diff --git a/orcid-api-common/src/main/java/org/orcid/api/common/jaxb/OrcidExceptionMapper.java b/orcid-api-common/src/main/java/org/orcid/api/common/jaxb/OrcidExceptionMapper.java index 418eceda83f..8819b3422f5 100644 --- a/orcid-api-common/src/main/java/org/orcid/api/common/jaxb/OrcidExceptionMapper.java +++ b/orcid-api-common/src/main/java/org/orcid/api/common/jaxb/OrcidExceptionMapper.java @@ -130,6 +130,8 @@ public Response toResponse(Throwable t) { logShortError(t, clientId); } else if (t instanceof InvalidPutCodeException) { logShortError(t, clientId); + } else if (t instanceof MismatchedPutCodeException) { + logShortError(t, clientId); } else { LOGGER.error("An exception has occured processing request from client " + clientId, t); } diff --git a/orcid-api-common/src/main/java/org/orcid/api/common/oauth/OrcidClientCredentialEndPointDelegatorImpl.java b/orcid-api-common/src/main/java/org/orcid/api/common/oauth/OrcidClientCredentialEndPointDelegatorImpl.java index 6d15fb7a930..db1c8e7ea83 100644 --- a/orcid-api-common/src/main/java/org/orcid/api/common/oauth/OrcidClientCredentialEndPointDelegatorImpl.java +++ b/orcid-api-common/src/main/java/org/orcid/api/common/oauth/OrcidClientCredentialEndPointDelegatorImpl.java @@ -162,8 +162,11 @@ public Response obtainOauth2Token(String authorization, MultivaluedMap additionalInformation = new HashMap(); @@ -47,6 +49,9 @@ public static IETFTokenExchangeResponse accessToken(OAuth2AccessToken accessTok if (accessToken.getAdditionalInformation().containsKey("name")) { token.additionalInformation.put("name",accessToken.getAdditionalInformation().get("name")); } + if(accessToken.getAdditionalInformation().containsKey(TOKEN_DISABLED)) { + token.additionalInformation.put(TOKEN_DISABLED, "true"); + } return token; } diff --git a/orcid-core/src/main/java/org/orcid/core/oauth/service/OrcidRandomValueTokenServicesImpl.java b/orcid-core/src/main/java/org/orcid/core/oauth/service/OrcidRandomValueTokenServicesImpl.java index 2f32a62ab3f..f9ec2d50b48 100644 --- a/orcid-core/src/main/java/org/orcid/core/oauth/service/OrcidRandomValueTokenServicesImpl.java +++ b/orcid-core/src/main/java/org/orcid/core/oauth/service/OrcidRandomValueTokenServicesImpl.java @@ -1,12 +1,6 @@ package org.orcid.core.oauth.service; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.UUID; +import java.util.*; import javax.annotation.Resource; import javax.persistence.PersistenceException; @@ -465,6 +459,10 @@ public OAuth2AccessToken createRevokedAccessToken(OAuth2Authentication authentic // create the regular token DefaultOAuth2AccessToken accessToken = generateAccessToken(authentication); try { + if(accessToken.getAdditionalInformation() == null) { + accessToken.setAdditionalInformation(Collections.emptyMap()); + } + accessToken.getAdditionalInformation().put(OrcidOauth2Constants.TOKEN_DISABLED, true); orcidTokenStore.storeRevokedAccessToken(accessToken, authentication, revokeReason); } catch (PersistenceException e) { // In the unlikely case that there is a constraint violation, lets