本文整理汇总了Java中org.wso2.carbon.identity.application.common.model.Claim类的典型用法代码示例。如果您正苦于以下问题:Java Claim类的具体用法?Java Claim怎么用?Java Claim使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Claim类属于org.wso2.carbon.identity.application.common.model包,在下文中一共展示了Claim类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addIdPClaims
import org.wso2.carbon.identity.application.common.model.Claim; //导入依赖的package包/类
/**
* @param conn
* @param idPId
* @param claims
* @throws SQLException
*/
private void addIdPClaims(Connection conn, int idPId, int tenantId, Claim[] claims)
throws SQLException {
PreparedStatement prepStmt = null;
if (claims == null || claims.length == 0) {
return;
}
try {
// SP_IDP_ID, SP_IDP_CLAIM
String sqlStmt = IdPManagementConstants.SQLQueries.ADD_IDP_CLAIMS_SQL;
prepStmt = conn.prepareStatement(sqlStmt);
for (Claim claim : claims) {
prepStmt.setInt(1, idPId);
prepStmt.setInt(2, tenantId);
prepStmt.setString(3, claim.getClaimUri());
prepStmt.addBatch();
prepStmt.clearParameters();
}
prepStmt.executeBatch();
} finally {
IdentityDatabaseUtil.closeStatement(prepStmt);
}
}
示例2: addUserAttributesToCache
import org.wso2.carbon.identity.application.common.model.Claim; //导入依赖的package包/类
private void addUserAttributesToCache(SessionDataCacheEntry sessionDataCacheEntry, String code, String codeId) {
AuthorizationGrantCacheKey authorizationGrantCacheKey = new AuthorizationGrantCacheKey(code);
AuthorizationGrantCacheEntry authorizationGrantCacheEntry = new AuthorizationGrantCacheEntry(
sessionDataCacheEntry.getLoggedInUser().getUserAttributes());
String sub = sessionDataCacheEntry.getLoggedInUser().getUserAttributes().get("sub");
if(StringUtils.isBlank(sub)){
sub = sessionDataCacheEntry.getLoggedInUser().getAuthenticatedSubjectIdentifier();
}
if(StringUtils.isNotBlank(sub)){
ClaimMapping claimMapping = new ClaimMapping();
Claim claim = new Claim();
claim.setClaimUri("sub");
claimMapping.setRemoteClaim(claim);
sessionDataCacheEntry.getLoggedInUser().getUserAttributes().put(claimMapping, sub);
}
authorizationGrantCacheEntry.setNonceValue(sessionDataCacheEntry.getoAuth2Parameters().getNonce());
authorizationGrantCacheEntry.setCodeId(codeId);
AuthorizationGrantCache.getInstance().addToCacheByCode(authorizationGrantCacheKey, authorizationGrantCacheEntry);
}
示例3: getClaims
import org.wso2.carbon.identity.application.common.model.Claim; //导入依赖的package包/类
/**
* @return
*/
public Claim[] getClaims() {
if (claimConfiguration != null) {
return claimConfiguration.getIdpClaims();
}
return new Claim[0];
}
示例4: getFederatedSubjectFromClaims
import org.wso2.carbon.identity.application.common.model.Claim; //导入依赖的package包/类
public static String getFederatedSubjectFromClaims(IdentityProvider identityProvider,
Map<ClaimMapping, String> claimMappings) {
String userIdClaimURI = identityProvider.getClaimConfig().getUserClaimURI();
ClaimMapping claimMapping = new ClaimMapping();
Claim claim = new Claim();
claim.setClaimUri(userIdClaimURI);
claimMapping.setRemoteClaim(claim);
claimMapping.setLocalClaim(claim);
return claimMappings.get(claimMapping);
}
示例5: addUserClaims
import org.wso2.carbon.identity.application.common.model.Claim; //导入依赖的package包/类
private void addUserClaims(JWTClaimsSet jwtClaimsSet, AuthenticatedUser user) {
for (Map.Entry<ClaimMapping, String> entry : user.getUserAttributes().entrySet()) {
ClaimMapping claimMapping = entry.getKey();
Claim claim = claimMapping.getLocalClaim();
if (claim != null && Constants.CUSTOMER_ID_CLAIM_URI.equalsIgnoreCase(claim.getClaimUri())) {
jwtClaimsSet.setClaim(Constants.CUSTOMER_ID_CLAIM_URI, entry.getValue());
}
}
}
示例6: getClaimMappingsMap
import org.wso2.carbon.identity.application.common.model.Claim; //导入依赖的package包/类
private Map<ClaimMapping, String> getClaimMappingsMap(Map<String, String> userAttributes) {
Map<ClaimMapping, String> results = new HashMap<ClaimMapping, String>();
for (Map.Entry<String, String> entry : userAttributes.entrySet()) {
ClaimMapping claimMapping = new ClaimMapping();
Claim claim = new Claim();
claim.setClaimUri(entry.getKey());
claimMapping.setRemoteClaim(claim);
results.put(claimMapping, entry.getValue());
}
return results;
}
示例7: setUp
import org.wso2.carbon.identity.application.common.model.Claim; //导入依赖的package包/类
@BeforeMethod
public void setUp() {
initMocks(this);
connector = new AbstractOutboundProvisioningConnector() {
@Override
public void init(Property[] provisioningProperties) throws IdentityProvisioningException {
}
@Override
public ProvisionedIdentifier provision(ProvisioningEntity provisioningEntity)
throws IdentityProvisioningException {
return null;
}
};
attributeMap = new HashMap<>();
attributeMap.put(ClaimMapping.build("testLocalClaim", "testRemoteClaim",
null, false), Arrays.asList("remoteClaimValue"));
attributeMap.put(ClaimMapping.build("testLocalClaim1", null,
null, false), new ArrayList<String>());
ClaimMapping mapping = new ClaimMapping();
mapping.setRemoteClaim(null);
mapping.setLocalClaim(new Claim());
attributeMap.put(mapping, new ArrayList<String>());
attributeMap.put(ClaimMapping.build(IdentityProvisioningConstants.GROUP_CLAIM_URI, IdentityProvisioningConstants
.GROUP_CLAIM_URI, null, false), Arrays.asList("testGroupName"));
attributeMap.put(ClaimMapping.build(IdentityProvisioningConstants.USERNAME_CLAIM_URI,
IdentityProvisioningConstants.USERNAME_CLAIM_URI,
null, false), Arrays.asList("testUserName"));
attributeMap.put(ClaimMapping.build(IdentityProvisioningConstants.PASSWORD_CLAIM_URI,
IdentityProvisioningConstants.PASSWORD_CLAIM_URI,
null, false), Arrays.asList("testPassword1", "testPassword2"));
attributeMap.put(ClaimMapping.build("testLocalClaim", "testRemoteClaim1",
null, false), Arrays.asList("testValue1", "testValue2"));
attributeMap.put(ClaimMapping.build("testLocalClaim2", "testRemoteClaim1",
null, false), Arrays.asList(null, "testValue2"));
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:42,代码来源:AbstractOutboundProvisioningConnectorTest.java
示例8: getLocalIdPDefaultClaimValues
import org.wso2.carbon.identity.application.common.model.Claim; //导入依赖的package包/类
/**
* @param dbConnection
* @param idPName
* @param userClaimUri
* @param roleClaimUri
* @param idpId
* @param tenantId
* @return
* @throws SQLException
*/
private ClaimConfig getLocalIdPDefaultClaimValues(Connection dbConnection, String idPName,
String userClaimUri, String roleClaimUri,
int idpId, int tenantId) throws SQLException {
PreparedStatement prepStmt = null;
ResultSet rs = null;
String sqlStmt;
ClaimConfig claimConfig = new ClaimConfig();
try {
claimConfig.setLocalClaimDialect(true);
claimConfig.setRoleClaimURI(roleClaimUri);
claimConfig.setUserClaimURI(userClaimUri);
sqlStmt = IdPManagementConstants.SQLQueries.GET_LOCAL_IDP_DEFAULT_CLAIM_VALUES_SQL;
prepStmt = dbConnection.prepareStatement(sqlStmt);
prepStmt.setInt(1, idpId);
prepStmt.setInt(2, tenantId);
List<ClaimMapping> claimMappings = new ArrayList<ClaimMapping>();
rs = prepStmt.executeQuery();
while (rs.next()) {
ClaimMapping claimMapping = new ClaimMapping();
// empty claim.
Claim remoteClaim = new Claim();
Claim localClaim = new Claim();
localClaim.setClaimUri(rs.getString("CLAIM_URI"));
claimMapping.setLocalClaim(localClaim);
claimMapping.setRemoteClaim(remoteClaim);
claimMapping.setDefaultValue(rs.getString("DEFAULT_VALUE"));
if ((IdPManagementConstants.IS_TRUE_VALUE).equals(rs.getString("IS_REQUESTED"))) {
claimMapping.setRequested(true);
} else if (rs.getString("IS_REQUESTED").equals(IdPManagementConstants.IS_TRUE_VALUE)) {
claimMapping.setRequested(false);
}
claimMappings.add(claimMapping);
}
claimConfig.setClaimMappings(claimMappings.toArray(new ClaimMapping[claimMappings
.size()]));
return claimConfig;
} finally {
IdentityDatabaseUtil.closeAllConnections(null, rs, prepStmt);
}
}
示例9: getIdPClaimConfiguration
import org.wso2.carbon.identity.application.common.model.Claim; //导入依赖的package包/类
/**
* @param dbConnection
* @param idPName
* @param tenantId
* @return
* @throws IdentityProviderManagementException
* @throws SQLException
*/
private ClaimConfig getIdPClaimConfiguration(Connection dbConnection, String idPName,
String userClaimUri, String roleClaimUri, int idPId, int tenantId)
throws IdentityProviderManagementException, SQLException {
PreparedStatement prepStmt1 = null;
PreparedStatement prepStmt2 = null;
ResultSet rs1 = null;
ResultSet rs2 = null;
try {
List<Claim> claimList = new ArrayList<Claim>();
// SP_IDP_CLAIM_ID, SP_IDP_CLAIM
String sqlStmt = IdPManagementConstants.SQLQueries.GET_IDP_CLAIMS_SQL;
prepStmt1 = dbConnection.prepareStatement(sqlStmt);
prepStmt1.setInt(1, idPId);
rs1 = prepStmt1.executeQuery();
ClaimConfig claimConfig = new ClaimConfig();
while (rs1.next()) {
Claim identityProviderClaim = new Claim();
identityProviderClaim.setClaimId(rs1.getInt(1));
identityProviderClaim.setClaimUri(rs1.getString(2));
claimList.add(identityProviderClaim);
}
// populate claim configuration with identity provider claims.
claimConfig.setIdpClaims(claimList.toArray(new Claim[claimList.size()]));
claimConfig.setUserClaimURI(userClaimUri);
claimConfig.setRoleClaimURI(roleClaimUri);
List<ClaimMapping> claimMappings = new ArrayList<ClaimMapping>();
// SP_IDP_CLAIMS.SP_IDP_CLAIM SP_IDP_CLAIM_MAPPINGS.SP_LOCAL_CLAIM
sqlStmt = IdPManagementConstants.SQLQueries.GET_IDP_CLAIM_MAPPINGS_SQL;
prepStmt2 = dbConnection.prepareStatement(sqlStmt);
prepStmt2.setInt(1, idPId);
rs2 = prepStmt2.executeQuery();
while (rs2.next()) {
ClaimMapping claimMapping = new ClaimMapping();
Claim idpClaim = new Claim();
idpClaim.setClaimUri(rs2.getString("CLAIM"));
Claim localClaim = new Claim();
localClaim.setClaimUri(rs2.getString("LOCAL_CLAIM"));
claimMapping.setLocalClaim(localClaim);
claimMapping.setRemoteClaim(idpClaim);
claimMapping.setDefaultValue(rs2.getString("DEFAULT_VALUE"));
if ((IdPManagementConstants.IS_TRUE_VALUE).equals(rs2.getString("IS_REQUESTED"))) {
claimMapping.setRequested(true);
} else if ((IdPManagementConstants.IS_FALSE_VALUE).equals(rs2.getString("IS_REQUESTED"))) {
claimMapping.setRequested(false);
}
claimMappings.add(claimMapping);
}
claimConfig.setClaimMappings(claimMappings.toArray(new ClaimMapping[claimMappings
.size()]));
return claimConfig;
} finally {
IdentityDatabaseUtil.closeAllConnections(null, rs2, prepStmt2);
IdentityDatabaseUtil.closeAllConnections(null, rs1, prepStmt1);
}
}