removed dependency on commons.lang
parent
c46095b6a3
commit
78457b70fc
|
@ -16,18 +16,21 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package org.mitre.openid.connect.client;
|
package org.mitre.openid.connect.client;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
import java.io.IOException;
|
||||||
import com.google.gson.JsonElement;
|
import java.math.BigInteger;
|
||||||
import com.google.gson.JsonObject;
|
import java.net.URI;
|
||||||
import com.google.gson.JsonParser;
|
import java.security.SecureRandom;
|
||||||
import com.nimbusds.jose.util.Base64;
|
import java.text.ParseException;
|
||||||
import com.nimbusds.jwt.ReadOnlyJWTClaimsSet;
|
import java.util.Date;
|
||||||
import com.nimbusds.jwt.SignedJWT;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import javax.servlet.ServletException;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
import org.apache.http.impl.client.DefaultHttpClient;
|
import org.apache.http.impl.client.DefaultHttpClient;
|
||||||
import org.mitre.jwt.signer.service.JwtSigningAndValidationService;
|
import org.mitre.jwt.signer.service.JwtSigningAndValidationService;
|
||||||
import org.mitre.jwt.signer.service.impl.JWKSetSigningAndValidationServiceCacheService;
|
import org.mitre.jwt.signer.service.impl.JWKSetSigningAndValidationServiceCacheService;
|
||||||
import org.mitre.oauth2.model.ClientDetailsEntity;
|
|
||||||
import org.mitre.oauth2.model.RegisteredClient;
|
import org.mitre.oauth2.model.RegisteredClient;
|
||||||
import org.mitre.openid.connect.client.model.IssuerServiceResponse;
|
import org.mitre.openid.connect.client.model.IssuerServiceResponse;
|
||||||
import org.mitre.openid.connect.client.service.AuthRequestUrlBuilder;
|
import org.mitre.openid.connect.client.service.AuthRequestUrlBuilder;
|
||||||
|
@ -42,23 +45,19 @@ import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
||||||
import org.springframework.security.authentication.AuthenticationServiceException;
|
import org.springframework.security.authentication.AuthenticationServiceException;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.AuthenticationException;
|
import org.springframework.security.core.AuthenticationException;
|
||||||
import org.springframework.security.oauth2.provider.ClientDetails;
|
|
||||||
import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter;
|
import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter;
|
||||||
import org.springframework.util.LinkedMultiValueMap;
|
import org.springframework.util.LinkedMultiValueMap;
|
||||||
import org.springframework.util.MultiValueMap;
|
import org.springframework.util.MultiValueMap;
|
||||||
import org.springframework.web.client.HttpClientErrorException;
|
import org.springframework.web.client.HttpClientErrorException;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import com.google.common.base.Strings;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import com.google.gson.JsonElement;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import com.google.gson.JsonObject;
|
||||||
import javax.servlet.http.HttpSession;
|
import com.google.gson.JsonParser;
|
||||||
import java.io.IOException;
|
import com.nimbusds.jose.util.Base64;
|
||||||
import java.math.BigInteger;
|
import com.nimbusds.jwt.ReadOnlyJWTClaimsSet;
|
||||||
import java.net.URI;
|
import com.nimbusds.jwt.SignedJWT;
|
||||||
import java.security.SecureRandom;
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import static org.mitre.oauth2.model.ClientDetailsEntity.AuthMethod.SECRET_BASIC;
|
import static org.mitre.oauth2.model.ClientDetailsEntity.AuthMethod.SECRET_BASIC;
|
||||||
|
|
||||||
|
@ -224,7 +223,7 @@ public class OIDCAuthenticationFilter extends AbstractAuthenticationProcessingFi
|
||||||
|
|
||||||
// check for state, if it doesn't match we bail early
|
// check for state, if it doesn't match we bail early
|
||||||
String storedState = getStoredState(session);
|
String storedState = getStoredState(session);
|
||||||
if (!StringUtils.isBlank(storedState)) {
|
if (!Strings.isNullOrEmpty(storedState)) {
|
||||||
String state = request.getParameter("state");
|
String state = request.getParameter("state");
|
||||||
if (!storedState.equals(state)) {
|
if (!storedState.equals(state)) {
|
||||||
throw new AuthenticationServiceException("State parameter mismatch on return. Expected " + storedState + " got " + state);
|
throw new AuthenticationServiceException("State parameter mismatch on return. Expected " + storedState + " got " + state);
|
||||||
|
@ -403,9 +402,9 @@ public class OIDCAuthenticationFilter extends AbstractAuthenticationProcessingFi
|
||||||
}
|
}
|
||||||
|
|
||||||
// compare the nonce to our stored claim
|
// compare the nonce to our stored claim
|
||||||
// FIXME: Nimbus claims as strings?
|
// TODO: Nimbus claims as strings?
|
||||||
String nonce = (String) idClaims.getCustomClaim("nonce");
|
String nonce = (String) idClaims.getCustomClaim("nonce");
|
||||||
if (StringUtils.isBlank(nonce)) {
|
if (Strings.isNullOrEmpty(nonce)) {
|
||||||
|
|
||||||
logger.error("ID token did not contain a nonce claim.");
|
logger.error("ID token did not contain a nonce claim.");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue