use of org.wso2.carbon.identity.test.integration.service.stub.ClaimDTO in project carbon-apimgt by wso2.
the class SubscriptionMappingUtil method fromSubscriberClaimsToDTO.
/**
* Convert Subscriber claims information into SubscriberInfoDTO
*
* @param subscriberClaims list of subscriber claims
* @param subscriberName subscriber name
* @return SubscriberInfoDTO
* @throws APIManagementException If an error occurs when getting display name of claim
*/
public static SubscriberInfoDTO fromSubscriberClaimsToDTO(Map<String, String> subscriberClaims, String subscriberName) throws APIManagementException {
SubscriberInfoDTO subscriberInfoDTO = new SubscriberInfoDTO();
subscriberInfoDTO.setName(subscriberName);
List<ClaimDTO> claimDTOList = new ArrayList<>();
for (String key : subscriberClaims.keySet()) {
ClaimDTO claimDTO = new ClaimDTO();
claimDTO.setName(APIUtil.getClaimDisplayName(key, subscriberName));
claimDTO.setURI(key);
claimDTO.setValue(subscriberClaims.get(key));
claimDTOList.add(claimDTO);
}
subscriberInfoDTO.setClaims(claimDTOList);
return subscriberInfoDTO;
}
use of org.wso2.carbon.identity.test.integration.service.stub.ClaimDTO in project core-util by WSO2Telco.
the class ClaimUtil method convertToClaims.
public org.wso2.carbon.user.core.claim.Claim[] convertToClaims(ClaimDTO[] claims) {
if (claims == null) {
return new org.wso2.carbon.user.core.claim.Claim[0];
}
org.wso2.carbon.user.core.claim.Claim[] claimz = new org.wso2.carbon.user.core.claim.Claim[claims.length];
int i = 0;
for (ClaimDTO claim : claims) {
claimz[i] = convertToClaim(claim);
i++;
}
return claimz;
}
use of org.wso2.carbon.identity.test.integration.service.stub.ClaimDTO in project product-microgateway by wso2.
the class MGWJWTGeneratorInvoker method getRetrievedClaims.
public static BMap<String, Object> getRetrievedClaims(BMap<String, Object> authContext) {
try {
List<ClaimDTO> claimList = abstractMGWClaimRetriever.retrieveClaims(convertBMapToMap(authContext));
if (claimList == null) {
return null;
}
BPackage packageId = new BPackage("wso2", "gateway", "3.2.1");
BMap<String, Object> bMap = BValueCreator.createRecordValue(packageId, "RetrievedUserClaimsListDTO");
bMap.put("count", claimList.size());
BArray bArray = (BArray) bMap.get("list");
for (Object claimDTO : claimList) {
bArray.append(BValueCreator.createRecordValue(packageId, "ClaimDTO", (Map<String, Object>) claimDTO));
}
return bMap;
// Not to break the flow if an exception occured during claim retrieval
} catch (Exception e) {
log.error("Error while retrieving user claims from remote url.", e);
return null;
}
}
use of org.wso2.carbon.identity.test.integration.service.stub.ClaimDTO in project carbon-identity-framework by wso2.
the class UserIdentityManagementUtil method getAllUserIdentityClaims.
/**
* Returns all user claims
*
* @param userName
* @return
* @throws IdentityMgtServiceException
*/
public static UserIdentityClaimDTO[] getAllUserIdentityClaims(String userName) throws IdentityMgtServiceException {
int tenantId = 0;
try {
tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
UserStoreManager userStoreManager = IdentityMgtServiceComponent.getRealmService().getTenantUserRealm(tenantId).getUserStoreManager();
// read all claims and convert them to UserIdentityClaimDTO
Claim[] claims = userStoreManager.getUserClaimValues(userName, null);
List<UserIdentityClaimDTO> allDefaultClaims = new ArrayList<UserIdentityClaimDTO>();
for (Claim claim : claims) {
if (claim.getClaimUri().contains(UserCoreConstants.DEFAULT_CARBON_DIALECT)) {
UserIdentityClaimDTO claimDTO = new UserIdentityClaimDTO();
claimDTO.setClaimUri(claim.getClaimUri());
claimDTO.setClaimValue(claim.getValue());
allDefaultClaims.add(claimDTO);
}
}
UserIdentityClaimDTO[] claimDTOs = new UserIdentityClaimDTO[allDefaultClaims.size()];
return allDefaultClaims.toArray(claimDTOs);
} catch (UserStoreException e) {
throw new IdentityMgtServiceException("Error while getting user identity claims", e);
}
}
use of org.wso2.carbon.identity.test.integration.service.stub.ClaimDTO in project carbon-identity-framework by wso2.
the class ClaimAdminService method convertClaimToClaimDTO.
private ClaimDTO convertClaimToClaimDTO(Claim claim) {
ClaimDTO claimDTO = new ClaimDTO();
claimDTO.setClaimUri(claim.getClaimUri());
claimDTO.setDescription(claim.getDescription());
claimDTO.setDialectURI(claim.getDialectURI());
claimDTO.setDisplayOrder(claim.getDisplayOrder());
claimDTO.setDisplayTag(claim.getDisplayTag());
claimDTO.setRegEx(claim.getRegEx());
claimDTO.setRequired(claim.isRequired());
claimDTO.setSupportedByDefault(claim.isSupportedByDefault());
claimDTO.setValue(claim.getValue());
claimDTO.setCheckedAttribute(claim.isCheckedAttribute());
claimDTO.setReadOnly(claim.isReadOnly());
return claimDTO;
}
Aggregations