1
0
mirror of synced 2026-08-05 09:47:05 +00:00

Apply updated Code Style

Closes gh-13881
This commit is contained in:
Marcus Da Coregio
2023-09-29 11:44:32 -03:00
parent 650692964e
commit 64e2a2ff8b
1172 changed files with 10805 additions and 8768 deletions
@@ -132,7 +132,7 @@ public class OpenID4JavaConsumer implements OpenIDConsumer {
"DiscoveryInformation is not available. Possible causes are lost session or replay attack");
}
List<OpenIDAttribute> attributesToFetch = (List<OpenIDAttribute>) request.getSession()
.getAttribute(ATTRIBUTE_LIST_KEY);
.getAttribute(ATTRIBUTE_LIST_KEY);
request.getSession().removeAttribute(DISCOVERY_INFO_KEY);
request.getSession().removeAttribute(ATTRIBUTE_LIST_KEY);
// extract the receiving URL from the HTTP request
@@ -165,7 +165,8 @@ public class OpenIDAuthenticationFilter extends AbstractAuthenticationProcessing
URL url = new URL(returnToUrl);
int port = url.getPort();
StringBuilder realmBuffer = new StringBuilder(returnToUrl.length()).append(url.getProtocol())
.append("://").append(url.getHost());
.append("://")
.append(url.getHost());
if (port > 0) {
realmBuffer.append(":").append(port);
}
@@ -18,6 +18,7 @@ package org.springframework.security.openid;
/**
* Authentication status codes, based on JanRain status codes
*
* @author JanRain Inc.
* @author Robin Bramley, Opsera Ltd
* @author Luke Taylor
@@ -68,7 +68,7 @@ public class OpenID4JavaConsumerTests {
MockHttpServletRequest request = new MockHttpServletRequest();
consumer.beginConsumption(request, "", "", "");
assertThat(request.getSession().getAttribute("SPRING_SECURITY_OPEN_ID_ATTRIBUTES_FETCH_LIST"))
.isEqualTo(this.attributes);
.isEqualTo(this.attributes);
assertThat(request.getSession().getAttribute(DiscoveryInformation.class.getName())).isEqualTo(di);
// Check with empty attribute fetch list
consumer = new OpenID4JavaConsumer(mgr, new NullAxFetchListFactory());
@@ -82,7 +82,7 @@ public class OpenID4JavaConsumerTests {
OpenID4JavaConsumer consumer = new OpenID4JavaConsumer(mgr, new NullAxFetchListFactory());
given(mgr.discover(any())).willThrow(new DiscoveryException("msg"));
assertThatExceptionOfType(OpenIDConsumerException.class)
.isThrownBy(() -> consumer.beginConsumption(new MockHttpServletRequest(), "", "", ""));
.isThrownBy(() -> consumer.beginConsumption(new MockHttpServletRequest(), "", "", ""));
}
@Test
@@ -90,11 +90,11 @@ public class OpenID4JavaConsumerTests {
ConsumerManager mgr = mock(ConsumerManager.class);
OpenID4JavaConsumer consumer = new OpenID4JavaConsumer(mgr, new NullAxFetchListFactory());
given(mgr.authenticate(ArgumentMatchers.<DiscoveryInformation>any(), any(), any()))
.willThrow(new MessageException("msg"), new ConsumerException("msg"));
.willThrow(new MessageException("msg"), new ConsumerException("msg"));
assertThatExceptionOfType(OpenIDConsumerException.class)
.isThrownBy(() -> consumer.beginConsumption(new MockHttpServletRequest(), "", "", ""));
.isThrownBy(() -> consumer.beginConsumption(new MockHttpServletRequest(), "", "", ""));
assertThatExceptionOfType(OpenIDConsumerException.class)
.isThrownBy(() -> consumer.beginConsumption(new MockHttpServletRequest(), "", "", ""));
.isThrownBy(() -> consumer.beginConsumption(new MockHttpServletRequest(), "", "", ""));
}
@Test
@@ -115,7 +115,7 @@ public class OpenID4JavaConsumerTests {
ConsumerManager mgr = mock(ConsumerManager.class);
OpenID4JavaConsumer consumer = new OpenID4JavaConsumer(mgr, new NullAxFetchListFactory());
given(mgr.verify(any(), any(ParameterList.class), any(DiscoveryInformation.class)))
.willThrow(new MessageException(""), new AssociationException(""), new DiscoveryException(""));
.willThrow(new MessageException(""), new AssociationException(""), new DiscoveryException(""));
MockHttpServletRequest request = new MockHttpServletRequest();
request.setQueryString("x=5");
assertThatExceptionOfType(OpenIDConsumerException.class).isThrownBy(() -> consumer.endConsumption(request));
@@ -164,14 +164,14 @@ public class OpenID4JavaConsumerTests {
given(msg.getExtension(AxMessage.OPENID_NS_AX)).willThrow(new MessageException(""));
given(fr.getAttributeValues("a")).willReturn(Arrays.asList("x", "y"));
assertThatExceptionOfType(OpenIDConsumerException.class)
.isThrownBy(() -> consumer.fetchAxAttributes(msg, this.attributes));
.isThrownBy(() -> consumer.fetchAxAttributes(msg, this.attributes));
}
@Test
public void missingDiscoveryInformationThrowsException() throws Exception {
OpenID4JavaConsumer consumer = new OpenID4JavaConsumer(new NullAxFetchListFactory());
assertThatExceptionOfType(OpenIDConsumerException.class)
.isThrownBy(() -> consumer.endConsumption(new MockHttpServletRequest()));
.isThrownBy(() -> consumer.endConsumption(new MockHttpServletRequest()));
}
@Test
@@ -62,7 +62,8 @@ public class OpenIDAuthenticationProviderTests {
null);
assertThat(preAuth.isAuthenticated()).isFalse();
assertThatExceptionOfType(AuthenticationCancelledException.class)
.isThrownBy(() -> provider.authenticate(preAuth)).withMessage("Log in cancelled");
.isThrownBy(() -> provider.authenticate(preAuth))
.withMessage("Log in cancelled");
}
/*
@@ -77,7 +78,7 @@ public class OpenIDAuthenticationProviderTests {
Authentication preAuth = new OpenIDAuthenticationToken(OpenIDAuthenticationStatus.ERROR, USERNAME, "", null);
assertThat(preAuth.isAuthenticated()).isFalse();
assertThatExceptionOfType(AuthenticationServiceException.class).isThrownBy(() -> provider.authenticate(preAuth))
.withMessage("Error message from server: ");
.withMessage("Error message from server: ");
}
/*
@@ -88,12 +89,12 @@ public class OpenIDAuthenticationProviderTests {
@Test
public void testAuthenticateFailure() {
OpenIDAuthenticationProvider provider = new OpenIDAuthenticationProvider();
provider.setAuthenticationUserDetailsService(
new UserDetailsByNameServiceWrapper<>(new MockUserDetailsService()));
provider
.setAuthenticationUserDetailsService(new UserDetailsByNameServiceWrapper<>(new MockUserDetailsService()));
Authentication preAuth = new OpenIDAuthenticationToken(OpenIDAuthenticationStatus.FAILURE, USERNAME, "", null);
assertThat(preAuth.isAuthenticated()).isFalse();
assertThatExceptionOfType(BadCredentialsException.class).isThrownBy(() -> provider.authenticate(preAuth))
.withMessage("Log in failed - identity could not be verified");
.withMessage("Log in failed - identity could not be verified");
}
/*
@@ -109,7 +110,7 @@ public class OpenIDAuthenticationProviderTests {
null);
assertThat(preAuth.isAuthenticated()).isFalse();
assertThatExceptionOfType(AuthenticationServiceException.class).isThrownBy(() -> provider.authenticate(preAuth))
.withMessage("The server responded setup was needed, which shouldn't happen");
.withMessage("The server responded setup was needed, which shouldn't happen");
}
/*