diff --git a/openid-connect-client/src/main/java/org/mitre/openid/connect/client/OIDCAuthenticationFilter.java b/openid-connect-client/src/main/java/org/mitre/openid/connect/client/OIDCAuthenticationFilter.java index e6353b744..ff36fbb44 100644 --- a/openid-connect-client/src/main/java/org/mitre/openid/connect/client/OIDCAuthenticationFilter.java +++ b/openid-connect-client/src/main/java/org/mitre/openid/connect/client/OIDCAuthenticationFilter.java @@ -152,6 +152,11 @@ public class OIDCAuthenticationFilter extends AbstractAuthenticationProcessingFi IssuerServiceResponse issResp = issuerService.getIssuer(request); + if (issResp == null) { + logger.error("Null issuer response returned from service."); + throw new AuthenticationServiceException("No issuer found."); + } + if (issResp.shouldRedirect()) { response.sendRedirect(issResp.getRedirectUrl()); } else { @@ -171,7 +176,7 @@ public class OIDCAuthenticationFilter extends AbstractAuthenticationProcessingFi } - ClientDetails clientConfig = clients.getClientConfiguration(issuer); + ClientDetails clientConfig = clients.getClientConfiguration(serverConfig); if (clientConfig == null) { logger.error("No client configuration found for issuer: " + issuer); throw new AuthenticationServiceException("No client configuration found for issuer: " + issuer); @@ -222,7 +227,7 @@ public class OIDCAuthenticationFilter extends AbstractAuthenticationProcessingFi // pull the configurations based on that issuer ServerConfiguration serverConfig = servers.getServerConfiguration(issuer); - ClientDetails clientConfig = clients.getClientConfiguration(issuer); + ClientDetails clientConfig = clients.getClientConfiguration(serverConfig); MultiValueMap form = new LinkedMultiValueMap(); form.add("grant_type", "authorization_code"); diff --git a/openid-connect-client/src/main/java/org/mitre/openid/connect/client/service/ClientConfigurationService.java b/openid-connect-client/src/main/java/org/mitre/openid/connect/client/service/ClientConfigurationService.java index cd4404eac..2c4f3471b 100644 --- a/openid-connect-client/src/main/java/org/mitre/openid/connect/client/service/ClientConfigurationService.java +++ b/openid-connect-client/src/main/java/org/mitre/openid/connect/client/service/ClientConfigurationService.java @@ -3,6 +3,7 @@ */ package org.mitre.openid.connect.client.service; +import org.mitre.openid.connect.config.ServerConfiguration; import org.springframework.security.oauth2.provider.ClientDetails; /** @@ -11,6 +12,6 @@ import org.springframework.security.oauth2.provider.ClientDetails; */ public interface ClientConfigurationService { - public ClientDetails getClientConfiguration(String issuer); + public ClientDetails getClientConfiguration(ServerConfiguration issuer); } diff --git a/openid-connect-client/src/main/java/org/mitre/openid/connect/client/service/impl/StaticClientConfigurationService.java b/openid-connect-client/src/main/java/org/mitre/openid/connect/client/service/impl/StaticClientConfigurationService.java index e765f27b0..0dd20c968 100644 --- a/openid-connect-client/src/main/java/org/mitre/openid/connect/client/service/impl/StaticClientConfigurationService.java +++ b/openid-connect-client/src/main/java/org/mitre/openid/connect/client/service/impl/StaticClientConfigurationService.java @@ -6,6 +6,7 @@ package org.mitre.openid.connect.client.service.impl; import java.util.Map; import org.mitre.openid.connect.client.service.ClientConfigurationService; +import org.mitre.openid.connect.config.ServerConfiguration; import org.springframework.beans.factory.InitializingBean; import org.springframework.security.oauth2.provider.ClientDetails; @@ -42,9 +43,9 @@ public class StaticClientConfigurationService implements ClientConfigurationServ * @see org.mitre.openid.connect.client.service.ClientConfigurationService#getClientConfiguration(java.lang.String) */ @Override - public ClientDetails getClientConfiguration(String issuer) { + public ClientDetails getClientConfiguration(ServerConfiguration issuer) { - return clients.get(issuer); + return clients.get(issuer.getIssuer()); } /* (non-Javadoc) diff --git a/openid-connect-common/src/main/java/org/mitre/openid/connect/config/ServerConfiguration.java b/openid-connect-common/src/main/java/org/mitre/openid/connect/config/ServerConfiguration.java index 0ad8f0e4b..bba050730 100644 --- a/openid-connect-common/src/main/java/org/mitre/openid/connect/config/ServerConfiguration.java +++ b/openid-connect-common/src/main/java/org/mitre/openid/connect/config/ServerConfiguration.java @@ -29,6 +29,8 @@ public class ServerConfiguration { private String authorizationEndpointUri; private String tokenEndpointUri; + + private String registrationEndpointUri; private String issuer; @@ -105,5 +107,96 @@ public class ServerConfiguration { public void setUserInfoUri(String userInfoUri) { this.userInfoUri = userInfoUri; } + + /** + * @return the registrationEndpointUri + */ + public String getRegistrationEndpointUri() { + return registrationEndpointUri; + } + + /** + * @param registrationEndpointUri the registrationEndpointUri to set + */ + public void setRegistrationEndpointUri(String registrationEndpointUri) { + this.registrationEndpointUri = registrationEndpointUri; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((authorizationEndpointUri == null) ? 0 : authorizationEndpointUri.hashCode()); + result = prime * result + ((issuer == null) ? 0 : issuer.hashCode()); + result = prime * result + ((jwksUri == null) ? 0 : jwksUri.hashCode()); + result = prime * result + ((registrationEndpointUri == null) ? 0 : registrationEndpointUri.hashCode()); + result = prime * result + ((tokenEndpointUri == null) ? 0 : tokenEndpointUri.hashCode()); + result = prime * result + ((userInfoUri == null) ? 0 : userInfoUri.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + ServerConfiguration other = (ServerConfiguration) obj; + if (authorizationEndpointUri == null) { + if (other.authorizationEndpointUri != null) { + return false; + } + } else if (!authorizationEndpointUri.equals(other.authorizationEndpointUri)) { + return false; + } + if (issuer == null) { + if (other.issuer != null) { + return false; + } + } else if (!issuer.equals(other.issuer)) { + return false; + } + if (jwksUri == null) { + if (other.jwksUri != null) { + return false; + } + } else if (!jwksUri.equals(other.jwksUri)) { + return false; + } + if (registrationEndpointUri == null) { + if (other.registrationEndpointUri != null) { + return false; + } + } else if (!registrationEndpointUri.equals(other.registrationEndpointUri)) { + return false; + } + if (tokenEndpointUri == null) { + if (other.tokenEndpointUri != null) { + return false; + } + } else if (!tokenEndpointUri.equals(other.tokenEndpointUri)) { + return false; + } + if (userInfoUri == null) { + if (other.userInfoUri != null) { + return false; + } + } else if (!userInfoUri.equals(other.userInfoUri)) { + return false; + } + return true; + } + } \ No newline at end of file