本文整理匯總了Java中org.wso2.carbon.user.core.claim.ClaimMapping.setMappedAttribute方法的典型用法代碼示例。如果您正苦於以下問題:Java ClaimMapping.setMappedAttribute方法的具體用法?Java ClaimMapping.setMappedAttribute怎麽用?Java ClaimMapping.setMappedAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.wso2.carbon.user.core.claim.ClaimMapping
的用法示例。
在下文中一共展示了ClaimMapping.setMappedAttribute方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: convertLocalClaimToClaimMapping
import org.wso2.carbon.user.core.claim.ClaimMapping; //導入方法依賴的package包/類
public static ClaimMapping convertLocalClaimToClaimMapping(LocalClaim localClaim, int tenantId) throws
UserStoreException {
ClaimMapping claimMapping = new ClaimMapping();
Claim claim = new Claim();
claim.setClaimUri(localClaim.getClaimURI());
claim.setDialectURI(localClaim.getClaimDialectURI());
Map<String, String> claimProperties = localClaim.getClaimProperties();
if (claimProperties.containsKey(ClaimConstants.DISPLAY_NAME_PROPERTY)) {
claim.setDisplayTag(claimProperties.get(ClaimConstants.DISPLAY_NAME_PROPERTY));
}
if (claimProperties.containsKey(ClaimConstants.DESCRIPTION_PROPERTY)) {
claim.setDescription(claimProperties.get(ClaimConstants.DESCRIPTION_PROPERTY));
}
if (claimProperties.containsKey(ClaimConstants.REGULAR_EXPRESSION_PROPERTY)) {
claim.setRegEx(claimProperties.get(ClaimConstants.REGULAR_EXPRESSION_PROPERTY));
}
if (claimProperties.containsKey(ClaimConstants.DISPLAY_ORDER_PROPERTY)) {
claim.setDisplayOrder(Integer.parseInt(claimProperties.get(ClaimConstants.DISPLAY_ORDER_PROPERTY)));
}
if (claimProperties.containsKey(ClaimConstants.SUPPORTED_BY_DEFAULT_PROPERTY)) {
if ("false".equalsIgnoreCase(claimProperties.get(ClaimConstants.SUPPORTED_BY_DEFAULT_PROPERTY))) {
claim.setSupportedByDefault(Boolean.FALSE);
} else {
claim.setSupportedByDefault(Boolean.TRUE);
}
}
if (claimProperties.containsKey(ClaimConstants.REQUIRED_PROPERTY)) {
if ("false".equalsIgnoreCase(claimProperties.get(ClaimConstants.REQUIRED_PROPERTY))) {
claim.setRequired(Boolean.FALSE);
} else {
claim.setRequired(Boolean.TRUE);
}
}
if (claimProperties.containsKey(ClaimConstants.READ_ONLY_PROPERTY)) {
if ("false".equalsIgnoreCase(claimProperties.get(ClaimConstants.READ_ONLY_PROPERTY))) {
claim.setReadOnly(Boolean.FALSE);
} else {
claim.setReadOnly(Boolean.TRUE);
}
}
claimMapping.setClaim(claim);
List<AttributeMapping> mappedAttributes = localClaim.getMappedAttributes();
for (AttributeMapping attributeMapping : mappedAttributes) {
claimMapping.setMappedAttribute(attributeMapping.getUserStoreDomain(), attributeMapping.getAttributeName());
}
if (claimProperties.containsKey(ClaimConstants.DEFAULT_ATTRIBUTE)) {
claimMapping.setMappedAttribute(claimProperties.get(ClaimConstants.DEFAULT_ATTRIBUTE));
} else {
RealmService realmService = IdentityClaimManagementServiceDataHolder.getInstance().getRealmService();
if (realmService != null && realmService.getTenantUserRealm(tenantId) != null) {
UserRealm realm = realmService.getTenantUserRealm(tenantId);
String primaryDomainName = realm.getRealmConfiguration().getUserStoreProperty
(UserCoreConstants.RealmConfig.PROPERTY_DOMAIN_NAME);
claimMapping.setMappedAttribute(localClaim.getMappedAttribute(primaryDomainName));
} else {
claimMapping.setMappedAttribute(localClaim.getMappedAttribute(UserCoreConstants.
PRIMARY_DEFAULT_DOMAIN_NAME));
}
}
return claimMapping;
}