Search in sources :

Example 1 with InvalidApplicationClientException

use of org.wso2.carbon.identity.oauth.endpoint.exception.InvalidApplicationClientException in project identity-inbound-auth-oauth by wso2-extensions.

the class OAuth2TokenEndpoint method issueAccessToken.

protected Response issueAccessToken(HttpServletRequest request, Map<String, List<String>> paramMap) throws OAuthSystemException, InvalidRequestParentException {
    try {
        startSuperTenantFlow();
        validateRepeatedParams(request, paramMap);
        HttpServletRequestWrapper httpRequest = new OAuthRequestWrapper(request, paramMap);
        CarbonOAuthTokenRequest oauthRequest = buildCarbonOAuthTokenRequest(httpRequest);
        validateOAuthApplication(oauthRequest.getoAuthClientAuthnContext());
        OAuth2AccessTokenRespDTO oauth2AccessTokenResp = issueAccessToken(oauthRequest, httpRequest);
        if (oauth2AccessTokenResp.getErrorMsg() != null) {
            return handleErrorResponse(oauth2AccessTokenResp);
        } else {
            return buildTokenResponse(oauth2AccessTokenResp);
        }
    } catch (TokenEndpointBadRequestException | OAuthSystemException | InvalidApplicationClientException e) {
        triggerOnTokenExceptionListeners(e, request, paramMap);
        throw e;
    } finally {
        PrivilegedCarbonContext.endTenantFlow();
    }
}
Also used : OAuthRequestWrapper(org.wso2.carbon.identity.oauth.endpoint.OAuthRequestWrapper) OAuth2AccessTokenRespDTO(org.wso2.carbon.identity.oauth2.dto.OAuth2AccessTokenRespDTO) TokenEndpointBadRequestException(org.wso2.carbon.identity.oauth.endpoint.exception.TokenEndpointBadRequestException) HttpServletRequestWrapper(javax.servlet.http.HttpServletRequestWrapper) OAuthSystemException(org.apache.oltu.oauth2.common.exception.OAuthSystemException) InvalidApplicationClientException(org.wso2.carbon.identity.oauth.endpoint.exception.InvalidApplicationClientException) CarbonOAuthTokenRequest(org.wso2.carbon.identity.oauth2.model.CarbonOAuthTokenRequest)

Aggregations

HttpServletRequestWrapper (javax.servlet.http.HttpServletRequestWrapper)1 OAuthSystemException (org.apache.oltu.oauth2.common.exception.OAuthSystemException)1 OAuthRequestWrapper (org.wso2.carbon.identity.oauth.endpoint.OAuthRequestWrapper)1 InvalidApplicationClientException (org.wso2.carbon.identity.oauth.endpoint.exception.InvalidApplicationClientException)1 TokenEndpointBadRequestException (org.wso2.carbon.identity.oauth.endpoint.exception.TokenEndpointBadRequestException)1 OAuth2AccessTokenRespDTO (org.wso2.carbon.identity.oauth2.dto.OAuth2AccessTokenRespDTO)1 CarbonOAuthTokenRequest (org.wso2.carbon.identity.oauth2.model.CarbonOAuthTokenRequest)1