diff --git a/documentation/docs/release-notes.md b/documentation/docs/release-notes.md index fc54255988..baacdaee64 100644 --- a/documentation/docs/release-notes.md +++ b/documentation/docs/release-notes.md @@ -13,6 +13,7 @@ title: Release notes: - The `CallbackUrlResolver` computes the callback URL (using a query parameter or a path parameter to define the client), based on the `UrlResolver` which computes a URL - You can define an error (page) URL at the logics' level to handle unexpected exceptions - The SAML Keystore alias can be defined via a property +- The client name is not set at the credential's level **v2.2.0**: diff --git a/pac4j-cas/src/main/java/org/pac4j/cas/client/CasClient.java b/pac4j-cas/src/main/java/org/pac4j/cas/client/CasClient.java index 50d2ac7844..5749bdf3c0 100644 --- a/pac4j-cas/src/main/java/org/pac4j/cas/client/CasClient.java +++ b/pac4j-cas/src/main/java/org/pac4j/cas/client/CasClient.java @@ -46,8 +46,8 @@ protected void clientInit() { configuration.setUrlResolver(this.getCallbackUrlResolver().getUrlResolver()); defaultRedirectActionBuilder(new CasRedirectActionBuilder(configuration, this)); - defaultCredentialsExtractor(new TicketAndLogoutRequestExtractor(configuration, getName())); - defaultAuthenticator(new CasAuthenticator(configuration, getCallbackUrlResolver(), callbackUrl)); + defaultCredentialsExtractor(new TicketAndLogoutRequestExtractor(configuration)); + defaultAuthenticator(new CasAuthenticator(configuration, getName(), getCallbackUrlResolver(), callbackUrl)); defaultLogoutActionBuilder(new CasLogoutActionBuilder<>(configuration.getPrefixUrl() + "logout", configuration.getPostLogoutUrlParameter())); addAuthorizationGenerator(new DefaultCasAuthorizationGenerator<>()); diff --git a/pac4j-cas/src/main/java/org/pac4j/cas/client/direct/DirectCasClient.java b/pac4j-cas/src/main/java/org/pac4j/cas/client/direct/DirectCasClient.java index 0f39c7b5df..42309b8d11 100644 --- a/pac4j-cas/src/main/java/org/pac4j/cas/client/direct/DirectCasClient.java +++ b/pac4j-cas/src/main/java/org/pac4j/cas/client/direct/DirectCasClient.java @@ -54,9 +54,9 @@ protected void clientInit() { CommonHelper.assertNotNull("configuration", this.configuration); CommonHelper.assertTrue(!configuration.isGateway(), "the DirectCasClient can not support gateway to avoid infinite loops"); - defaultCredentialsExtractor(new ParameterExtractor(CasConfiguration.TICKET_PARAMETER, true, false, getName())); + defaultCredentialsExtractor(new ParameterExtractor(CasConfiguration.TICKET_PARAMETER, true, false)); // only a fake one for the initialization as we will build a new one with the current url for each request - super.defaultAuthenticator(new CasAuthenticator(configuration, callbackUrlResolver, "fake")); + super.defaultAuthenticator(new CasAuthenticator(configuration, getName(), callbackUrlResolver, "fake")); addAuthorizationGenerator(new DefaultCasAuthorizationGenerator<>()); } @@ -79,7 +79,7 @@ protected TokenCredentials retrieveCredentials(final WebContext context) { // clean url from ticket parameter callbackUrl = CommonHelper.substringBefore(callbackUrl, "?" + CasConfiguration.TICKET_PARAMETER + "="); callbackUrl = CommonHelper.substringBefore(callbackUrl, "&" + CasConfiguration.TICKET_PARAMETER + "="); - final CasAuthenticator casAuthenticator = new CasAuthenticator(configuration, callbackUrlResolver, callbackUrl); + final CasAuthenticator casAuthenticator = new CasAuthenticator(configuration, getName(), callbackUrlResolver, callbackUrl); casAuthenticator.init(); casAuthenticator.validate(credentials, context); diff --git a/pac4j-cas/src/main/java/org/pac4j/cas/client/direct/DirectCasProxyClient.java b/pac4j-cas/src/main/java/org/pac4j/cas/client/direct/DirectCasProxyClient.java index 2da09d5b66..8f70fde225 100644 --- a/pac4j-cas/src/main/java/org/pac4j/cas/client/direct/DirectCasProxyClient.java +++ b/pac4j-cas/src/main/java/org/pac4j/cas/client/direct/DirectCasProxyClient.java @@ -52,8 +52,8 @@ protected void clientInit() { CommonHelper.assertTrue(protocol == CasProtocol.CAS20_PROXY || protocol == CasProtocol.CAS30_PROXY, "The DirectCasProxyClient must be configured with a CAS proxy protocol (CAS20_PROXY or CAS30_PROXY)"); - defaultCredentialsExtractor(new ParameterExtractor(CasConfiguration.TICKET_PARAMETER, true, false, getName())); - defaultAuthenticator(new CasAuthenticator(configuration, callbackUrlResolver, this.serviceUrl)); + defaultCredentialsExtractor(new ParameterExtractor(CasConfiguration.TICKET_PARAMETER, true, false)); + defaultAuthenticator(new CasAuthenticator(configuration, getName(), callbackUrlResolver, this.serviceUrl)); addAuthorizationGenerator(new DefaultCasAuthorizationGenerator<>()); } diff --git a/pac4j-cas/src/main/java/org/pac4j/cas/client/rest/AbstractCasRestClient.java b/pac4j-cas/src/main/java/org/pac4j/cas/client/rest/AbstractCasRestClient.java index 9a0d98a1f4..de3fb1746f 100644 --- a/pac4j-cas/src/main/java/org/pac4j/cas/client/rest/AbstractCasRestClient.java +++ b/pac4j-cas/src/main/java/org/pac4j/cas/client/rest/AbstractCasRestClient.java @@ -71,7 +71,7 @@ public TokenCredentials requestServiceTicket(final String serviceURL, final CasR if (responseCode == HttpConstants.OK) { try (final BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8))) { - return new TokenCredentials(in.readLine(), getClass().getSimpleName()); + return new TokenCredentials(in.readLine()); } } throw new TechnicalException("Service ticket request for `" + profile + "` failed: " + diff --git a/pac4j-cas/src/main/java/org/pac4j/cas/client/rest/CasRestBasicAuthClient.java b/pac4j-cas/src/main/java/org/pac4j/cas/client/rest/CasRestBasicAuthClient.java index 9a19f1ebdd..5f30e6a8d4 100644 --- a/pac4j-cas/src/main/java/org/pac4j/cas/client/rest/CasRestBasicAuthClient.java +++ b/pac4j-cas/src/main/java/org/pac4j/cas/client/rest/CasRestBasicAuthClient.java @@ -33,7 +33,7 @@ protected void clientInit() { CommonHelper.assertNotNull("prefixHeader", this.prefixHeader); CommonHelper.assertNotNull("configuration", this.configuration); - defaultCredentialsExtractor(new BasicAuthExtractor(this.headerName, this.prefixHeader, getName())); + defaultCredentialsExtractor(new BasicAuthExtractor(this.headerName, this.prefixHeader)); defaultAuthenticator(new CasRestAuthenticator(this.configuration)); } diff --git a/pac4j-cas/src/main/java/org/pac4j/cas/client/rest/CasRestFormClient.java b/pac4j-cas/src/main/java/org/pac4j/cas/client/rest/CasRestFormClient.java index e8fea63e9f..48e5d57d1a 100644 --- a/pac4j-cas/src/main/java/org/pac4j/cas/client/rest/CasRestFormClient.java +++ b/pac4j-cas/src/main/java/org/pac4j/cas/client/rest/CasRestFormClient.java @@ -32,7 +32,7 @@ protected void clientInit() { CommonHelper.assertNotBlank("passwordParameter", this.passwordParameter); CommonHelper.assertNotNull("configuration", this.configuration); - defaultCredentialsExtractor(new FormExtractor(this.usernameParameter, this.passwordParameter, getName())); + defaultCredentialsExtractor(new FormExtractor(this.usernameParameter, this.passwordParameter)); defaultAuthenticator(new CasRestAuthenticator(this.configuration)); } diff --git a/pac4j-cas/src/main/java/org/pac4j/cas/credentials/authenticator/CasAuthenticator.java b/pac4j-cas/src/main/java/org/pac4j/cas/credentials/authenticator/CasAuthenticator.java index a10d6864d5..3085340283 100644 --- a/pac4j-cas/src/main/java/org/pac4j/cas/credentials/authenticator/CasAuthenticator.java +++ b/pac4j-cas/src/main/java/org/pac4j/cas/credentials/authenticator/CasAuthenticator.java @@ -32,12 +32,16 @@ public class CasAuthenticator extends ProfileDefinitionAware impl protected CasConfiguration configuration; + protected String clientName; + protected CallbackUrlResolver callbackUrlResolver; protected String callbackUrl; - public CasAuthenticator(final CasConfiguration configuration, final CallbackUrlResolver callbackUrlResolver, final String callbackUrl) { + public CasAuthenticator(final CasConfiguration configuration, final String clientName, final CallbackUrlResolver callbackUrlResolver, + final String callbackUrl) { this.configuration = configuration; + this.clientName = clientName; this.callbackUrlResolver = callbackUrlResolver; this.callbackUrl = callbackUrl; } @@ -45,6 +49,7 @@ public CasAuthenticator(final CasConfiguration configuration, final CallbackUrlR @Override protected void internalInit() { CommonHelper.assertNotNull("callbackUrlResolver", callbackUrlResolver); + CommonHelper.assertNotBlank("clientName", clientName); CommonHelper.assertNotBlank("callbackUrl", callbackUrl); CommonHelper.assertNotNull("configuration", configuration); @@ -57,7 +62,7 @@ public void validate(final TokenCredentials credentials, final WebContext contex final String ticket = credentials.getToken(); try { - final String finalCallbackUrl = callbackUrlResolver.compute(callbackUrl, credentials.getClientName(), context); + final String finalCallbackUrl = callbackUrlResolver.compute(callbackUrl, clientName, context); final Assertion assertion = configuration.retrieveTicketValidator(context).validate(ticket, finalCallbackUrl); final AttributePrincipal principal = assertion.getPrincipal(); logger.debug("principal: {}", principal); diff --git a/pac4j-cas/src/main/java/org/pac4j/cas/credentials/extractor/TicketAndLogoutRequestExtractor.java b/pac4j-cas/src/main/java/org/pac4j/cas/credentials/extractor/TicketAndLogoutRequestExtractor.java index 73ca867a97..56145d3ec8 100644 --- a/pac4j-cas/src/main/java/org/pac4j/cas/credentials/extractor/TicketAndLogoutRequestExtractor.java +++ b/pac4j-cas/src/main/java/org/pac4j/cas/credentials/extractor/TicketAndLogoutRequestExtractor.java @@ -31,13 +31,9 @@ public class TicketAndLogoutRequestExtractor implements CredentialsExtractor { private final String prefixHeader; - private final String clientName; - - public HeaderExtractor(final String headerName, final String prefixHeader, final String clientName) { + public HeaderExtractor(final String headerName, final String prefixHeader) { this.headerName = headerName; this.prefixHeader = prefixHeader; - this.clientName = clientName; } @Override @@ -36,6 +33,6 @@ public TokenCredentials extract(WebContext context) { } final String headerWithoutPrefix = header.substring(this.prefixHeader.length()); - return new TokenCredentials(headerWithoutPrefix, clientName); + return new TokenCredentials(headerWithoutPrefix); } } diff --git a/pac4j-core/src/main/java/org/pac4j/core/credentials/extractor/ParameterExtractor.java b/pac4j-core/src/main/java/org/pac4j/core/credentials/extractor/ParameterExtractor.java index 0e2d10fdc3..6cbdd40b36 100644 --- a/pac4j-core/src/main/java/org/pac4j/core/credentials/extractor/ParameterExtractor.java +++ b/pac4j-core/src/main/java/org/pac4j/core/credentials/extractor/ParameterExtractor.java @@ -17,22 +17,19 @@ public class ParameterExtractor implements CredentialsExtractor RedirectAction.redirect(computeFinalCallbackUrl(webContext))); - defaultCredentialsExtractor(new BasicAuthExtractor(getName())); + defaultCredentialsExtractor(new BasicAuthExtractor()); } @Override diff --git a/pac4j-http/src/main/java/org/pac4j/http/credentials/DigestCredentials.java b/pac4j-http/src/main/java/org/pac4j/http/credentials/DigestCredentials.java index bd2a264a17..42ad19a878 100644 --- a/pac4j-http/src/main/java/org/pac4j/http/credentials/DigestCredentials.java +++ b/pac4j-http/src/main/java/org/pac4j/http/credentials/DigestCredentials.java @@ -32,7 +32,6 @@ public class DigestCredentials extends TokenCredentials { * * @param token the token * @param httpMethod the HTTP method - * @param clientName the client name * @param username the user name * @param realm the realm * @param nonce nonce @@ -41,10 +40,10 @@ public class DigestCredentials extends TokenCredentials { * @param nc nc * @param qop qop */ - public DigestCredentials(final String token, final String httpMethod, final String clientName, final String username, - final String realm, final String nonce, final String uri, final String cnonce, final String nc, + public DigestCredentials(final String token, final String httpMethod, final String username, final String realm, + final String nonce, final String uri, final String cnonce, final String nc, final String qop) { - super(token, clientName); + super(token); this.username = username; this.realm = realm; @@ -139,7 +138,6 @@ public int hashCode() { @Override public String toString() { - return CommonHelper.toNiceString(this.getClass(), "username", this.username, "response", "[PROTECTED]", - "clientName", getClientName()); + return CommonHelper.toNiceString(this.getClass(), "username", this.username, "response", "[PROTECTED]"); } } diff --git a/pac4j-http/src/main/java/org/pac4j/http/credentials/extractor/CookieExtractor.java b/pac4j-http/src/main/java/org/pac4j/http/credentials/extractor/CookieExtractor.java index aeaf8ade5f..44cb73c44d 100644 --- a/pac4j-http/src/main/java/org/pac4j/http/credentials/extractor/CookieExtractor.java +++ b/pac4j-http/src/main/java/org/pac4j/http/credentials/extractor/CookieExtractor.java @@ -18,11 +18,8 @@ public class CookieExtractor implements CredentialsExtractor { private final String cookieName; - private final String clientName; - - public CookieExtractor(final String cookieName, final String clientName) { + public CookieExtractor(final String cookieName) { this.cookieName = cookieName; - this.clientName = clientName; } @Override @@ -30,7 +27,7 @@ public TokenCredentials extract(final WebContext context) { final Collection col = context.getRequestCookies(); for (final Cookie c : col) { if (c.getName().equals(this.cookieName)) { - return new TokenCredentials(c.getValue(), clientName); + return new TokenCredentials(c.getValue()); } } return null; @@ -38,7 +35,6 @@ public TokenCredentials extract(final WebContext context) { @Override public String toString() { - return CommonHelper.toNiceString(this.getClass(), "cookieName", this.cookieName, - "clientName", this.clientName); + return CommonHelper.toNiceString(this.getClass(), "cookieName", this.cookieName); } } diff --git a/pac4j-http/src/main/java/org/pac4j/http/credentials/extractor/DigestAuthExtractor.java b/pac4j-http/src/main/java/org/pac4j/http/credentials/extractor/DigestAuthExtractor.java index 5e62cef9d1..c01e6046fb 100644 --- a/pac4j-http/src/main/java/org/pac4j/http/credentials/extractor/DigestAuthExtractor.java +++ b/pac4j-http/src/main/java/org/pac4j/http/credentials/extractor/DigestAuthExtractor.java @@ -23,15 +23,12 @@ public class DigestAuthExtractor implements CredentialsExtractor parseTokenValue(String token) { @@ -95,6 +92,6 @@ private Map parseTokenValue(String token) { @Override public String toString() { - return CommonHelper.toNiceString(this.getClass(), "extractor", extractor, "clientName", clientName); + return CommonHelper.toNiceString(this.getClass(), "extractor", extractor); } } diff --git a/pac4j-http/src/main/java/org/pac4j/http/credentials/extractor/IpExtractor.java b/pac4j-http/src/main/java/org/pac4j/http/credentials/extractor/IpExtractor.java index 3652fdd706..b064f5f2ba 100644 --- a/pac4j-http/src/main/java/org/pac4j/http/credentials/extractor/IpExtractor.java +++ b/pac4j-http/src/main/java/org/pac4j/http/credentials/extractor/IpExtractor.java @@ -21,18 +21,13 @@ */ public class IpExtractor implements CredentialsExtractor { - private final String clientName; - private List alternateIpHeaders = Collections.emptyList(); private String proxyIp = ""; - public IpExtractor(final String clientName) { - this.clientName = clientName; - } + public IpExtractor() {} - public IpExtractor(final String clientName, String... alternateIpHeaders) { - this.clientName = clientName; + public IpExtractor(String... alternateIpHeaders) { this.alternateIpHeaders = Arrays.asList(alternateIpHeaders); } @@ -57,7 +52,7 @@ else if (this.proxyIp.equals(requestSourceIp)) { return null; } - return new TokenCredentials(ip, clientName); + return new TokenCredentials(ip); } private String ipFromHeaders(WebContext context) { @@ -108,7 +103,6 @@ public void setAlternateIpHeaders(final String... alternateIpHeaders) { @Override public String toString() { - return CommonHelper.toNiceString(this.getClass(), "clientName", this.clientName, - "alternateIpHeaders", Arrays.asList(this.alternateIpHeaders)); + return CommonHelper.toNiceString(this.getClass(), "alternateIpHeaders", Arrays.asList(this.alternateIpHeaders)); } } diff --git a/pac4j-http/src/test/java/org/pac4j/http/client/direct/CookieClientTests.java b/pac4j-http/src/test/java/org/pac4j/http/client/direct/CookieClientTests.java index f713a8fd22..4860a27c81 100644 --- a/pac4j-http/src/test/java/org/pac4j/http/client/direct/CookieClientTests.java +++ b/pac4j-http/src/test/java/org/pac4j/http/client/direct/CookieClientTests.java @@ -34,7 +34,7 @@ public void testMissingUsernamePasswordAuthenticator() { public void testMissingProfileCreator() { final CookieClient cookieClient = new CookieClient("testcookie", new SimpleTestTokenAuthenticator()); cookieClient.setProfileCreator(null); - TestsHelper.expectException(() -> cookieClient.getUserProfile(new TokenCredentials(TOKEN, CLIENT_NAME), MockWebContext.create()), + TestsHelper.expectException(() -> cookieClient.getUserProfile(new TokenCredentials(TOKEN), MockWebContext.create()), TechnicalException.class, "profileCreator cannot be null"); } diff --git a/pac4j-http/src/test/java/org/pac4j/http/client/direct/DirectBasicAuthClientTests.java b/pac4j-http/src/test/java/org/pac4j/http/client/direct/DirectBasicAuthClientTests.java index c8a6dc89cb..dc244b1b46 100644 --- a/pac4j-http/src/test/java/org/pac4j/http/client/direct/DirectBasicAuthClientTests.java +++ b/pac4j-http/src/test/java/org/pac4j/http/client/direct/DirectBasicAuthClientTests.java @@ -33,7 +33,7 @@ public void testMissingUsernamePasswordAuthenticator() { @Test public void testMissingProfileCreator() { final DirectBasicAuthClient basicAuthClient = new DirectBasicAuthClient(new SimpleTestUsernamePasswordAuthenticator(), null); - TestsHelper.expectException(() -> basicAuthClient.getUserProfile(new UsernamePasswordCredentials(USERNAME, PASSWORD, CLIENT_NAME), + TestsHelper.expectException(() -> basicAuthClient.getUserProfile(new UsernamePasswordCredentials(USERNAME, PASSWORD), MockWebContext.create()), TechnicalException.class, "profileCreator cannot be null"); } diff --git a/pac4j-http/src/test/java/org/pac4j/http/client/direct/DirectDigestAuthClientTests.java b/pac4j-http/src/test/java/org/pac4j/http/client/direct/DirectDigestAuthClientTests.java index 0136a77267..d74fb53afd 100644 --- a/pac4j-http/src/test/java/org/pac4j/http/client/direct/DirectDigestAuthClientTests.java +++ b/pac4j-http/src/test/java/org/pac4j/http/client/direct/DirectDigestAuthClientTests.java @@ -33,7 +33,7 @@ public void testMissingUsernamePasswordAuthenticator() { public void testMissingProfileCreator() { final DirectDigestAuthClient digestAuthClient = new DirectDigestAuthClient(new SimpleTestTokenAuthenticator(), null); TestsHelper.expectException(() -> digestAuthClient.getUserProfile(new DigestCredentials(TOKEN, HTTP_METHOD.POST.name(), - CLIENT_NAME, null, null, null, null, null, null, null), MockWebContext.create()), TechnicalException.class, + null, null, null, null, null, null, null), MockWebContext.create()), TechnicalException.class, "profileCreator cannot be null"); } diff --git a/pac4j-http/src/test/java/org/pac4j/http/client/direct/DirectFormClientTests.java b/pac4j-http/src/test/java/org/pac4j/http/client/direct/DirectFormClientTests.java index d8793364a1..fbd99867b7 100644 --- a/pac4j-http/src/test/java/org/pac4j/http/client/direct/DirectFormClientTests.java +++ b/pac4j-http/src/test/java/org/pac4j/http/client/direct/DirectFormClientTests.java @@ -34,7 +34,7 @@ public void testMissingUsernamePasswordAuthenticator() { @Test public void testMissingProfileCreator() { final DirectFormClient formClient = new DirectFormClient(new SimpleTestUsernamePasswordAuthenticator(), null); - TestsHelper.expectException(() -> formClient.getUserProfile(new UsernamePasswordCredentials(USERNAME, PASSWORD, CLIENT_NAME), + TestsHelper.expectException(() -> formClient.getUserProfile(new UsernamePasswordCredentials(USERNAME, PASSWORD), MockWebContext.create()), TechnicalException.class, "profileCreator cannot be null"); } @@ -92,8 +92,7 @@ public void testGetUserProfile() { return profile; }); final MockWebContext context = MockWebContext.create(); - final CommonProfile profile = formClient.getUserProfile(new UsernamePasswordCredentials(USERNAME, USERNAME, - formClient.getName()), context); + final CommonProfile profile = formClient.getUserProfile(new UsernamePasswordCredentials(USERNAME, USERNAME), context); assertEquals(USERNAME, profile.getId()); assertEquals(CommonProfile.class.getName() + CommonProfile.SEPARATOR + USERNAME, profile.getTypedId()); assertTrue(ProfileHelper.isTypedIdOf(profile.getTypedId(), CommonProfile.class)); diff --git a/pac4j-http/src/test/java/org/pac4j/http/client/direct/HeaderClientTests.java b/pac4j-http/src/test/java/org/pac4j/http/client/direct/HeaderClientTests.java index 316ee17f55..a7a8d31f9b 100644 --- a/pac4j-http/src/test/java/org/pac4j/http/client/direct/HeaderClientTests.java +++ b/pac4j-http/src/test/java/org/pac4j/http/client/direct/HeaderClientTests.java @@ -30,7 +30,7 @@ public void testMissingTokendAuthenticator() { public void testMissingProfileCreator() { final HeaderClient client = new HeaderClient(NAME, new SimpleTestTokenAuthenticator()); client.setProfileCreator(null); - TestsHelper.expectException(() -> client.getUserProfile(new TokenCredentials(TOKEN, CLIENT_NAME), + TestsHelper.expectException(() -> client.getUserProfile(new TokenCredentials(TOKEN), MockWebContext.create()), TechnicalException.class, "profileCreator cannot be null"); } diff --git a/pac4j-http/src/test/java/org/pac4j/http/client/direct/IpClientTests.java b/pac4j-http/src/test/java/org/pac4j/http/client/direct/IpClientTests.java index de6acc30e3..e312a6d08d 100644 --- a/pac4j-http/src/test/java/org/pac4j/http/client/direct/IpClientTests.java +++ b/pac4j-http/src/test/java/org/pac4j/http/client/direct/IpClientTests.java @@ -32,7 +32,7 @@ public void testMissingTokendAuthenticator() { public void testMissingProfileCreator() { final IpClient client = new IpClient(new SimpleTestTokenAuthenticator()); client.setProfileCreator(null); - TestsHelper.expectException(() -> client.getUserProfile(new TokenCredentials(TOKEN, CLIENT_NAME), + TestsHelper.expectException(() -> client.getUserProfile(new TokenCredentials(TOKEN), MockWebContext.create()), TechnicalException.class, "profileCreator cannot be null"); } diff --git a/pac4j-http/src/test/java/org/pac4j/http/client/direct/ParameterClientTests.java b/pac4j-http/src/test/java/org/pac4j/http/client/direct/ParameterClientTests.java index 4e0c046985..d0252ebbdd 100644 --- a/pac4j-http/src/test/java/org/pac4j/http/client/direct/ParameterClientTests.java +++ b/pac4j-http/src/test/java/org/pac4j/http/client/direct/ParameterClientTests.java @@ -34,7 +34,7 @@ public void testMissingTokenAuthenticator() { @Test public void testMissingProfileCreator() { final ParameterClient client = new ParameterClient(PARAMETER_NAME, new SimpleTestTokenAuthenticator(), null); - TestsHelper.expectException(() -> client.getUserProfile(new TokenCredentials(TOKEN, CLIENT_NAME), + TestsHelper.expectException(() -> client.getUserProfile(new TokenCredentials(TOKEN), MockWebContext.create()), TechnicalException.class, "profileCreator cannot be null"); } diff --git a/pac4j-http/src/test/java/org/pac4j/http/client/indirect/FormClientTests.java b/pac4j-http/src/test/java/org/pac4j/http/client/indirect/FormClientTests.java index d4c57ed5fc..b4d553ea53 100644 --- a/pac4j-http/src/test/java/org/pac4j/http/client/indirect/FormClientTests.java +++ b/pac4j-http/src/test/java/org/pac4j/http/client/indirect/FormClientTests.java @@ -37,7 +37,7 @@ public void testMissingProfileCreator() { final FormClient formClient = new FormClient(LOGIN_URL, new SimpleTestUsernamePasswordAuthenticator()); formClient.setCallbackUrl(CALLBACK_URL); formClient.setProfileCreator(null); - TestsHelper.expectException(() -> formClient.getUserProfile(new UsernamePasswordCredentials(USERNAME, PASSWORD, CLIENT_NAME), + TestsHelper.expectException(() -> formClient.getUserProfile(new UsernamePasswordCredentials(USERNAME, PASSWORD), MockWebContext.create()), TechnicalException.class, "profileCreator cannot be null"); } @@ -128,8 +128,7 @@ public void testGetUserProfile() { return profile; }); final MockWebContext context = MockWebContext.create(); - final CommonProfile profile = formClient.getUserProfile(new UsernamePasswordCredentials(USERNAME, USERNAME, - formClient.getName()), context); + final CommonProfile profile = formClient.getUserProfile(new UsernamePasswordCredentials(USERNAME, USERNAME), context); assertEquals(USERNAME, profile.getId()); assertEquals(CommonProfile.class.getName() + CommonProfile.SEPARATOR + USERNAME, profile.getTypedId()); assertTrue(ProfileHelper.isTypedIdOf(profile.getTypedId(), CommonProfile.class)); diff --git a/pac4j-http/src/test/java/org/pac4j/http/client/indirect/IndirectBasicAuthClientTests.java b/pac4j-http/src/test/java/org/pac4j/http/client/indirect/IndirectBasicAuthClientTests.java index 5a76346701..19c2555dd5 100644 --- a/pac4j-http/src/test/java/org/pac4j/http/client/indirect/IndirectBasicAuthClientTests.java +++ b/pac4j-http/src/test/java/org/pac4j/http/client/indirect/IndirectBasicAuthClientTests.java @@ -37,7 +37,7 @@ public void testMissingProfileCreator() { final IndirectBasicAuthClient basicAuthClient = new IndirectBasicAuthClient(NAME, new SimpleTestUsernamePasswordAuthenticator()); basicAuthClient.setCallbackUrl(CALLBACK_URL); basicAuthClient.setProfileCreator(null); - TestsHelper.expectException(() -> basicAuthClient.getUserProfile(new UsernamePasswordCredentials(USERNAME, PASSWORD, CLIENT_NAME), + TestsHelper.expectException(() -> basicAuthClient.getUserProfile(new UsernamePasswordCredentials(USERNAME, PASSWORD), MockWebContext.create()), TechnicalException.class, "profileCreator cannot be null"); } diff --git a/pac4j-http/src/test/java/org/pac4j/http/credentials/authenticator/IpRegexpAuthenticatorTests.java b/pac4j-http/src/test/java/org/pac4j/http/credentials/authenticator/IpRegexpAuthenticatorTests.java index 031f250cfc..9ae32b7b5a 100644 --- a/pac4j-http/src/test/java/org/pac4j/http/credentials/authenticator/IpRegexpAuthenticatorTests.java +++ b/pac4j-http/src/test/java/org/pac4j/http/credentials/authenticator/IpRegexpAuthenticatorTests.java @@ -25,14 +25,14 @@ public final class IpRegexpAuthenticatorTests implements TestsConstants { @Test(expected = TechnicalException.class) public void testNoPattern() { - final TokenCredentials credentials = new TokenCredentials(GOOD_IP, CLIENT_NAME); + final TokenCredentials credentials = new TokenCredentials(GOOD_IP); IpRegexpAuthenticator authenticator = new IpRegexpAuthenticator(); authenticator.validate(credentials, null); } @Test public void testValidateGoodIP() { - final TokenCredentials credentials = new TokenCredentials(GOOD_IP, CLIENT_NAME); + final TokenCredentials credentials = new TokenCredentials(GOOD_IP); authenticator.validate(credentials, null); final IpProfile profile = (IpProfile) credentials.getUserProfile(); assertEquals(GOOD_IP, profile.getId()); @@ -40,7 +40,7 @@ public void testValidateGoodIP() { @Test public void testValidateBadIP() { - final TokenCredentials credentials = new TokenCredentials(BAD_IP, CLIENT_NAME); + final TokenCredentials credentials = new TokenCredentials(BAD_IP); TestsHelper.expectException(() -> authenticator.validate(credentials, null), CredentialsException.class, "Unauthorized IP address: " + BAD_IP); } diff --git a/pac4j-http/src/test/java/org/pac4j/http/credentials/authenticator/RestAuthenticatorIT.java b/pac4j-http/src/test/java/org/pac4j/http/credentials/authenticator/RestAuthenticatorIT.java index 9857956d19..3c78ee832d 100644 --- a/pac4j-http/src/test/java/org/pac4j/http/credentials/authenticator/RestAuthenticatorIT.java +++ b/pac4j-http/src/test/java/org/pac4j/http/credentials/authenticator/RestAuthenticatorIT.java @@ -37,7 +37,7 @@ public static void setUp() { @Test public void testProfileOk() { final RestAuthenticator authenticator = new RestAuthenticator("http://localhost:" + PORT + "?r=ok"); - final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(GOOD_USERNAME, PASSWORD, CLIENT_NAME); + final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(GOOD_USERNAME, PASSWORD); authenticator.validate(credentials, MockWebContext.create()); final RestProfile profile = (RestProfile) credentials.getUserProfile(); assertNotNull(profile); @@ -49,7 +49,7 @@ public void testProfileOk() { @Test public void testNotFound() { final RestAuthenticator authenticator = new RestAuthenticator("http://localhost:" + PORT + "?r=notfound"); - final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(GOOD_USERNAME, PASSWORD, CLIENT_NAME); + final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(GOOD_USERNAME, PASSWORD); authenticator.validate(credentials, MockWebContext.create()); final RestProfile profile = (RestProfile) credentials.getUserProfile(); assertNull(profile); @@ -58,7 +58,7 @@ public void testNotFound() { @Test public void testParsingError() { final RestAuthenticator authenticator = new RestAuthenticator("http://localhost:" + PORT + "?r=pe"); - final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(GOOD_USERNAME, PASSWORD, CLIENT_NAME); + final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(GOOD_USERNAME, PASSWORD); TestsHelper.expectException(() -> authenticator.validate(credentials, MockWebContext.create()), TechnicalException.class, "com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'bad': was expecting ('true', 'false' or 'null')\n" + " at [Source: bad; line: 1, column: 7]"); @@ -67,7 +67,7 @@ public void testParsingError() { @Test public void testHttps() { final RestAuthenticator authenticator = new RestAuthenticator("https://www.google.com"); - final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(GOOD_USERNAME, PASSWORD, CLIENT_NAME); + final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(GOOD_USERNAME, PASSWORD); authenticator.validate(credentials, MockWebContext.create()); } } diff --git a/pac4j-http/src/test/java/org/pac4j/http/credentials/extractor/DigestExtractorTests.java b/pac4j-http/src/test/java/org/pac4j/http/credentials/extractor/DigestExtractorTests.java index f93eeb7519..cadbd3db95 100644 --- a/pac4j-http/src/test/java/org/pac4j/http/credentials/extractor/DigestExtractorTests.java +++ b/pac4j-http/src/test/java/org/pac4j/http/credentials/extractor/DigestExtractorTests.java @@ -16,7 +16,7 @@ */ public class DigestExtractorTests implements TestsConstants { - private final static DigestAuthExtractor digestExtractor = new DigestAuthExtractor(CLIENT_NAME); + private final static DigestAuthExtractor digestExtractor = new DigestAuthExtractor(); @Test public void testRetrieveDigestHeaderComponents() { diff --git a/pac4j-http/src/test/java/org/pac4j/http/credentials/extractor/IpExtractorTests.java b/pac4j-http/src/test/java/org/pac4j/http/credentials/extractor/IpExtractorTests.java index fdfb01ab3b..81f2d1ce53 100644 --- a/pac4j-http/src/test/java/org/pac4j/http/credentials/extractor/IpExtractorTests.java +++ b/pac4j-http/src/test/java/org/pac4j/http/credentials/extractor/IpExtractorTests.java @@ -21,7 +21,7 @@ public final class IpExtractorTests implements TestsConstants { @SuppressWarnings("PMD") private final static String LOCALHOST = "127.0.0.1"; - private static final IpExtractor extractor = new IpExtractor(CLIENT_NAME); + private static final IpExtractor extractor = new IpExtractor(); @Test public void testRetrieveIpOk() { @@ -33,7 +33,7 @@ public void testRetrieveIpOk() { @Test public void testRetrieveIpFromHeaderWithProxyIpCheck() { final MockWebContext context = MockWebContext.create().addRequestHeader(HEADER_NAME, GOOD_IP).setRemoteAddress(LOCALHOST); - final IpExtractor ipExtractor = new IpExtractor(CLIENT_NAME); + final IpExtractor ipExtractor = new IpExtractor(); ipExtractor.setProxyIp(LOCALHOST); // test for varargs ipExtractor.setAlternateIpHeaders("fooBar", HEADER_NAME, "barFoo"); @@ -49,18 +49,18 @@ public void testRetrieveIpFromHeaderWithProxyIpCheck() { public void testRetrieveIpFromHeaderUsingConstructor() { final MockWebContext context = MockWebContext.create().addRequestHeader(HEADER_NAME, GOOD_IP).setRemoteAddress(LOCALHOST); // test for varargs - final IpExtractor ipExtractor = new IpExtractor(CLIENT_NAME, "fooBar", HEADER_NAME, "barFoo"); + final IpExtractor ipExtractor = new IpExtractor("fooBar", HEADER_NAME, "barFoo"); final TokenCredentials credentials = ipExtractor.extract(context); assertEquals(GOOD_IP, credentials.getToken()); // test for edge case of 1 header - final IpExtractor ipExtractor2 = new IpExtractor(CLIENT_NAME, HEADER_NAME); + final IpExtractor ipExtractor2 = new IpExtractor(HEADER_NAME); final TokenCredentials credentials2 = ipExtractor2.extract(context); assertEquals(GOOD_IP, credentials2.getToken()); } @Test(expected = TechnicalException.class) public void testSetNullIpHeaderChain() { - final IpExtractor ipExtractor = new IpExtractor(CLIENT_NAME); + final IpExtractor ipExtractor = new IpExtractor(); ipExtractor.setAlternateIpHeaders(null); } diff --git a/pac4j-http/src/test/java/org/pac4j/http/credentials/extractor/ParameterExtractorTests.java b/pac4j-http/src/test/java/org/pac4j/http/credentials/extractor/ParameterExtractorTests.java index 1a8af1118e..3fdd29d8e5 100644 --- a/pac4j-http/src/test/java/org/pac4j/http/credentials/extractor/ParameterExtractorTests.java +++ b/pac4j-http/src/test/java/org/pac4j/http/credentials/extractor/ParameterExtractorTests.java @@ -21,8 +21,8 @@ public final class ParameterExtractorTests implements TestsConstants { private final static String GOOD_PARAMETER = "goodParameter"; - private final static ParameterExtractor getExtractor = new ParameterExtractor(GOOD_PARAMETER, true, false, CLIENT_NAME); - private final static ParameterExtractor postExtractor = new ParameterExtractor(GOOD_PARAMETER, false, true, CLIENT_NAME); + private final static ParameterExtractor getExtractor = new ParameterExtractor(GOOD_PARAMETER, true, false); + private final static ParameterExtractor postExtractor = new ParameterExtractor(GOOD_PARAMETER, false, true); @Test public void testRetrieveGetParameterOk() { diff --git a/pac4j-jwt/src/main/java/org/pac4j/jwt/credentials/authenticator/JwtAuthenticator.java b/pac4j-jwt/src/main/java/org/pac4j/jwt/credentials/authenticator/JwtAuthenticator.java index 2fc7235122..412fb46935 100644 --- a/pac4j-jwt/src/main/java/org/pac4j/jwt/credentials/authenticator/JwtAuthenticator.java +++ b/pac4j-jwt/src/main/java/org/pac4j/jwt/credentials/authenticator/JwtAuthenticator.java @@ -113,7 +113,7 @@ public Map validateTokenAndGetClaims(final String token) { * @return the corresponding user profile */ public CommonProfile validateToken(final String token) { - final TokenCredentials credentials = new TokenCredentials(token, "(validateToken)Method"); + final TokenCredentials credentials = new TokenCredentials(token); try { validate(credentials, null); } catch (final HttpAction e) { diff --git a/pac4j-jwt/src/test/java/org/pac4j/jwt/JwtTests.java b/pac4j-jwt/src/test/java/org/pac4j/jwt/JwtTests.java index ac42b80800..998d1de218 100644 --- a/pac4j-jwt/src/test/java/org/pac4j/jwt/JwtTests.java +++ b/pac4j-jwt/src/test/java/org/pac4j/jwt/JwtTests.java @@ -48,7 +48,7 @@ public void testGenericJwt() { + "3XWWV24aYyGWR5HVrfm4HLQi1xgmwglLlEIiFlOSTOSZ_LeAwl2Z3VFh-5EidocjwGkAPGQA_4_KCLbK8Im7M25ZZvDzCJ1kKN1JrDIIrBWCcuI4Mbw0O" + "_YGb8TfIECPkpeG7wEgBG30sb1kH-F_vg9yjYfB4MiJCSFmY7cRqN9-9O23tz3wYv3b-eJh5ACr2CGSVNj2KcMsOMJ6bbALgz6pzQTIWk_" + "fhcE9QSfaSY7RuZ8cRTV-UTjYgZk1gbd1LskgchS.ijMQmfPlObJv7oaPG8LCEg"; - final TokenCredentials credentials = new TokenCredentials(token, JwtAuthenticator.class.getName()); + final TokenCredentials credentials = new TokenCredentials(token); final JwtAuthenticator authenticator = new JwtAuthenticator(new SecretSignatureConfiguration(MAC_SECRET), new SecretEncryptionConfiguration(MAC_SECRET)); authenticator.validate(credentials, null); @@ -139,7 +139,7 @@ public void testDoubleGenerateAuthenticate() { final String token = generator.generate(profile); final JwtAuthenticator authenticator = new JwtAuthenticator(new SecretSignatureConfiguration(MAC_SECRET), new SecretEncryptionConfiguration(MAC_SECRET)); - final TokenCredentials credentials = new TokenCredentials(token, CLIENT_NAME); + final TokenCredentials credentials = new TokenCredentials(token); authenticator.validate(credentials, null); final FacebookProfile profile2 = (FacebookProfile) credentials.getUserProfile(); generator.generate(profile2); @@ -270,7 +270,7 @@ private CommonProfile assertToken(FacebookProfile profile, String token) { } private CommonProfile assertToken(FacebookProfile profile, String token, JwtAuthenticator authenticator) { - final TokenCredentials credentials = new TokenCredentials(token, CLIENT_NAME); + final TokenCredentials credentials = new TokenCredentials(token); authenticator.validate(credentials, null); final CommonProfile profile2 = credentials.getUserProfile(); assertTrue(profile2 instanceof FacebookProfile); @@ -295,7 +295,7 @@ private FacebookProfile createProfile() { public void testAuthenticateFailed() { final JwtAuthenticator authenticator = new JwtAuthenticator(new SecretSignatureConfiguration(MAC_SECRET), new SecretEncryptionConfiguration(MAC_SECRET)); - final TokenCredentials credentials = new TokenCredentials("fakeToken", CLIENT_NAME); + final TokenCredentials credentials = new TokenCredentials("fakeToken"); authenticator.validate(credentials, null); } diff --git a/pac4j-kerberos/src/main/java/org/pac4j/kerberos/client/direct/DirectKerberosClient.java b/pac4j-kerberos/src/main/java/org/pac4j/kerberos/client/direct/DirectKerberosClient.java index 6b609db760..a571d6ac56 100644 --- a/pac4j-kerberos/src/main/java/org/pac4j/kerberos/client/direct/DirectKerberosClient.java +++ b/pac4j-kerberos/src/main/java/org/pac4j/kerberos/client/direct/DirectKerberosClient.java @@ -31,6 +31,6 @@ public DirectKerberosClient(final Authenticator authenticator, final ProfileCrea @Override protected void clientInit() { - defaultCredentialsExtractor(new KerberosExtractor(getName())); + defaultCredentialsExtractor(new KerberosExtractor()); } } diff --git a/pac4j-kerberos/src/main/java/org/pac4j/kerberos/client/indirect/IndirectKerberosClient.java b/pac4j-kerberos/src/main/java/org/pac4j/kerberos/client/indirect/IndirectKerberosClient.java index 432dd6513e..2ae0b8bc18 100644 --- a/pac4j-kerberos/src/main/java/org/pac4j/kerberos/client/indirect/IndirectKerberosClient.java +++ b/pac4j-kerberos/src/main/java/org/pac4j/kerberos/client/indirect/IndirectKerberosClient.java @@ -34,7 +34,7 @@ public IndirectKerberosClient(final Authenticator authenticator, final ProfileCr @Override protected void clientInit() { defaultRedirectActionBuilder(webContext -> RedirectAction.redirect(computeFinalCallbackUrl(webContext))); - defaultCredentialsExtractor(new KerberosExtractor(getName())); + defaultCredentialsExtractor(new KerberosExtractor()); } @Override diff --git a/pac4j-kerberos/src/main/java/org/pac4j/kerberos/credentials/KerberosCredentials.java b/pac4j-kerberos/src/main/java/org/pac4j/kerberos/credentials/KerberosCredentials.java index ce1a61128a..5bf4926c93 100644 --- a/pac4j-kerberos/src/main/java/org/pac4j/kerberos/credentials/KerberosCredentials.java +++ b/pac4j-kerberos/src/main/java/org/pac4j/kerberos/credentials/KerberosCredentials.java @@ -18,9 +18,8 @@ public class KerberosCredentials extends Credentials { */ private static final long serialVersionUID = -4264156105410684508L; - public KerberosCredentials(byte[] kerberosTicket, String clientName) { + public KerberosCredentials(byte[] kerberosTicket) { this.kerberosTicket = kerberosTicket.clone(); - this.setClientName(clientName); } public byte[] getKerberosTicket() { @@ -33,7 +32,7 @@ public String getKerberosTicketAsString() { @Override public String toString() { - return CommonHelper.toNiceString(this.getClass(), "token", this.kerberosTicket, "clientName", getClientName()); + return CommonHelper.toNiceString(this.getClass(), "token", this.kerberosTicket); } @Override diff --git a/pac4j-kerberos/src/main/java/org/pac4j/kerberos/credentials/extractor/KerberosExtractor.java b/pac4j-kerberos/src/main/java/org/pac4j/kerberos/credentials/extractor/KerberosExtractor.java index bb38ea1fca..6909535cd1 100644 --- a/pac4j-kerberos/src/main/java/org/pac4j/kerberos/credentials/extractor/KerberosExtractor.java +++ b/pac4j-kerberos/src/main/java/org/pac4j/kerberos/credentials/extractor/KerberosExtractor.java @@ -15,11 +15,6 @@ * @since 2.1.0 */ public class KerberosExtractor implements CredentialsExtractor { - private final String clientName; - - public KerberosExtractor(final String clientName) { - this.clientName = clientName; - } @Override public KerberosCredentials extract(final WebContext context) { @@ -37,6 +32,6 @@ public KerberosCredentials extract(final WebContext context) { byte[] base64Token = header.substring(header.indexOf(" ") + 1).getBytes(StandardCharsets.UTF_8); byte[] kerberosTicket = Base64.getDecoder().decode(base64Token); - return new KerberosCredentials(kerberosTicket, clientName); + return new KerberosCredentials(kerberosTicket); } } diff --git a/pac4j-ldap/src/test/java/org/pac4j/ldap/profile/service/LdapProfileServiceTests.java b/pac4j-ldap/src/test/java/org/pac4j/ldap/profile/service/LdapProfileServiceTests.java index 777f494dd2..a622e68520 100644 --- a/pac4j-ldap/src/test/java/org/pac4j/ldap/profile/service/LdapProfileServiceTests.java +++ b/pac4j-ldap/src/test/java/org/pac4j/ldap/profile/service/LdapProfileServiceTests.java @@ -80,7 +80,7 @@ public void testBlankUsersDn() { @Test(expected = BadCredentialsException.class) public void authentFailed() { final LdapProfileService ldapProfileService = new LdapProfileService(connectionFactory, authenticator, LdapServer.BASE_PEOPLE_DN); - final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(BAD_USERNAME, PASSWORD, CLIENT_NAME); + final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(BAD_USERNAME, PASSWORD); ldapProfileService.validate(credentials, null); } @@ -89,7 +89,7 @@ public void authentSuccessNoAttribute() { final LdapProfileService ldapProfileService = new LdapProfileService(connectionFactory, authenticator, "", LdapServer.BASE_PEOPLE_DN); ldapProfileService.setUsernameAttribute(LdapServer.CN); - final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(GOOD_USERNAME, PASSWORD, CLIENT_NAME); + final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(GOOD_USERNAME, PASSWORD); ldapProfileService.validate(credentials, null); final CommonProfile profile = credentials.getUserProfile(); @@ -105,7 +105,7 @@ public void authentSuccessSingleAttribute() { final LdapProfileService ldapProfileService = new LdapProfileService(connectionFactory, authenticator, LdapServer.SN, LdapServer.BASE_PEOPLE_DN); ldapProfileService.setUsernameAttribute(LdapServer.CN); - final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(GOOD_USERNAME, PASSWORD, CLIENT_NAME); + final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(GOOD_USERNAME, PASSWORD); ldapProfileService.validate(credentials, null); final CommonProfile profile = credentials.getUserProfile(); @@ -122,7 +122,7 @@ public void authentSuccessMultiAttribute() { final LdapProfileService ldapProfileService = new LdapProfileService(connectionFactory, authenticator, LdapServer.SN + "," + LdapServer.ROLE, LdapServer.BASE_PEOPLE_DN); ldapProfileService.setUsernameAttribute(LdapServer.CN); - final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(GOOD_USERNAME2, PASSWORD, CLIENT_NAME); + final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(GOOD_USERNAME2, PASSWORD); ldapProfileService.validate(credentials, null); final CommonProfile profile = credentials.getUserProfile(); @@ -151,7 +151,7 @@ public void testCreateUpdateFindDelete() { // create ldapProfileService.create(profile, LDAP_PASS); // check credentials - final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(LDAP_ID, LDAP_PASS, CLIENT_NAME); + final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(LDAP_ID, LDAP_PASS); ldapProfileService.validate(credentials, null); final CommonProfile profile1 = credentials.getUserProfile(); assertNotNull(profile1); @@ -182,7 +182,7 @@ public void testCreateUpdateFindDelete() { assertNotNull(result2.get(AbstractProfileService.SERIALIZED_PROFILE)); assertEquals(LDAP_USER2, result2.get(LdapServer.SN)); // check credentials - final UsernamePasswordCredentials credentials2 = new UsernamePasswordCredentials(LDAP_ID, LDAP_PASS2, CLIENT_NAME); + final UsernamePasswordCredentials credentials2 = new UsernamePasswordCredentials(LDAP_ID, LDAP_PASS2); ldapProfileService.validate(credentials2, null); final CommonProfile profile3 = credentials.getUserProfile(); assertNotNull(profile3); diff --git a/pac4j-mongo/src/test/java/org/pac4j/mongo/profile/service/MongoProfileServiceIT.java b/pac4j-mongo/src/test/java/org/pac4j/mongo/profile/service/MongoProfileServiceIT.java index 1ea1dde02b..ffc4f3bc3a 100644 --- a/pac4j-mongo/src/test/java/org/pac4j/mongo/profile/service/MongoProfileServiceIT.java +++ b/pac4j-mongo/src/test/java/org/pac4j/mongo/profile/service/MongoProfileServiceIT.java @@ -84,7 +84,7 @@ public void testNullUsername() { public void testNullPassword() { final MongoProfileService authenticator = new MongoProfileService(getClient(), FIRSTNAME, MongoServer.PASSWORD_ENCODER); authenticator.setPasswordAttribute(null); - final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(GOOD_USERNAME, PASSWORD, CLIENT_NAME); + final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(GOOD_USERNAME, PASSWORD); TestsHelper.expectException(() -> authenticator.validate(credentials, null), TechnicalException.class, "passwordAttribute cannot be blank"); } @@ -96,7 +96,7 @@ private MongoClient getClient() { private UsernamePasswordCredentials login(final String username, final String password, final String attribute) { final MongoProfileService authenticator = new MongoProfileService(getClient(), attribute); authenticator.setPasswordEncoder(MongoServer.PASSWORD_ENCODER); - final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(username, password, CLIENT_NAME); + final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(username, password); authenticator.validate(credentials, null); return credentials; @@ -157,7 +157,7 @@ public void testCreateUpdateFindDelete() { // create mongoProfileService.create(profile, MONGO_PASS); // check credentials - final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(MONGO_USER, MONGO_PASS, CLIENT_NAME); + final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(MONGO_USER, MONGO_PASS); mongoProfileService.validate(credentials, null); final CommonProfile profile1 = credentials.getUserProfile(); assertNotNull(profile1); diff --git a/pac4j-oauth/src/main/java/org/pac4j/oauth/credentials/OAuth10Credentials.java b/pac4j-oauth/src/main/java/org/pac4j/oauth/credentials/OAuth10Credentials.java index f014d0994a..eed39bf4aa 100644 --- a/pac4j-oauth/src/main/java/org/pac4j/oauth/credentials/OAuth10Credentials.java +++ b/pac4j-oauth/src/main/java/org/pac4j/oauth/credentials/OAuth10Credentials.java @@ -20,8 +20,7 @@ public class OAuth10Credentials extends OAuthCredentials { private OAuth1AccessToken accessToken; - public OAuth10Credentials(OAuth1RequestToken requestToken, String token, String verifier, String clientName) { - super(clientName); + public OAuth10Credentials(OAuth1RequestToken requestToken, String token, String verifier) { this.requestToken = requestToken; this.token = token; this.verifier = verifier; @@ -74,7 +73,6 @@ public String toString() { "requestToken", requestToken, "token", token, "verifier'", verifier, - "clientName", getClientName(), "accessToken", accessToken); } } diff --git a/pac4j-oauth/src/main/java/org/pac4j/oauth/credentials/OAuth20Credentials.java b/pac4j-oauth/src/main/java/org/pac4j/oauth/credentials/OAuth20Credentials.java index 11cfd0310b..251e2fbce7 100644 --- a/pac4j-oauth/src/main/java/org/pac4j/oauth/credentials/OAuth20Credentials.java +++ b/pac4j-oauth/src/main/java/org/pac4j/oauth/credentials/OAuth20Credentials.java @@ -19,10 +19,8 @@ public class OAuth20Credentials extends OAuthCredentials { * For OAuth2 Authorization Code Flow. * * @param code the authorization code - * @param clientName the client name. */ - public OAuth20Credentials(String code, String clientName) { - super(clientName); + public OAuth20Credentials(String code) { this.code = code; } @@ -58,7 +56,6 @@ public void setAccessToken(final OAuth2AccessToken accessToken) { public String toString() { return CommonHelper.toNiceString(this.getClass(), "code", code, - "accessToken", accessToken, - "clientName", getClientName()); + "accessToken", accessToken); } } diff --git a/pac4j-oauth/src/main/java/org/pac4j/oauth/credentials/OAuthCredentials.java b/pac4j-oauth/src/main/java/org/pac4j/oauth/credentials/OAuthCredentials.java index 24c97e89fd..72ad1bef3c 100644 --- a/pac4j-oauth/src/main/java/org/pac4j/oauth/credentials/OAuthCredentials.java +++ b/pac4j-oauth/src/main/java/org/pac4j/oauth/credentials/OAuthCredentials.java @@ -1,7 +1,6 @@ package org.pac4j.oauth.credentials; import org.pac4j.core.credentials.Credentials; -import org.pac4j.core.util.CommonHelper; /** * This class represents an OAuth credentials for OAuth 1.0 and 2.0: a request token, a token and a verifier. @@ -13,16 +12,7 @@ public abstract class OAuthCredentials extends Credentials { private static final long serialVersionUID = -7705033802712382951L; - public OAuthCredentials(final String clientName) { - setClientName(clientName); - } - public abstract boolean equals(Object o); public abstract int hashCode(); - - @Override - public String toString() { - return CommonHelper.toNiceString(this.getClass(), "clientName", getClientName()); - } } diff --git a/pac4j-oauth/src/main/java/org/pac4j/oauth/credentials/extractor/OAuth10CredentialsExtractor.java b/pac4j-oauth/src/main/java/org/pac4j/oauth/credentials/extractor/OAuth10CredentialsExtractor.java index 702a40379e..dcdb90b5bc 100644 --- a/pac4j-oauth/src/main/java/org/pac4j/oauth/credentials/extractor/OAuth10CredentialsExtractor.java +++ b/pac4j-oauth/src/main/java/org/pac4j/oauth/credentials/extractor/OAuth10CredentialsExtractor.java @@ -32,7 +32,7 @@ protected OAuth10Credentials getOAuthCredentials(final WebContext context) { final String token = OAuthEncoder.decode(tokenParameter); final String verifier = OAuthEncoder.decode(verifierParameter); logger.debug("token: {} / verifier: {}", token, verifier); - return new OAuth10Credentials(tokenSession, token, verifier, client.getName()); + return new OAuth10Credentials(tokenSession, token, verifier); } else { final String message = "No credential found"; throw new OAuthCredentialsException(message); diff --git a/pac4j-oauth/src/main/java/org/pac4j/oauth/credentials/extractor/OAuth20CredentialsExtractor.java b/pac4j-oauth/src/main/java/org/pac4j/oauth/credentials/extractor/OAuth20CredentialsExtractor.java index a80ed0d488..eef6b11728 100644 --- a/pac4j-oauth/src/main/java/org/pac4j/oauth/credentials/extractor/OAuth20CredentialsExtractor.java +++ b/pac4j-oauth/src/main/java/org/pac4j/oauth/credentials/extractor/OAuth20CredentialsExtractor.java @@ -47,7 +47,7 @@ protected OAuth20Credentials getOAuthCredentials(final WebContext context) { if (codeParameter != null) { final String code = OAuthEncoder.decode(codeParameter); logger.debug("code: {}", code); - return new OAuth20Credentials(code, this.client.getName()); + return new OAuth20Credentials(code); } else { final String message = "No credential found"; throw new OAuthCredentialsException(message); diff --git a/pac4j-oauth/src/test/java/org/pac4j/oauth/credentials/OAuthCredentialsTests.java b/pac4j-oauth/src/test/java/org/pac4j/oauth/credentials/OAuthCredentialsTests.java index 5f678eb880..3c017e4d1b 100644 --- a/pac4j-oauth/src/test/java/org/pac4j/oauth/credentials/OAuthCredentialsTests.java +++ b/pac4j-oauth/src/test/java/org/pac4j/oauth/credentials/OAuthCredentialsTests.java @@ -19,10 +19,9 @@ public final class OAuthCredentialsTests implements TestsConstants { @Test public void testOAuth10Credentials() { - final OAuth10Credentials credentials = new OAuth10Credentials(REQUEST_TOKEN, TOKEN, VERIFIER, TYPE); + final OAuth10Credentials credentials = new OAuth10Credentials(REQUEST_TOKEN, TOKEN, VERIFIER); assertEquals(TOKEN, credentials.getToken()); assertEquals(VERIFIER, credentials.getVerifier()); - assertEquals(TYPE, credentials.getClientName()); final OAuth1RequestToken requestToken = credentials.getRequestToken(); assertEquals(TOKEN, requestToken.getToken()); assertEquals(SECRET, requestToken.getTokenSecret()); @@ -33,6 +32,5 @@ public void testOAuth10Credentials() { assertEquals(credentials.getRequestToken().toString(), credentials2.getRequestToken().toString()); assertEquals(credentials.getToken(), credentials2.getToken()); assertEquals(credentials.getVerifier(), credentials2.getVerifier()); - assertEquals(credentials.getClientName(), credentials2.getClientName()); } } diff --git a/pac4j-oidc/src/main/java/org/pac4j/oidc/credentials/OidcCredentials.java b/pac4j-oidc/src/main/java/org/pac4j/oidc/credentials/OidcCredentials.java index 972f30c5a5..4dd1e93e69 100644 --- a/pac4j-oidc/src/main/java/org/pac4j/oidc/credentials/OidcCredentials.java +++ b/pac4j-oidc/src/main/java/org/pac4j/oidc/credentials/OidcCredentials.java @@ -24,10 +24,6 @@ public class OidcCredentials extends Credentials { private RefreshToken refreshToken; private JWT idToken; - public OidcCredentials(final String clientName) { - this.setClientName(clientName); - } - public AuthorizationCode getCode() { return code; } @@ -76,7 +72,7 @@ public int hashCode() { @Override public String toString() { - return CommonHelper.toNiceString(this.getClass(), "code", this.code, "clientName", getClientName(), "accessToken", accessToken, + return CommonHelper.toNiceString(this.getClass(), "code", this.code, "accessToken", accessToken, "refreshToken", refreshToken, "idToken", idToken); } } diff --git a/pac4j-oidc/src/main/java/org/pac4j/oidc/credentials/extractor/OidcExtractor.java b/pac4j-oidc/src/main/java/org/pac4j/oidc/credentials/extractor/OidcExtractor.java index d61b0bbd7e..8a78e19436 100644 --- a/pac4j-oidc/src/main/java/org/pac4j/oidc/credentials/extractor/OidcExtractor.java +++ b/pac4j-oidc/src/main/java/org/pac4j/oidc/credentials/extractor/OidcExtractor.java @@ -71,7 +71,7 @@ public OidcCredentials extract(final WebContext context) { + "Session expired or possible threat of cross-site request forgery"); } - final OidcCredentials credentials = new OidcCredentials(client.getName()); + final OidcCredentials credentials = new OidcCredentials(); // get authorization code final AuthorizationCode code = successResponse.getAuthorizationCode(); if (code != null) { diff --git a/pac4j-oidc/src/test/java/org/pac4j/oidc/credentials/OidcCredentialsTests.java b/pac4j-oidc/src/test/java/org/pac4j/oidc/credentials/OidcCredentialsTests.java index 071e0aabce..59ebe02c4a 100644 --- a/pac4j-oidc/src/test/java/org/pac4j/oidc/credentials/OidcCredentialsTests.java +++ b/pac4j-oidc/src/test/java/org/pac4j/oidc/credentials/OidcCredentialsTests.java @@ -27,7 +27,7 @@ public final class OidcCredentialsTests implements TestsConstants { @Test public void testSerialization() throws ParseException { - final OidcCredentials credentials = new OidcCredentials(CLIENT_NAME); + final OidcCredentials credentials = new OidcCredentials(); credentials.setCode(new AuthorizationCode(VALUE)); credentials.setAccessToken(new BearerAccessToken(VALUE, 0L, Scope.parse("oidc email"))); credentials.setRefreshToken(new RefreshToken(VALUE)); diff --git a/pac4j-openid/src/main/java/org/pac4j/openid/credentials/OpenIdCredentials.java b/pac4j-openid/src/main/java/org/pac4j/openid/credentials/OpenIdCredentials.java index ae9efc1c41..765123295e 100644 --- a/pac4j-openid/src/main/java/org/pac4j/openid/credentials/OpenIdCredentials.java +++ b/pac4j-openid/src/main/java/org/pac4j/openid/credentials/OpenIdCredentials.java @@ -20,12 +20,9 @@ public class OpenIdCredentials extends Credentials { private DiscoveryInformation discoveryInformation; - public OpenIdCredentials(final DiscoveryInformation discoveryInformation, final ParameterList parameterList, - final String clientName) { + public OpenIdCredentials(final DiscoveryInformation discoveryInformation, final ParameterList parameterList) { this.discoveryInformation = discoveryInformation; this.parameterList = parameterList; - setClientName(clientName); - } public DiscoveryInformation getDiscoveryInformation() { @@ -60,6 +57,6 @@ public int hashCode() { @Override public String toString() { return CommonHelper.toNiceString(this.getClass(), "discoveryInformation", this.discoveryInformation, - "parameterList", this.parameterList, "clientName", getClientName()); + "parameterList", this.parameterList); } } diff --git a/pac4j-openid/src/main/java/org/pac4j/openid/credentials/extractor/YahooCredentialsExtractor.java b/pac4j-openid/src/main/java/org/pac4j/openid/credentials/extractor/YahooCredentialsExtractor.java index 6ff2b7bbdc..d0d42302b0 100644 --- a/pac4j-openid/src/main/java/org/pac4j/openid/credentials/extractor/YahooCredentialsExtractor.java +++ b/pac4j-openid/src/main/java/org/pac4j/openid/credentials/extractor/YahooCredentialsExtractor.java @@ -48,7 +48,7 @@ public OpenIdCredentials extract(final WebContext context) { .getSessionStore().get(context, this.client.getDiscoveryInformationSessionAttributeName()); // create credentials - final OpenIdCredentials credentials = new OpenIdCredentials(discoveryInformation, parameterList, this.client.getName()); + final OpenIdCredentials credentials = new OpenIdCredentials(discoveryInformation, parameterList); logger.debug("credentials: {}", credentials); return credentials; } diff --git a/pac4j-saml/src/main/java/org/pac4j/saml/client/SAML2Client.java b/pac4j-saml/src/main/java/org/pac4j/saml/client/SAML2Client.java index 2f46ecd70b..693f530d27 100644 --- a/pac4j-saml/src/main/java/org/pac4j/saml/client/SAML2Client.java +++ b/pac4j-saml/src/main/java/org/pac4j/saml/client/SAML2Client.java @@ -108,8 +108,6 @@ protected void clientInit() { defaultCredentialsExtractor(ctx -> { final SAML2MessageContext samlContext = this.contextProvider.buildContext(ctx); final SAML2Credentials credentials = (SAML2Credentials) this.profileHandler.receive(samlContext); - // The profile handler sets a hard-coded client name, we need the real one. - credentials.setClientName(getName()); return credentials; }); defaultAuthenticator(new SAML2Authenticator()); diff --git a/pac4j-saml/src/main/java/org/pac4j/saml/credentials/SAML2Credentials.java b/pac4j-saml/src/main/java/org/pac4j/saml/credentials/SAML2Credentials.java index b4a242c6d6..dc18cddb9b 100644 --- a/pac4j-saml/src/main/java/org/pac4j/saml/credentials/SAML2Credentials.java +++ b/pac4j-saml/src/main/java/org/pac4j/saml/credentials/SAML2Credentials.java @@ -9,7 +9,7 @@ /** * Credentials containing the nameId of the SAML subject and all of its attributes. - * + * * @author Michael Remond * @since 1.5.0 */ @@ -22,28 +22,27 @@ public class SAML2Credentials extends Credentials { private String sessionIndex; private List attributes; - + private Conditions conditions; - + private String issuerId; - + private List authnContexts; public SAML2Credentials(final NameID nameId, final String issuerId, final List attributes, final Conditions conditions, - final String clientName, final String sessionIndex, final List authnContexts) { + final String sessionIndex, final List authnContexts) { this.nameId = nameId; this.issuerId = issuerId; this.sessionIndex = sessionIndex; this.attributes = attributes; this.conditions = conditions; this.authnContexts = authnContexts; - setClientName(clientName); } public final NameID getNameId() { return this.nameId; } - + public final String getSessionIndex() { return this.sessionIndex; } @@ -51,7 +50,7 @@ public final String getSessionIndex() { public final List getAttributes() { return this.attributes; } - + public Conditions getConditions() { return this.conditions; } diff --git a/pac4j-saml/src/main/java/org/pac4j/saml/sso/impl/SAML2DefaultResponseValidator.java b/pac4j-saml/src/main/java/org/pac4j/saml/sso/impl/SAML2DefaultResponseValidator.java index cececc9bfc..fc4bacc853 100644 --- a/pac4j-saml/src/main/java/org/pac4j/saml/sso/impl/SAML2DefaultResponseValidator.java +++ b/pac4j-saml/src/main/java/org/pac4j/saml/sso/impl/SAML2DefaultResponseValidator.java @@ -46,7 +46,6 @@ import org.opensaml.xmlsec.signature.support.SignatureException; import org.opensaml.xmlsec.signature.support.SignatureTrustEngine; import org.pac4j.core.credentials.Credentials; -import org.pac4j.saml.client.SAML2Client; import org.pac4j.saml.context.SAML2MessageContext; import org.pac4j.saml.credentials.SAML2Credentials; import org.pac4j.saml.crypto.SAML2SignatureTrustEngineProvider; @@ -68,7 +67,7 @@ * Class responsible for executing every required checks for validating a SAML response. * The method validate populates the given {@link SAML2MessageContext} * with the correct SAML assertion and the corresponding nameID's Bearer subject if every checks succeeds. - * + * * @author Michael Remond * @since 1.5.0 * @@ -77,9 +76,9 @@ public class SAML2DefaultResponseValidator implements SAML2ResponseValidator { private final static Logger logger = LoggerFactory.getLogger(SAML2DefaultResponseValidator.class); - /** + /** * The default maximum authentication lifetime, in seconds. Used for {@link #maximumAuthenticationLifetime} if a meaningless (<=0) - * value is passed to the constructor. + * value is passed to the constructor. */ private static final int DEFAULT_MAXIMUM_AUTHENTICATION_LIFETIME = 3600; @@ -111,7 +110,7 @@ public SAML2DefaultResponseValidator(final SAML2SignatureTrustEngineProvider eng final URIComparator uriComparator) { this.signatureTrustEngineProvider = engine; this.decrypter = decrypter; - this.maximumAuthenticationLifetime = (maximumAuthenticationLifetime > 0 ? + this.maximumAuthenticationLifetime = (maximumAuthenticationLifetime > 0 ? maximumAuthenticationLifetime : DEFAULT_MAXIMUM_AUTHENTICATION_LIFETIME); this.uriComparator = uriComparator; this.wantsAssertionsSigned = wantsAssertionsSigned; @@ -149,14 +148,14 @@ protected final SAML2Credentials buildSAML2Credentials(final SAML2MessageContext final Assertion subjectAssertion = context.getSubjectAssertion(); final String sessionIndex = getSessionIndex(subjectAssertion); - + final String issuerEntityId = subjectAssertion.getIssuer().getValue(); List authnStatements = subjectAssertion.getAuthnStatements(); List authnContexts = new ArrayList(); for(AuthnStatement authnStatement : authnStatements) { authnContexts.add(authnStatement.getAuthnContext().getAuthnContextClassRef().getAuthnContextClassRef()); } - + final List attributes = new ArrayList(); for (final AttributeStatement attributeStatement : subjectAssertion.getAttributeStatements()) { @@ -177,13 +176,12 @@ protected final SAML2Credentials buildSAML2Credentials(final SAML2MessageContext } } } - return new SAML2Credentials(nameId, issuerEntityId, attributes, subjectAssertion.getConditions(), - SAML2Client.class.getSimpleName(), sessionIndex, authnContexts); + return new SAML2Credentials(nameId, issuerEntityId, attributes, subjectAssertion.getConditions(), sessionIndex, authnContexts); } /** * Searches the sessionIndex in the assertion - * + * * @param subjectAssertion assertion from the response * @return the sessionIndex if found in the assertion */ @@ -235,7 +233,7 @@ protected final void validateSamlProtocolResponse(final Response response, final if (messageStorage != null && response.getInResponseTo() != null) { final XMLObject xmlObject = messageStorage.retrieveMessage(response.getInResponseTo()); if (xmlObject == null) { - throw new SAMLException("InResponseToField of the Response doesn't correspond to sent message " + throw new SAMLException("InResponseToField of the Response doesn't correspond to sent message " + response.getInResponseTo()); } else if (xmlObject instanceof AuthnRequest) { request = (AuthnRequest) xmlObject; @@ -410,10 +408,10 @@ protected final void validateAssertion(final Assertion assertion, final SAML2Mes /** * Validate the given subject by finding a valid Bearer confirmation. If the subject is valid, put its nameID in the context. - * + * * NameID / BaseID / EncryptedID is first looked up directly in the Subject. If not present there, then all relevant * SubjectConfirmations are parsed and the IDs are taken from them. - * + * * @param subject * The Subject from an assertion. * @param context @@ -448,7 +446,7 @@ protected final void validateSubject(final Subject subject, final SAML2MessageCo } for (final SubjectConfirmation confirmation : subject.getSubjectConfirmations()) { - if (SubjectConfirmation.METHOD_BEARER.equals(confirmation.getMethod()) && + if (SubjectConfirmation.METHOD_BEARER.equals(confirmation.getMethod()) && isValidBearerSubjectConfirmationData(confirmation.getSubjectConfirmationData(), context)) { NameID nameIDFromConfirmation = confirmation.getNameID(); final BaseID baseIDFromConfirmation = confirmation.getBaseID(); @@ -480,12 +478,12 @@ protected final void validateSubject(final Subject subject, final SAML2MessageCo /** * Decrypts an EncryptedID, using a decrypter. - * + * * @param encryptedId The EncryptedID to be decrypted. * @param decrypter The decrypter to use. - * + * * @return Decrypted ID or {@code null} if any input is {@code null}. - * + * * @throws SAMLException If the input ID cannot be decrypted. */ protected final NameID decryptEncryptedId(final EncryptedID encryptedId, final Decrypter decrypter) throws SAMLException { @@ -549,11 +547,11 @@ protected final boolean isValidBearerSubjectConfirmationData(final SubjectConfir logger.warn("No endpoint was found in the SAML endpoint context"); return false; } - + final URI recipientUri = new URI(data.getRecipient()); final URI appEndpointUri = new URI(endpoint.getLocation()); if (!UriUtils.urisEqualAfterPortNormalization(recipientUri, appEndpointUri)) { - logger.debug("SubjectConfirmationData recipient {} does not match SP assertion consumer URL, found. " + logger.debug("SubjectConfirmationData recipient {} does not match SP assertion consumer URL, found. " + "SP ACS URL from context: {}", recipientUri, appEndpointUri); return false; } @@ -562,7 +560,7 @@ protected final boolean isValidBearerSubjectConfirmationData(final SubjectConfir logger.error("Unable to check SubjectConfirmationData recipient, a URI has invalid syntax.", use); return false; } - + return true; } @@ -710,8 +708,8 @@ private boolean isDateValid(final DateTime issueInstant, final int interval) { final DateTime after = DateTime.now().minusSeconds(acceptedSkew + interval); boolean isDateValid = issueInstant.isBefore(before) && issueInstant.isAfter(after); if (!isDateValid) { - logger.trace("interval={},before={},after={},issueInstant={}", interval, before.toDateTime(issueInstant.getZone()), - after.toDateTime(issueInstant.getZone()), issueInstant); + logger.trace("interval={},before={},after={},issueInstant={}", interval, before.toDateTime(issueInstant.getZone()), + after.toDateTime(issueInstant.getZone()), issueInstant); } return isDateValid; } diff --git a/pac4j-sql/src/test/java/org/pac4j/sql/profile/service/DbProfileServiceTests.java b/pac4j-sql/src/test/java/org/pac4j/sql/profile/service/DbProfileServiceTests.java index 8561804fd8..02601a81e1 100644 --- a/pac4j-sql/src/test/java/org/pac4j/sql/profile/service/DbProfileServiceTests.java +++ b/pac4j-sql/src/test/java/org/pac4j/sql/profile/service/DbProfileServiceTests.java @@ -53,7 +53,7 @@ private UsernamePasswordCredentials login(final String username, final String pa final DbProfileService dbProfileService = new DbProfileService(ds, attribute); dbProfileService.setPasswordEncoder(DbServer.PASSWORD_ENCODER); - final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(username, password, CLIENT_NAME); + final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(username, password); dbProfileService.validate(credentials, null); return credentials; @@ -112,7 +112,7 @@ public void testCreateUpdateFindDelete() { // create dbProfileService.create(profile, DB_PASS); // check credentials - final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(DB_USER, DB_PASS, CLIENT_NAME); + final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(DB_USER, DB_PASS); dbProfileService.validate(credentials, null); final CommonProfile profile1 = credentials.getUserProfile(); assertNotNull(profile1);