Search in sources :

Example 1 with ClaimName

use of com.wso2telco.core.userprofile.util.ClaimName in project core-util by WSO2Telco.

the class UserClaimProsser method getUserClaimsByUserName.

public Map<ClaimName, String> getUserClaimsByUserName(String userName) {
    try {
        APIManagerConfiguration config = HostObjectComponent.getAPIManagerConfiguration();
        String remoteUserStoreManagerServiceEndpoint = config.getFirstProperty(APIConstants.AUTH_MANAGER_URL) + AdminServicePath.REMOTE_USER_STORE_MANAGER_SERVICE.getTObject();
        String adminUsername = config.getFirstProperty(APIConstants.AUTH_MANAGER_USERNAME);
        String adminPassword = config.getFirstProperty(APIConstants.AUTH_MANAGER_PASSWORD);
        RemoteUserStoreManagerServiceStub userStoreManagerStub = new RemoteUserStoreManagerServiceStub(remoteUserStoreManagerServiceEndpoint);
        CarbonUtils.setBasicAccessSecurityHeaders(adminUsername, adminPassword, userStoreManagerStub._getServiceClient());
        ClaimUtil claimUtil = new ClaimUtil();
        Claim[] claims = claimUtil.convertToClaims(userStoreManagerStub.getUserClaimValues(userName, UserProfileType.DEFAULT.getTObject()));
        List<ClaimName> somethingList = Arrays.asList(ClaimName.values());
        for (Iterator<ClaimName> iterator = somethingList.iterator(); iterator.hasNext(); ) {
            ClaimName claimName = iterator.next();
            getClaimValue(claims, claimName);
        }
    } catch (RemoteException | RemoteUserStoreManagerServiceUserStoreExceptionException e) {
        log.error("unable to retrieve claims for user " + userName + " : ", e);
        return Collections.emptyMap();
    }
    return userClaimDetails;
}
Also used : ClaimName(com.wso2telco.core.userprofile.util.ClaimName) APIManagerConfiguration(org.wso2.carbon.apimgt.impl.APIManagerConfiguration) ClaimUtil(com.wso2telco.core.userprofile.util.ClaimUtil) RemoteUserStoreManagerServiceStub(org.wso2.carbon.um.ws.api.stub.RemoteUserStoreManagerServiceStub) RemoteException(java.rmi.RemoteException) Claim(org.wso2.carbon.user.core.claim.Claim) RemoteUserStoreManagerServiceUserStoreExceptionException(org.wso2.carbon.um.ws.api.stub.RemoteUserStoreManagerServiceUserStoreExceptionException)

Example 2 with ClaimName

use of com.wso2telco.core.userprofile.util.ClaimName in project core-util by WSO2Telco.

the class UserClaimProsser method getUserClaims.

public UserClaimDTO getUserClaims(String userName) {
    UserClaimDTO userClaimDTO = null;
    Map<ClaimName, String> userClaims = getUserClaimsByUserName(userName);
    if (!userClaims.isEmpty()) {
        userClaimDTO = new UserClaimDTO();
        userClaimDTO = fillUserClaimDTO(userClaims, userClaimDTO);
    }
    return userClaimDTO;
}
Also used : ClaimName(com.wso2telco.core.userprofile.util.ClaimName) UserClaimDTO(com.wso2telco.core.userprofile.dto.UserClaimDTO)

Aggregations

ClaimName (com.wso2telco.core.userprofile.util.ClaimName)2 UserClaimDTO (com.wso2telco.core.userprofile.dto.UserClaimDTO)1 ClaimUtil (com.wso2telco.core.userprofile.util.ClaimUtil)1 RemoteException (java.rmi.RemoteException)1 APIManagerConfiguration (org.wso2.carbon.apimgt.impl.APIManagerConfiguration)1 RemoteUserStoreManagerServiceStub (org.wso2.carbon.um.ws.api.stub.RemoteUserStoreManagerServiceStub)1 RemoteUserStoreManagerServiceUserStoreExceptionException (org.wso2.carbon.um.ws.api.stub.RemoteUserStoreManagerServiceUserStoreExceptionException)1 Claim (org.wso2.carbon.user.core.claim.Claim)1