Search in sources :

Example 6 with AuthResponseBean

use of org.wso2.carbon.apimgt.rest.api.authenticator.utils.bean.AuthResponseBean in project carbon-apimgt by wso2.

the class AuthenticatorService method getResponseBeanFromTokenInfo.

/**
 * This method sets access token data.
 *
 * @param accessTokenInfo Information of the access token
 * @return AuthResponseBean - An object with access token data
 * @throws KeyManagementException When parsing JWT fails
 */
public AuthResponseBean getResponseBeanFromTokenInfo(AccessTokenInfo accessTokenInfo) throws KeyManagementException {
    String authUser = null;
    if (accessTokenInfo.getIdToken() != null) {
        authUser = getUsernameFromJWT(accessTokenInfo.getIdToken());
    }
    if (authUser == null) {
        authUser = AuthenticatorConstants.ADMIN_USER;
    }
    AuthResponseBean responseBean = new AuthResponseBean();
    responseBean.setTokenValid(true);
    responseBean.setAuthUser(authUser);
    responseBean.setScopes(accessTokenInfo.getScopes());
    responseBean.setType(AuthenticatorConstants.BEARER_PREFIX);
    responseBean.setValidityPeriod(accessTokenInfo.getValidityPeriod());
    responseBean.setIdToken(accessTokenInfo.getIdToken());
    return responseBean;
}
Also used : AuthResponseBean(org.wso2.carbon.apimgt.rest.api.authenticator.utils.bean.AuthResponseBean)

Aggregations

AuthResponseBean (org.wso2.carbon.apimgt.rest.api.authenticator.utils.bean.AuthResponseBean)6 HashMap (java.util.HashMap)3 NewCookie (javax.ws.rs.core.NewCookie)3 Test (org.junit.Test)3 KeyManager (org.wso2.carbon.apimgt.core.api.KeyManager)3 APIMConfigurationService (org.wso2.carbon.apimgt.core.configuration.APIMConfigurationService)3 EnvironmentConfigurations (org.wso2.carbon.apimgt.core.configuration.models.EnvironmentConfigurations)3 SystemApplicationDao (org.wso2.carbon.apimgt.core.dao.SystemApplicationDao)3 AccessTokenInfo (org.wso2.carbon.apimgt.core.models.AccessTokenInfo)3 APIMAppConfigurationService (org.wso2.carbon.apimgt.rest.api.authenticator.configuration.APIMAppConfigurationService)3 URI (java.net.URI)2 OPTIONS (javax.ws.rs.OPTIONS)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)2 APIMAppConfigurations (org.wso2.carbon.apimgt.rest.api.authenticator.configuration.models.APIMAppConfigurations)2 ErrorDTO (org.wso2.carbon.apimgt.rest.api.authenticator.dto.ErrorDTO)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 URISyntaxException (java.net.URISyntaxException)1 Consumes (javax.ws.rs.Consumes)1