public OAuth2AccessToken grant(String grantType, TokenRequest tokenRequest) { if (!this.grantType.equals(grantType)) { return null; } String clientId = tokenRequest.getClientId(); ClientDetails client = clientDetailsService.loadClientByClientId(clientId); validateGrantType(grantType, client); if (logger.isDebugEnabled()) { logger.debug("Getting access token for: " + clientId); } return getAccessToken(client, tokenRequest); }
public ImplicitTokenRequest(TokenRequest tokenRequest, OAuth2Request oauth2Request) { super(tokenRequest.getRequestParameters(), tokenRequest.getClientId(), tokenRequest.getScope(), tokenRequest.getGrantType()); this.oauth2Request = oauth2Request; }
@Override public OAuth2AccessToken grant(String grantType, TokenRequest tokenRequest) { TokenRequest adjusted = new TokenRequest(tokenRequest.getRequestParameters(), tokenRequest.getClientId(), tokenRequest.getScope(), tokenRequest.getGrantType()); return super.grant(grantType, adjusted); }
String clientId = tokenRequest.getClientId(); if (clientId != null && !clientId.equals(pendingClientId)) {
Map<String, String> requestParams = request.getRequestParameters(); String requestedTokenFormat = requestParams.get(REQUEST_TOKEN_FORMAT); String requestedClientId = request.getClientId();
if (!clientId.equals(tokenRequest.getClientId())) {
if (clientId == null || !clientId.equals(tokenRequest.getClientId())) { throw new InvalidGrantException("Wrong client for this refresh token: " + refreshTokenValue);
ClientDetailsEntity requestingClient = clientDetailsService.loadClientByClientId(authRequest.getClientId()); if (!client.getClientId().equals(requestingClient.getClientId())) { tokenRepository.removeRefreshToken(refreshToken);
public OAuth2AccessToken grant(String grantType, TokenRequest tokenRequest) { if (!this.grantType.equals(grantType)) { return null; } String clientId = tokenRequest.getClientId(); ClientDetails client = clientDetailsService.loadClientByClientId(clientId); validateGrantType(grantType, client); if (logger.isDebugEnabled()) { logger.debug("Getting access token for: " + clientId); } return getAccessToken(client, tokenRequest); }
public ImplicitTokenRequest(TokenRequest tokenRequest, OAuth2Request oauth2Request) { super(tokenRequest.getRequestParameters(), tokenRequest.getClientId(), tokenRequest.getScope(), tokenRequest.getGrantType()); this.oauth2Request = oauth2Request; }
ClientDetailsEntity clientDetails = clientDetailsEntityCacheManager.retrieve(tokenRequest.getClientId()); orcidOAuth2RequestValidator.validateClientIsEnabled(clientDetails);
throw new IllegalArgumentException("access_token does not exist or is disabled"); if (!detail.getClientDetailsId().equals(tokenRequest.getClientId())) { throw new IllegalArgumentException("Clients can only exchange their own access_tokens for id_tokens"); String idTok = openIDConnectTokenEnhancer.buildIdToken(existing,detail.getProfile().getId(), tokenRequest.getClientId(),tokenRequest.getRequestParameters().get(OrcidOauth2Constants.NONCE) ); return new DefaultOAuth2AccessToken(IETFTokenExchangeResponse.idToken(idTok)); } catch (JOSEException e) {
public OAuth2Request validateCredentials(String grantType, TokenRequest tokenRequest) { String clientId = tokenRequest.getClientId(); String scopesString = tokenRequest.getRequestParameters().get(OrcidOauth2Constants.SCOPE_PARAM); Set<String> scopes = new HashSet<String>(); if(!PojoUtil.isEmpty(scopesString)) { scopes = OAuth2Utils.parseParameterList(scopesString); } ClientDetailsEntity clientDetails = clientDetailsEntityCacheManager.retrieve(clientId); orcidOAuth2RequestValidator.validateClientIsEnabled(clientDetails); validateGrantType(grantType, clientDetails); if (scopes != null) { validateScope(clientDetails, scopes); } Map<String, String> authorizationParams = new HashMap<String, String>(); authorizationParams.putAll(tokenRequest.getRequestParameters()); authorizationParams.put(OrcidOauth2Constants.GRANT_TYPE, grantType); authorizationParams.put(OAuth2Utils.SCOPE, StringUtils.join(scopes, ' ')); authorizationParams.put(OAuth2Utils.CLIENT_ID, clientId); AuthorizationRequest authorizationRequest = oAuth2RequestFactory.createAuthorizationRequest(authorizationParams); authorizationRequest.setAuthorities(clientDetails.getAuthorities()); authorizationRequest.setResourceIds(clientDetails.getResourceIds()); authorizationRequest.setApproved(true); return oAuth2RequestFactory.createOAuth2Request(authorizationRequest); }
String clientId = tokenRequest.getClientId(); if (clientId != null && !clientId.equals(pendingClientId)) {
tokenRequest.getClientId(), tokenRequest.getScope() }); ClientDetailsEntity clientDetails = clientDetailsEntityCacheManager.retrieve(tokenRequest.getClientId()); orcidOAuth2RequestValidator.validateClientIsEnabled(clientDetails); if(codeDetails == null) { if (Features.REVOKE_TOKEN_ON_CODE_REUSE.isActive()){ int numDisabled = orcidOauthTokenDetailService.disableAccessTokenByCodeAndClient(authorizationCode, tokenRequest.getClientId(), RevokeReason.AUTH_CODE_REUSED); if (numDisabled >0){ throw new InvalidGrantException("Reused authorization code: " + authorizationCode);
if (!clientId.equals(tokenRequest.getClientId())) {
public OAuth2AccessToken refreshAccessToken(String refreshTokenValue, TokenRequest tokenRequest) throws AuthenticationException { String parentTokenValue = tokenRequest.getRequestParameters().get(OrcidOauth2Constants.AUTHORIZATION); String clientId = tokenRequest.getClientId(); String scopes = tokenRequest.getRequestParameters().get(OAuth2Utils.SCOPE); Long expiresIn = tokenRequest.getRequestParameters().containsKey(OrcidOauth2Constants.EXPIRES_IN)
if (clientId == null || !clientId.equals(tokenRequest.getClientId())) { throw new InvalidGrantException("Wrong client for this refresh token: " + refreshTokenValue);
if (clientId == null || !clientId.equals(tokenRequest.getClientId())) { throw new InvalidGrantException("Wrong client for this refresh token: " + refreshTokenValue);
if (clientId == null || !clientId.equals(tokenRequest.getClientId())) { throw new InvalidGrantException("Wrong client for this refresh token: " + refreshTokenValue);