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;
}
Aggregations