List of usage examples for org.springframework.security.oauth2.provider OAuth2Request getRedirectUri
public String getRedirectUri()
From source file:org.mitre.oauth2.model.AuthenticationHolderEntity.java
public void setAuthentication(OAuth2Authentication authentication) { // pull apart the request and save its bits OAuth2Request o2Request = authentication.getOAuth2Request(); setAuthorities(o2Request.getAuthorities()); setClientId(o2Request.getClientId()); setExtensions(o2Request.getExtensions()); setRedirectUri(o2Request.getRedirectUri()); setRequestParameters(o2Request.getRequestParameters()); setResourceIds(o2Request.getResourceIds()); setResponseTypes(o2Request.getResponseTypes()); setScope(o2Request.getScope()); setApproved(o2Request.isApproved()); if (authentication.getUserAuthentication() != null) { this.userAuth = new SavedUserAuthentication(authentication.getUserAuthentication()); } else {//from ww w. j a v a 2 s.c o m this.userAuth = null; } }
From source file:org.orcid.core.oauth.service.OrcidTokenStoreServiceImpl.java
private OrcidOauth2TokenDetail populatePropertiesFromTokenAndAuthentication(OAuth2AccessToken token, OAuth2Authentication authentication, OrcidOauth2TokenDetail detail) { OAuth2Request authorizationRequest = authentication.getOAuth2Request(); if (detail == null) { detail = new OrcidOauth2TokenDetail(); }/*w w w .j a va2s.c om*/ String clientId = authorizationRequest.getClientId(); String authKey = KEY_GENERATOR.extractKey(authentication); detail.setAuthenticationKey(authKey); detail.setClientDetailsId(clientId); OAuth2RefreshToken refreshToken = token.getRefreshToken(); if (refreshToken != null && StringUtils.isNotBlank(refreshToken.getValue())) { if (refreshToken instanceof ExpiringOAuth2RefreshToken) { // Override the refresh token expiration from the client // details, and make it the same as the token itself detail.setRefreshTokenExpiration(token.getExpiration()); } detail.setRefreshTokenValue(refreshToken.getValue()); } if (!authentication.isClientOnly()) { Object principal = authentication.getPrincipal(); if (principal instanceof ProfileEntity) { ProfileEntity profileEntity = (ProfileEntity) authentication.getPrincipal(); profileEntity = profileEntityCacheManager.retrieve(profileEntity.getId()); detail.setProfile(profileEntity); } } detail.setTokenValue(token.getValue()); detail.setTokenType(token.getTokenType()); detail.setTokenExpiration(token.getExpiration()); detail.setApproved(authorizationRequest.isApproved()); detail.setRedirectUri(authorizationRequest.getRedirectUri()); Set<String> resourceIds = authorizationRequest.getResourceIds(); if (resourceIds == null || resourceIds.isEmpty()) { ClientDetailsEntity clientDetails = clientDetailsEntityCacheManager.retrieve(clientId); resourceIds = clientDetails.getResourceIds(); } detail.setResourceId(OAuth2Utils.formatParameterList(resourceIds)); detail.setResponseType(OAuth2Utils.formatParameterList(authorizationRequest.getResponseTypes())); detail.setScope(OAuth2Utils.formatParameterList(authorizationRequest.getScope())); Map<String, Object> additionalInfo = token.getAdditionalInformation(); if (additionalInfo != null) { if (additionalInfo.containsKey(OrcidOauth2Constants.TOKEN_VERSION)) { String sVersion = String.valueOf(additionalInfo.get(OrcidOauth2Constants.TOKEN_VERSION)); detail.setVersion(Long.valueOf(sVersion)); } else { // TODO: As of Jan 2015 all tokens will be new tokens, so, we // will have to remove the token version code and // treat all tokens as new tokens detail.setVersion(Long.valueOf(OrcidOauth2Constants.PERSISTENT_TOKEN)); } if (additionalInfo.containsKey(OrcidOauth2Constants.PERSISTENT)) { boolean isPersistentKey = (Boolean) additionalInfo.get(OrcidOauth2Constants.PERSISTENT); detail.setPersistent(isPersistentKey); } else { detail.setPersistent(false); } } else { detail.setPersistent(false); } return detail; }