Reformat code using spring-javaformat
Run `./gradlew format` to reformat all java files. Issue gh-8945
This commit is contained in:
@@ -27,14 +27,12 @@ public interface DnsResolver {
|
||||
/**
|
||||
* Resolves the IP Address (A record) to the specified host name. Throws
|
||||
* DnsEntryNotFoundException if there is no record.
|
||||
*
|
||||
* @param hostname The hostname for which you need the IP Address
|
||||
* @return IP Address as a String
|
||||
* @throws DnsEntryNotFoundException No record found
|
||||
* @throws DnsLookupException Unknown DNS error
|
||||
*/
|
||||
String resolveIpAddress(String hostname) throws DnsEntryNotFoundException,
|
||||
DnsLookupException;
|
||||
String resolveIpAddress(String hostname) throws DnsEntryNotFoundException, DnsLookupException;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -56,22 +54,19 @@ public interface DnsResolver {
|
||||
* The method will return the record with highest priority (which means the lowest
|
||||
* number in the DNS record) and if there are more than one records with the same
|
||||
* priority, it will return the one with the highest weight. You will find more
|
||||
* informatione about DNS service records at <a
|
||||
* href="https://en.wikipedia.org/wiki/SRV_record">Wikipedia</a>.
|
||||
*
|
||||
* informatione about DNS service records at
|
||||
* <a href="https://en.wikipedia.org/wiki/SRV_record">Wikipedia</a>.
|
||||
* @param serviceType The service type you are searching for, e.g. ldap, kerberos, ...
|
||||
* @param domain The domain, in which you are searching for the service
|
||||
* @return The hostname of the service
|
||||
* @throws DnsEntryNotFoundException No record found
|
||||
* @throws DnsLookupException Unknown DNS error
|
||||
*/
|
||||
String resolveServiceEntry(String serviceType, String domain)
|
||||
throws DnsEntryNotFoundException, DnsLookupException;
|
||||
String resolveServiceEntry(String serviceType, String domain) throws DnsEntryNotFoundException, DnsLookupException;
|
||||
|
||||
/**
|
||||
* Resolves the host name for the specified service and then the IP Address for this
|
||||
* host in one call.
|
||||
*
|
||||
* @param serviceType The service type you are searching for, e.g. ldap, kerberos, ...
|
||||
* @param domain The domain, in which you are searching for the service
|
||||
* @return IP Address of the service
|
||||
|
||||
@@ -46,7 +46,6 @@ public class JndiDnsResolver implements DnsResolver {
|
||||
|
||||
/**
|
||||
* Allows to inject an own JNDI context factory.
|
||||
*
|
||||
* @param ctxFactory factory to use, when a DirContext is needed
|
||||
* @see InitialDirContext
|
||||
* @see DirContext
|
||||
@@ -107,12 +106,10 @@ public class JndiDnsResolver implements DnsResolver {
|
||||
|
||||
// This method is needed, so that we can use only one DirContext for
|
||||
// resolveServiceIpAddress().
|
||||
private String resolveServiceEntry(String serviceType, String domain,
|
||||
DirContext ctx) {
|
||||
private String resolveServiceEntry(String serviceType, String domain, DirContext ctx) {
|
||||
String result = null;
|
||||
try {
|
||||
String query = new StringBuilder("_").append(serviceType).append("._tcp.")
|
||||
.append(domain).toString();
|
||||
String query = new StringBuilder("_").append(serviceType).append("._tcp.").append(domain).toString();
|
||||
Attribute dnsRecord = lookup(query, ctx, "SRV");
|
||||
// There are maybe more records defined, we will return the one
|
||||
// with the highest priority (lowest number) and the highest weight
|
||||
@@ -120,12 +117,11 @@ public class JndiDnsResolver implements DnsResolver {
|
||||
int highestPriority = -1;
|
||||
int highestWeight = -1;
|
||||
|
||||
for (NamingEnumeration<?> recordEnum = dnsRecord.getAll(); recordEnum
|
||||
.hasMoreElements();) {
|
||||
for (NamingEnumeration<?> recordEnum = dnsRecord.getAll(); recordEnum.hasMoreElements();) {
|
||||
String[] record = recordEnum.next().toString().split(" ");
|
||||
if (record.length != 4) {
|
||||
throw new DnsLookupException("Wrong service record for query " + query
|
||||
+ ": [" + Arrays.toString(record) + "]");
|
||||
throw new DnsLookupException(
|
||||
"Wrong service record for query " + query + ": [" + Arrays.toString(record) + "]");
|
||||
}
|
||||
int priority = Integer.parseInt(record[0]);
|
||||
int weight = Integer.parseInt(record[1]);
|
||||
@@ -143,8 +139,7 @@ public class JndiDnsResolver implements DnsResolver {
|
||||
}
|
||||
}
|
||||
catch (NamingException e) {
|
||||
throw new DnsLookupException(
|
||||
"DNS lookup failed for service " + serviceType + " at " + domain, e);
|
||||
throw new DnsLookupException("DNS lookup failed for service " + serviceType + " at " + domain, e);
|
||||
}
|
||||
|
||||
// remove the "." at the end
|
||||
@@ -162,8 +157,7 @@ public class JndiDnsResolver implements DnsResolver {
|
||||
}
|
||||
catch (NamingException e) {
|
||||
if (e instanceof NameNotFoundException) {
|
||||
throw new DnsEntryNotFoundException("DNS entry not found for:" + query,
|
||||
e);
|
||||
throw new DnsEntryNotFoundException("DNS entry not found for:" + query, e);
|
||||
}
|
||||
throw new DnsLookupException("DNS lookup failed for: " + query, e);
|
||||
}
|
||||
@@ -173,18 +167,18 @@ public class JndiDnsResolver implements DnsResolver {
|
||||
|
||||
public DirContext getCtx() {
|
||||
Hashtable<String, String> env = new Hashtable<>();
|
||||
env.put(Context.INITIAL_CONTEXT_FACTORY,
|
||||
"com.sun.jndi.dns.DnsContextFactory");
|
||||
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.dns.DnsContextFactory");
|
||||
env.put(Context.PROVIDER_URL, "dns:"); // This is needed for IBM JDK/JRE
|
||||
InitialDirContext ictx;
|
||||
try {
|
||||
ictx = new InitialDirContext(env);
|
||||
}
|
||||
catch (NamingException e) {
|
||||
throw new DnsLookupException(
|
||||
"Cannot create InitialDirContext for DNS lookup", e);
|
||||
throw new DnsLookupException("Cannot create InitialDirContext for DNS lookup", e);
|
||||
}
|
||||
return ictx;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,4 +17,3 @@
|
||||
* DNS resolution.
|
||||
*/
|
||||
package org.springframework.security.remoting.dns;
|
||||
|
||||
|
||||
@@ -34,13 +34,12 @@ import org.springframework.security.core.context.SecurityContextHolder;
|
||||
* @author Ben Alex
|
||||
* @author Rob Winch
|
||||
*/
|
||||
public class AuthenticationSimpleHttpInvokerRequestExecutor extends
|
||||
SimpleHttpInvokerRequestExecutor {
|
||||
public class AuthenticationSimpleHttpInvokerRequestExecutor extends SimpleHttpInvokerRequestExecutor {
|
||||
|
||||
// ~ Static fields/initializers
|
||||
// =====================================================================================
|
||||
|
||||
private static final Log logger = LogFactory
|
||||
.getLog(AuthenticationSimpleHttpInvokerRequestExecutor.class);
|
||||
private static final Log logger = LogFactory.getLog(AuthenticationSimpleHttpInvokerRequestExecutor.class);
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
@@ -53,13 +52,11 @@ public class AuthenticationSimpleHttpInvokerRequestExecutor extends
|
||||
/**
|
||||
* Provided so subclasses can perform additional configuration if required (eg set
|
||||
* additional request headers for non-security related information etc).
|
||||
*
|
||||
* @param con the HTTP connection to prepare
|
||||
* @param contentLength the length of the content to send
|
||||
*
|
||||
*/
|
||||
protected void doPrepareConnection(HttpURLConnection con, int contentLength)
|
||||
throws IOException {
|
||||
protected void doPrepareConnection(HttpURLConnection con, int contentLength) throws IOException {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,14 +70,11 @@ public class AuthenticationSimpleHttpInvokerRequestExecutor extends
|
||||
* The <code>SecurityContextHolder</code> is used to obtain the relevant principal and
|
||||
* credentials.
|
||||
* </p>
|
||||
*
|
||||
* @param con the HTTP connection to prepare
|
||||
* @param contentLength the length of the content to send
|
||||
*
|
||||
* @throws IOException if thrown by HttpURLConnection methods
|
||||
*/
|
||||
protected void prepareConnection(HttpURLConnection con, int contentLength)
|
||||
throws IOException {
|
||||
protected void prepareConnection(HttpURLConnection con, int contentLength) throws IOException {
|
||||
super.prepareConnection(con, contentLength);
|
||||
|
||||
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
|
||||
@@ -105,4 +99,5 @@ public class AuthenticationSimpleHttpInvokerRequestExecutor extends
|
||||
|
||||
doPrepareConnection(con, contentLength);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**
|
||||
* Enables use of Spring's <code>HttpInvoker</code> extension points to
|
||||
* present the <code>principal</code> and <code>credentials</code> located
|
||||
* in the <code>ContextHolder</code> via BASIC authentication.
|
||||
* Enables use of Spring's <code>HttpInvoker</code> extension points to present the
|
||||
* <code>principal</code> and <code>credentials</code> located in the
|
||||
* <code>ContextHolder</code> via BASIC authentication.
|
||||
* <p>
|
||||
* The beans are wired as follows:
|
||||
*
|
||||
@@ -32,4 +32,3 @@
|
||||
* </pre>
|
||||
*/
|
||||
package org.springframework.security.remoting.httpinvoker;
|
||||
|
||||
|
||||
@@ -17,4 +17,3 @@
|
||||
* Remote client related functionality.
|
||||
*/
|
||||
package org.springframework.security.remoting;
|
||||
|
||||
|
||||
@@ -46,13 +46,13 @@ public class ContextPropagatingRemoteInvocation extends RemoteInvocation {
|
||||
|
||||
private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID;
|
||||
|
||||
private static final Log logger = LogFactory
|
||||
.getLog(ContextPropagatingRemoteInvocation.class);
|
||||
private static final Log logger = LogFactory.getLog(ContextPropagatingRemoteInvocation.class);
|
||||
|
||||
// ~ Instance fields
|
||||
// ================================================================================================
|
||||
|
||||
private final String principal;
|
||||
|
||||
private final String credentials;
|
||||
|
||||
// ~ Constructors
|
||||
@@ -61,13 +61,11 @@ public class ContextPropagatingRemoteInvocation extends RemoteInvocation {
|
||||
/**
|
||||
* Constructs the object, storing the principal and credentials extracted from the
|
||||
* client-side security context.
|
||||
*
|
||||
* @param methodInvocation the method to invoke
|
||||
*/
|
||||
public ContextPropagatingRemoteInvocation(MethodInvocation methodInvocation) {
|
||||
super(methodInvocation);
|
||||
Authentication currentUser = SecurityContextHolder.getContext()
|
||||
.getAuthentication();
|
||||
Authentication currentUser = SecurityContextHolder.getContext().getAuthentication();
|
||||
|
||||
if (currentUser != null) {
|
||||
principal = currentUser.getName();
|
||||
@@ -93,18 +91,16 @@ public class ContextPropagatingRemoteInvocation extends RemoteInvocation {
|
||||
* Invoked on the server-side.
|
||||
* <p>
|
||||
* The transmitted principal and credentials will be used to create an unauthenticated
|
||||
* {@code Authentication} instance for processing by the {@code AuthenticationManager}.
|
||||
*
|
||||
* {@code Authentication} instance for processing by the
|
||||
* {@code AuthenticationManager}.
|
||||
* @param targetObject the target object to apply the invocation to
|
||||
*
|
||||
* @return the invocation result
|
||||
*
|
||||
* @throws NoSuchMethodException if the method name could not be resolved
|
||||
* @throws IllegalAccessException if the method could not be accessed
|
||||
* @throws InvocationTargetException if the method invocation resulted in an exception
|
||||
*/
|
||||
public Object invoke(Object targetObject) throws NoSuchMethodException,
|
||||
IllegalAccessException, InvocationTargetException {
|
||||
public Object invoke(Object targetObject)
|
||||
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
|
||||
|
||||
if (principal != null) {
|
||||
Authentication request = createAuthenticationRequest(principal, credentials);
|
||||
@@ -131,8 +127,8 @@ public class ContextPropagatingRemoteInvocation extends RemoteInvocation {
|
||||
/**
|
||||
* Creates the server-side authentication request object.
|
||||
*/
|
||||
protected Authentication createAuthenticationRequest(String principal,
|
||||
String credentials) {
|
||||
protected Authentication createAuthenticationRequest(String principal, String credentials) {
|
||||
return new UsernamePasswordAuthenticationToken(principal, credentials);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,10 +34,12 @@ import org.springframework.remoting.support.RemoteInvocationFactory;
|
||||
* @author Ben Alex
|
||||
*/
|
||||
public class ContextPropagatingRemoteInvocationFactory implements RemoteInvocationFactory {
|
||||
|
||||
// ~ Methods
|
||||
// ========================================================================================================
|
||||
|
||||
public RemoteInvocation createRemoteInvocation(MethodInvocation methodInvocation) {
|
||||
return new ContextPropagatingRemoteInvocation(methodInvocation);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,11 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
/**
|
||||
* Enables use of Spring's RMI remoting extension points to propagate the <code>SecurityContextHolder</code> (which
|
||||
* should contain an <code>Authentication</code> request token) from one JVM to the remote JVM.
|
||||
* Enables use of Spring's RMI remoting extension points to propagate the
|
||||
* <code>SecurityContextHolder</code> (which should contain an <code>Authentication</code>
|
||||
* request token) from one JVM to the remote JVM.
|
||||
* <p>
|
||||
* The beans are wired as follows:
|
||||
* <pre>
|
||||
* The beans are wired as follows: <pre>
|
||||
* <bean id="test" class="org.springframework.remoting.rmi.RmiProxyFactoryBean">
|
||||
* <property name="serviceUrl"><value>rmi://localhost/Test</value></property>
|
||||
* <property name="serviceInterface"><value>test.TargetInterface</value></property>
|
||||
@@ -31,4 +31,3 @@
|
||||
* </pre>
|
||||
*/
|
||||
package org.springframework.security.remoting.rmi;
|
||||
|
||||
|
||||
@@ -30,14 +30,15 @@ import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Mike Wiesner
|
||||
* @since 3.0
|
||||
*/
|
||||
public class JndiDnsResolverTests {
|
||||
|
||||
private JndiDnsResolver dnsResolver;
|
||||
|
||||
private InitialContextFactory contextFactory;
|
||||
|
||||
private DirContext context;
|
||||
|
||||
@Before
|
||||
@@ -53,8 +54,7 @@ public class JndiDnsResolverTests {
|
||||
public void testResolveIpAddress() throws Exception {
|
||||
Attributes records = new BasicAttributes("A", "63.246.7.80");
|
||||
|
||||
when(context.getAttributes("www.springsource.com", new String[] { "A" }))
|
||||
.thenReturn(records);
|
||||
when(context.getAttributes("www.springsource.com", new String[] { "A" })).thenReturn(records);
|
||||
|
||||
String ipAddress = dnsResolver.resolveIpAddress("www.springsource.com");
|
||||
assertThat(ipAddress).isEqualTo("63.246.7.80");
|
||||
@@ -62,8 +62,8 @@ public class JndiDnsResolverTests {
|
||||
|
||||
@Test(expected = DnsEntryNotFoundException.class)
|
||||
public void testResolveIpAddressNotExisting() throws Exception {
|
||||
when(context.getAttributes(any(String.class), any(String[].class))).thenThrow(
|
||||
new NameNotFoundException("not found"));
|
||||
when(context.getAttributes(any(String.class), any(String[].class)))
|
||||
.thenThrow(new NameNotFoundException("not found"));
|
||||
|
||||
dnsResolver.resolveIpAddress("notexisting.ansdansdugiuzgguzgioansdiandwq.foo");
|
||||
}
|
||||
@@ -72,8 +72,7 @@ public class JndiDnsResolverTests {
|
||||
public void testResolveServiceEntry() throws Exception {
|
||||
BasicAttributes records = createSrvRecords();
|
||||
|
||||
when(context.getAttributes("_ldap._tcp.springsource.com", new String[] { "SRV" }))
|
||||
.thenReturn(records);
|
||||
when(context.getAttributes("_ldap._tcp.springsource.com", new String[] { "SRV" })).thenReturn(records);
|
||||
|
||||
String hostname = dnsResolver.resolveServiceEntry("ldap", "springsource.com");
|
||||
assertThat(hostname).isEqualTo("kdc.springsource.com");
|
||||
@@ -81,8 +80,8 @@ public class JndiDnsResolverTests {
|
||||
|
||||
@Test(expected = DnsEntryNotFoundException.class)
|
||||
public void testResolveServiceEntryNotExisting() throws Exception {
|
||||
when(context.getAttributes(any(String.class), any(String[].class))).thenThrow(
|
||||
new NameNotFoundException("not found"));
|
||||
when(context.getAttributes(any(String.class), any(String[].class)))
|
||||
.thenThrow(new NameNotFoundException("not found"));
|
||||
|
||||
dnsResolver.resolveServiceEntry("wrong", "secpod.de");
|
||||
}
|
||||
@@ -91,20 +90,16 @@ public class JndiDnsResolverTests {
|
||||
public void testResolveServiceIpAddress() throws Exception {
|
||||
BasicAttributes srvRecords = createSrvRecords();
|
||||
BasicAttributes aRecords = new BasicAttributes("A", "63.246.7.80");
|
||||
when(context.getAttributes("_ldap._tcp.springsource.com", new String[] { "SRV" }))
|
||||
.thenReturn(srvRecords);
|
||||
when(context.getAttributes("kdc.springsource.com", new String[] { "A" }))
|
||||
.thenReturn(aRecords);
|
||||
when(context.getAttributes("_ldap._tcp.springsource.com", new String[] { "SRV" })).thenReturn(srvRecords);
|
||||
when(context.getAttributes("kdc.springsource.com", new String[] { "A" })).thenReturn(aRecords);
|
||||
|
||||
String ipAddress = dnsResolver
|
||||
.resolveServiceIpAddress("ldap", "springsource.com");
|
||||
String ipAddress = dnsResolver.resolveServiceIpAddress("ldap", "springsource.com");
|
||||
assertThat(ipAddress).isEqualTo("63.246.7.80");
|
||||
}
|
||||
|
||||
@Test(expected = DnsLookupException.class)
|
||||
public void testUnknowError() throws Exception {
|
||||
when(context.getAttributes(any(String.class), any(String[].class))).thenThrow(
|
||||
new NamingException("error"));
|
||||
when(context.getAttributes(any(String.class), any(String[].class))).thenThrow(new NamingException("error"));
|
||||
dnsResolver.resolveIpAddress("");
|
||||
}
|
||||
|
||||
@@ -121,4 +116,5 @@ public class JndiDnsResolverTests {
|
||||
records.put(record);
|
||||
return records;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -49,8 +49,7 @@ public class AuthenticationSimpleHttpInvokerRequestExecutorTests {
|
||||
@Test
|
||||
public void testNormalOperation() throws Exception {
|
||||
// Setup client-side context
|
||||
Authentication clientSideAuthentication = new UsernamePasswordAuthenticationToken(
|
||||
"Aladdin", "open sesame");
|
||||
Authentication clientSideAuthentication = new UsernamePasswordAuthenticationToken("Aladdin", "open sesame");
|
||||
SecurityContextHolder.getContext().setAuthentication(clientSideAuthentication);
|
||||
|
||||
// Create a connection and ensure our executor sets its
|
||||
@@ -62,8 +61,7 @@ public class AuthenticationSimpleHttpInvokerRequestExecutorTests {
|
||||
// Check connection properties
|
||||
// See https://tools.ietf.org/html/rfc1945 section 11.1 for example
|
||||
// we are comparing against
|
||||
assertThat(conn.getRequestProperty("Authorization")).isEqualTo(
|
||||
"Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
|
||||
assertThat(conn.getRequestProperty("Authorization")).isEqualTo("Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -83,8 +81,8 @@ public class AuthenticationSimpleHttpInvokerRequestExecutorTests {
|
||||
// SEC-1975
|
||||
@Test
|
||||
public void testNullContextHolderWhenAnonymous() throws Exception {
|
||||
AnonymousAuthenticationToken anonymous = new AnonymousAuthenticationToken("key",
|
||||
"principal", AuthorityUtils.createAuthorityList("ROLE_ANONYMOUS"));
|
||||
AnonymousAuthenticationToken anonymous = new AnonymousAuthenticationToken("key", "principal",
|
||||
AuthorityUtils.createAuthorityList("ROLE_ANONYMOUS"));
|
||||
SecurityContextHolder.getContext().setAuthentication(anonymous);
|
||||
|
||||
// Create a connection and ensure our executor sets its
|
||||
@@ -127,5 +125,7 @@ public class AuthenticationSimpleHttpInvokerRequestExecutorTests {
|
||||
public boolean usingProxy() {
|
||||
throw new UnsupportedOperationException("mock not implemented");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -49,8 +49,7 @@ public class ContextPropagatingRemoteInvocationTests {
|
||||
private ContextPropagatingRemoteInvocation getRemoteInvocation() throws Exception {
|
||||
Class<TargetObject> clazz = TargetObject.class;
|
||||
Method method = clazz.getMethod("makeLowerCase", new Class[] { String.class });
|
||||
MethodInvocation mi = new SimpleMethodInvocation(new TargetObject(), method,
|
||||
"SOME_STRING");
|
||||
MethodInvocation mi = new SimpleMethodInvocation(new TargetObject(), method, "SOME_STRING");
|
||||
|
||||
ContextPropagatingRemoteInvocationFactory factory = new ContextPropagatingRemoteInvocationFactory();
|
||||
|
||||
@@ -60,8 +59,7 @@ public class ContextPropagatingRemoteInvocationTests {
|
||||
@Test
|
||||
public void testContextIsResetEvenIfExceptionOccurs() throws Exception {
|
||||
// Setup client-side context
|
||||
Authentication clientSideAuthentication = new UsernamePasswordAuthenticationToken(
|
||||
"rod", "koala");
|
||||
Authentication clientSideAuthentication = new UsernamePasswordAuthenticationToken("rod", "koala");
|
||||
SecurityContextHolder.getContext().setAuthentication(clientSideAuthentication);
|
||||
|
||||
ContextPropagatingRemoteInvocation remoteInvocation = getRemoteInvocation();
|
||||
@@ -76,16 +74,14 @@ public class ContextPropagatingRemoteInvocationTests {
|
||||
// expected
|
||||
}
|
||||
|
||||
assertThat(
|
||||
SecurityContextHolder.getContext().getAuthentication()).withFailMessage(
|
||||
"Authentication must be null").isNull();
|
||||
assertThat(SecurityContextHolder.getContext().getAuthentication())
|
||||
.withFailMessage("Authentication must be null").isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNormalOperation() throws Exception {
|
||||
// Setup client-side context
|
||||
Authentication clientSideAuthentication = new UsernamePasswordAuthenticationToken(
|
||||
"rod", "koala");
|
||||
Authentication clientSideAuthentication = new UsernamePasswordAuthenticationToken("rod", "koala");
|
||||
SecurityContextHolder.getContext().setAuthentication(clientSideAuthentication);
|
||||
|
||||
ContextPropagatingRemoteInvocation remoteInvocation = getRemoteInvocation();
|
||||
@@ -109,19 +105,17 @@ public class ContextPropagatingRemoteInvocationTests {
|
||||
SecurityContextHolder.clearContext(); // unnecessary, but for
|
||||
// explicitness
|
||||
|
||||
assertThat(remoteInvocation.invoke(new TargetObject())).isEqualTo(
|
||||
"some_string Authentication empty");
|
||||
assertThat(remoteInvocation.invoke(new TargetObject())).isEqualTo("some_string Authentication empty");
|
||||
}
|
||||
|
||||
// SEC-1867
|
||||
@Test
|
||||
public void testNullCredentials() throws Exception {
|
||||
Authentication clientSideAuthentication = new UsernamePasswordAuthenticationToken(
|
||||
"rod", null);
|
||||
Authentication clientSideAuthentication = new UsernamePasswordAuthenticationToken("rod", null);
|
||||
SecurityContextHolder.getContext().setAuthentication(clientSideAuthentication);
|
||||
|
||||
ContextPropagatingRemoteInvocation remoteInvocation = getRemoteInvocation();
|
||||
assertThat(
|
||||
ReflectionTestUtils.getField(remoteInvocation, "credentials")).isNull();
|
||||
assertThat(ReflectionTestUtils.getField(remoteInvocation, "credentials")).isNull();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user