Search in sources :

Example 26 with OauthTokenIssuer

use of org.wso2.carbon.identity.oauth2.token.OauthTokenIssuer in project identity-inbound-auth-oauth by wso2-extensions.

the class AbstractAuthorizationGrantHandler method createNewTokenBean.

private AccessTokenDO createNewTokenBean(OAuthTokenReqMessageContext tokReqMsgCtx, OAuthAppDO oAuthAppBean, AccessTokenDO existingTokenBean, Timestamp timestamp, long validityPeriodInMillis, OauthTokenIssuer oauthTokenIssuer) throws IdentityOAuth2Exception {
    String tenantDomain = tokReqMsgCtx.getOauth2AccessTokenReqDTO().getTenantDomain();
    OAuth2AccessTokenReqDTO tokenReq = tokReqMsgCtx.getOauth2AccessTokenReqDTO();
    validateGrantTypeParam(tokenReq);
    AccessTokenDO newTokenBean = new AccessTokenDO();
    newTokenBean.setTokenState(TOKEN_STATE_ACTIVE);
    newTokenBean.setConsumerKey(tokenReq.getClientId());
    newTokenBean.setAuthzUser(tokReqMsgCtx.getAuthorizedUser());
    newTokenBean.setScope(tokReqMsgCtx.getScope());
    newTokenBean.setTenantID(OAuth2Util.getTenantId(tenantDomain));
    newTokenBean.setTokenId(UUID.randomUUID().toString());
    newTokenBean.setGrantType(tokenReq.getGrantType());
    newTokenBean.setTokenType(getTokenType());
    newTokenBean.setIssuedTime(timestamp);
    newTokenBean.setAccessToken(getNewAccessToken(tokReqMsgCtx, oauthTokenIssuer));
    newTokenBean.setValidityPeriodInMillis(validityPeriodInMillis);
    newTokenBean.setValidityPeriod(validityPeriodInMillis / SECONDS_TO_MILISECONDS_FACTOR);
    newTokenBean.setTokenBinding(tokReqMsgCtx.getTokenBinding());
    setRefreshTokenDetails(tokReqMsgCtx, oAuthAppBean, existingTokenBean, timestamp, validityPeriodInMillis, tokenReq, newTokenBean, oauthTokenIssuer);
    return newTokenBean;
}
Also used : AccessTokenDO(org.wso2.carbon.identity.oauth2.model.AccessTokenDO) OAuth2AccessTokenReqDTO(org.wso2.carbon.identity.oauth2.dto.OAuth2AccessTokenReqDTO)

Aggregations

OauthTokenIssuer (org.wso2.carbon.identity.oauth2.token.OauthTokenIssuer)18 AccessTokenDO (org.wso2.carbon.identity.oauth2.model.AccessTokenDO)15 IdentityOAuth2Exception (org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception)14 InvalidOAuthClientException (org.wso2.carbon.identity.oauth.common.exception.InvalidOAuthClientException)9 HashMap (java.util.HashMap)7 OAuthSystemException (org.apache.oltu.oauth2.common.exception.OAuthSystemException)7 OAuth2AuthorizeReqDTO (org.wso2.carbon.identity.oauth2.dto.OAuth2AuthorizeReqDTO)6 Timestamp (java.sql.Timestamp)5 Date (java.util.Date)5 UserIdNotFoundException (org.wso2.carbon.identity.application.authentication.framework.exception.UserIdNotFoundException)5 OAuthAppDO (org.wso2.carbon.identity.oauth.dao.OAuthAppDO)5 OAuthCacheKey (org.wso2.carbon.identity.oauth.cache.OAuthCacheKey)4 OauthTokenIssuerImpl (org.wso2.carbon.identity.oauth2.token.OauthTokenIssuerImpl)4 JWTTokenIssuer (org.wso2.carbon.identity.oauth2.token.JWTTokenIssuer)3 SQLException (java.sql.SQLException)2 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 Test (org.testng.annotations.Test)2 TokenIssuerDO (org.wso2.carbon.identity.oauth2.model.TokenIssuerDO)2 OAuthTokenReqMessageContext (org.wso2.carbon.identity.oauth2.token.OAuthTokenReqMessageContext)2