Remove uses of the org.apache.geode.management.internal.security.ResourceConstants class to refer to Security constants and properties.
Resolves gh-70.
This commit is contained in:
@@ -13,17 +13,17 @@
|
||||
* or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.geode.security;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.geode.LogWriter;
|
||||
import org.apache.geode.distributed.DistributedMember;
|
||||
import org.apache.geode.management.internal.security.ResourceConstants;
|
||||
import org.apache.geode.security.AuthInitialize;
|
||||
import org.apache.geode.security.AuthenticationFailedException;
|
||||
|
||||
import org.springframework.geode.util.GeodeConstants;
|
||||
|
||||
/**
|
||||
* Simple, test {@link AuthInitialize} implementation.
|
||||
*
|
||||
@@ -51,11 +51,11 @@ public class TestAuthInitialize implements AuthInitialize {
|
||||
|
||||
Properties credentials = new Properties();
|
||||
|
||||
credentials.setProperty(ResourceConstants.USER_NAME,
|
||||
securityProperties.getProperty(ResourceConstants.USER_NAME, DEFAULT_USERNAME));
|
||||
credentials.setProperty(GeodeConstants.USERNAME,
|
||||
securityProperties.getProperty(GeodeConstants.USERNAME, DEFAULT_USERNAME));
|
||||
|
||||
credentials.setProperty(ResourceConstants.PASSWORD,
|
||||
securityProperties.getProperty(ResourceConstants.PASSWORD, DEFAULT_PASSWORD));
|
||||
credentials.setProperty(GeodeConstants.PASSWORD,
|
||||
securityProperties.getProperty(GeodeConstants.PASSWORD, DEFAULT_PASSWORD));
|
||||
|
||||
return credentials;
|
||||
}
|
||||
|
||||
@@ -19,9 +19,10 @@ import java.io.Serializable;
|
||||
import java.security.Principal;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.geode.management.internal.security.ResourceConstants;
|
||||
import org.apache.geode.security.AuthenticationFailedException;
|
||||
|
||||
import org.springframework.geode.util.GeodeConstants;
|
||||
|
||||
/**
|
||||
* Simple, test {@link org.apache.geode.security.SecurityManager}.
|
||||
*
|
||||
@@ -37,8 +38,8 @@ public class TestSecurityManager implements org.apache.geode.security.SecurityMa
|
||||
@Override
|
||||
public Object authenticate(Properties credentials) throws AuthenticationFailedException {
|
||||
|
||||
String username = credentials.getProperty(ResourceConstants.USER_NAME);
|
||||
String password = credentials.getProperty(ResourceConstants.PASSWORD);
|
||||
String username = credentials.getProperty(GeodeConstants.USERNAME);
|
||||
String password = credentials.getProperty(GeodeConstants.PASSWORD);
|
||||
|
||||
if (!String.valueOf(username).equals(password)) {
|
||||
throw new AuthenticationFailedException(String.format("User [%s] could not be authenticated", username));
|
||||
|
||||
@@ -13,18 +13,18 @@
|
||||
* or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.geode.security;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.geode.management.internal.security.ResourceConstants;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.geode.util.GeodeConstants;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link TestAuthInitialize}.
|
||||
* Unit Tests for {@link TestAuthInitialize}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see java.util.Properties
|
||||
@@ -45,11 +45,11 @@ public class TestAuthInitializeUnitTests {
|
||||
Properties securityProperties = new Properties();
|
||||
|
||||
if (isSet(username)) {
|
||||
securityProperties.setProperty(ResourceConstants.USER_NAME, username);
|
||||
securityProperties.setProperty(GeodeConstants.USERNAME, username);
|
||||
}
|
||||
|
||||
if (isSet(password)) {
|
||||
securityProperties.setProperty(ResourceConstants.PASSWORD, password);
|
||||
securityProperties.setProperty(GeodeConstants.PASSWORD, password);
|
||||
}
|
||||
|
||||
return securityProperties;
|
||||
@@ -62,8 +62,8 @@ public class TestAuthInitializeUnitTests {
|
||||
this.authInitialize.getCredentials(newSecurityProperties("testUser", "s3cr3t"));
|
||||
|
||||
assertThat(credentials).isNotNull();
|
||||
assertThat(credentials.getProperty(ResourceConstants.USER_NAME)).isEqualTo("testUser");
|
||||
assertThat(credentials.getProperty(ResourceConstants.PASSWORD)).isEqualTo("s3cr3t");
|
||||
assertThat(credentials.getProperty(GeodeConstants.USERNAME)).isEqualTo("testUser");
|
||||
assertThat(credentials.getProperty(GeodeConstants.PASSWORD)).isEqualTo("s3cr3t");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -73,8 +73,8 @@ public class TestAuthInitializeUnitTests {
|
||||
this.authInitialize.getCredentials(newSecurityProperties("testUser", null));
|
||||
|
||||
assertThat(credentials).isNotNull();
|
||||
assertThat(credentials.getProperty(ResourceConstants.USER_NAME)).isEqualTo("testUser");
|
||||
assertThat(credentials.getProperty(ResourceConstants.PASSWORD)).isEqualTo("test");
|
||||
assertThat(credentials.getProperty(GeodeConstants.USERNAME)).isEqualTo("testUser");
|
||||
assertThat(credentials.getProperty(GeodeConstants.PASSWORD)).isEqualTo("test");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -84,8 +84,8 @@ public class TestAuthInitializeUnitTests {
|
||||
this.authInitialize.getCredentials(newSecurityProperties(null, "s3cr3t"));
|
||||
|
||||
assertThat(credentials).isNotNull();
|
||||
assertThat(credentials.getProperty(ResourceConstants.USER_NAME)).isEqualTo("test");
|
||||
assertThat(credentials.getProperty(ResourceConstants.PASSWORD)).isEqualTo("s3cr3t");
|
||||
assertThat(credentials.getProperty(GeodeConstants.USERNAME)).isEqualTo("test");
|
||||
assertThat(credentials.getProperty(GeodeConstants.PASSWORD)).isEqualTo("s3cr3t");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -95,7 +95,7 @@ public class TestAuthInitializeUnitTests {
|
||||
this.authInitialize.getCredentials(newSecurityProperties(null, null));
|
||||
|
||||
assertThat(credentials).isNotNull();
|
||||
assertThat(credentials.getProperty(ResourceConstants.USER_NAME)).isEqualTo("test");
|
||||
assertThat(credentials.getProperty(ResourceConstants.PASSWORD)).isEqualTo("test");
|
||||
assertThat(credentials.getProperty(GeodeConstants.USERNAME)).isEqualTo("test");
|
||||
assertThat(credentials.getProperty(GeodeConstants.PASSWORD)).isEqualTo("test");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.geode.security;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -22,13 +21,15 @@ import static org.mockito.Mockito.mock;
|
||||
import java.security.Principal;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.geode.management.internal.security.ResourceConstants;
|
||||
import org.apache.geode.security.AuthenticationFailedException;
|
||||
import org.apache.geode.security.ResourcePermission;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.geode.security.AuthenticationFailedException;
|
||||
import org.apache.geode.security.ResourcePermission;
|
||||
|
||||
import org.springframework.geode.util.GeodeConstants;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link org.springframework.geode.security.TestSecurityManager}.
|
||||
* Unit Tests for {@link org.springframework.geode.security.TestSecurityManager}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
@@ -44,8 +45,8 @@ public class TestSecurityManagerUnitTests {
|
||||
|
||||
Properties securityProperties = new Properties();
|
||||
|
||||
securityProperties.setProperty(ResourceConstants.USER_NAME, username);
|
||||
securityProperties.setProperty(ResourceConstants.PASSWORD, password);
|
||||
securityProperties.setProperty(GeodeConstants.USERNAME, username);
|
||||
securityProperties.setProperty(GeodeConstants.PASSWORD, password);
|
||||
|
||||
return securityProperties;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ dependencies {
|
||||
|
||||
compile project(":spring-geode")
|
||||
|
||||
optional project(':apache-geode-extensions')
|
||||
|
||||
optional "org.springframework.boot:spring-boot-autoconfigure-processor"
|
||||
optional "org.springframework.boot:spring-boot-configuration-processor"
|
||||
|
||||
|
||||
@@ -23,8 +23,6 @@ import java.net.PasswordAuthentication;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.apache.geode.management.internal.security.ResourceConstants;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -33,6 +31,7 @@ import org.springframework.core.env.Environment;
|
||||
import org.springframework.data.gemfire.config.admin.remote.RestHttpGemfireAdminTemplate;
|
||||
import org.springframework.data.gemfire.config.annotation.ClusterConfigurationConfiguration;
|
||||
import org.springframework.geode.core.util.ObjectUtils;
|
||||
import org.springframework.geode.util.GeodeConstants;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpRequest;
|
||||
import org.springframework.http.client.ClientHttpRequestExecution;
|
||||
@@ -179,8 +178,8 @@ public class HttpBasicAuthenticationSecurityConfiguration {
|
||||
|
||||
HttpHeaders requestHeaders = request.getHeaders();
|
||||
|
||||
requestHeaders.add(ResourceConstants.USER_NAME, getUsername());
|
||||
requestHeaders.add(ResourceConstants.PASSWORD, getPassword());
|
||||
requestHeaders.add(GeodeConstants.USERNAME, getUsername());
|
||||
requestHeaders.add(GeodeConstants.PASSWORD, getPassword());
|
||||
}
|
||||
|
||||
return execution.execute(request, body);
|
||||
|
||||
@@ -24,7 +24,7 @@ import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -38,13 +38,13 @@ import org.junit.Test;
|
||||
|
||||
import org.apache.geode.cache.GemFireCache;
|
||||
import org.apache.geode.cache.client.ClientCache;
|
||||
import org.apache.geode.management.internal.security.ResourceConstants;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.data.gemfire.config.admin.remote.RestHttpGemfireAdminTemplate;
|
||||
import org.springframework.data.gemfire.config.annotation.ClusterConfigurationConfiguration;
|
||||
import org.springframework.geode.boot.autoconfigure.support.HttpBasicAuthenticationSecurityConfiguration;
|
||||
import org.springframework.geode.util.GeodeConstants;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpRequest;
|
||||
import org.springframework.http.client.ClientHttpRequestExecution;
|
||||
@@ -124,11 +124,10 @@ public class HttpBasicAuthenticationSecurityConfigurationUnitTests {
|
||||
assertThat(beanPostProcessor.postProcessBeforeInitialization(bean, "testBean")).isEqualTo(bean);
|
||||
assertThat(beanPostProcessor.postProcessAfterInitialization(bean, "testBean")).isEqualTo(bean);
|
||||
|
||||
verifyZeroInteractions(mockEnvironment);
|
||||
verifyNoMoreInteractions(mockEnvironment);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("all")
|
||||
public void schemaObjectInitializerPostProcessorProcessesClusterSchemaObjectInitializerBeans() throws Exception {
|
||||
|
||||
Environment mockEnvironment = mock(Environment.class);
|
||||
@@ -233,8 +232,8 @@ public class HttpBasicAuthenticationSecurityConfigurationUnitTests {
|
||||
|
||||
interceptor.intercept(mockHttpRequest, body, mockExecution);
|
||||
|
||||
assertThat(httpHeaders.getFirst(ResourceConstants.USER_NAME)).isEqualTo("master");
|
||||
assertThat(httpHeaders.getFirst(ResourceConstants.PASSWORD)).isEqualTo("s3cr3t");
|
||||
assertThat(httpHeaders.getFirst(GeodeConstants.USERNAME)).isEqualTo("master");
|
||||
assertThat(httpHeaders.getFirst(GeodeConstants.PASSWORD)).isEqualTo("s3cr3t");
|
||||
|
||||
verify(mockHttpRequest, times(1)).getHeaders();
|
||||
verify(mockExecution, times(1)).execute(eq(mockHttpRequest), eq(body));
|
||||
@@ -263,8 +262,8 @@ public class HttpBasicAuthenticationSecurityConfigurationUnitTests {
|
||||
|
||||
interceptor.intercept(mockHttpRequest, body, mockExecution);
|
||||
|
||||
assertThat(httpHeaders.containsKey(ResourceConstants.USER_NAME)).isFalse();
|
||||
assertThat(httpHeaders.containsKey(ResourceConstants.PASSWORD)).isFalse();
|
||||
assertThat(httpHeaders.containsKey(GeodeConstants.USERNAME)).isFalse();
|
||||
assertThat(httpHeaders.containsKey(GeodeConstants.PASSWORD)).isFalse();
|
||||
|
||||
verify(mockHttpRequest, never()).getHeaders();
|
||||
verify(mockExecution, times(1)).execute(eq(mockHttpRequest), eq(body));
|
||||
|
||||
Reference in New Issue
Block a user