/*
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2014-2015 ForgeRock AS.
*/
/**
* Handles access token requests from OAuth2 clients to the OAuth2 provider to grant access tokens for the requested
* grant types.
*
* @since 12.0.0
*/
/**
* Constructs a new AccessTokenServiceImpl.
* @param grantTypeHandlers A {@code Map} of the grant type handlers.
* @param clientAuthenticator An instance of the ClientAuthenticator.
* @param tokenStore An instance of the TokenStore.
* @param providerSettingsFactory An instance of the OAuth2ProviderSettingsFactory.
* @param urisFactory An instance of the OAuth2UrisFactory.
*/
this.grantTypeHandlers = grantTypeHandlers;
this.tokenStore = tokenStore;
this.urisFactory = urisFactory;
}
/**
* {@inheritDoc}
*/
NotFoundException, AuthorizationPendingException, ExpiredTokenException, AuthorizationDeclinedException, BadRequestException {
if (grantTypeHandler == null) {
}
}
/**
* {@inheritDoc}
*/
public AccessToken refreshToken(OAuth2Request request) throws InvalidClientException, InvalidRequestException,
Reject.ifTrue(isEmpty(request.<String>getParameter(REFRESH_TOKEN)), "Missing parameter, 'refresh_token'");
uris.getTokenEndpoint());
if (refreshToken == null) {
throw new InvalidRequestException("RefreshToken does not exist");
}
logger.error("Refresh Token was issued to a different client id: " + clientRegistration.getClientId());
throw new InvalidRequestException("Token was issued to a different client");
}
if (refreshToken.isExpired()) {
throw new InvalidGrantException("grant is invalid");
}
} else {
}
request);
}
final AccessToken accessToken = tokenStore.createAccessToken(grantType, OAuth2Constants.Bearer.BEARER, null,
if (newRefreshToken != null) {
}
}
return accessToken;
}
}