use of org.wso2.carbon.identity.application.common.model.xsd.Claim in project carbon-identity-framework by wso2.
the class ClaimMetadataManagementAdminService method addExternalClaim.
@SuppressWarnings("unused")
public void addExternalClaim(ExternalClaimDTO externalClaim) throws ClaimMetadataException {
try {
ExternalClaim claim = ClaimMetadataUtils.convertExternalClaimDTOToExternalClaim(externalClaim);
String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
IdentityClaimManagementServiceDataHolder.getInstance().getClaimManagementService().addExternalClaim(claim, tenantDomain);
} catch (ClaimMetadataClientException e) {
if (log.isDebugEnabled()) {
log.debug(e.getMessage(), e);
}
throw new ClaimMetadataException(e.getMessage(), e);
} catch (Throwable e) {
log.error(e.getMessage(), e);
throw new ClaimMetadataException(e.getMessage(), e);
}
}
use of org.wso2.carbon.identity.application.common.model.xsd.Claim in project carbon-identity-framework by wso2.
the class CacheBackedExternalClaimDAO method removeExternalClaimCache.
/**
* Remove mapped external claims at post removing claim dialect.
*
* @param externalClaimDialectURI External claim dialect uri
* @param tenantId Tenant Id
*/
public void removeExternalClaimCache(String externalClaimDialectURI, int tenantId) {
ExternalClaimCacheKey cacheKey = new ExternalClaimCacheKey(externalClaimDialectURI);
externalClaimCache.clearCacheEntry(cacheKey, tenantId);
}
use of org.wso2.carbon.identity.application.common.model.xsd.Claim in project carbon-identity-framework by wso2.
the class CacheBackedExternalClaimDAO method getExternalClaims.
public List<ExternalClaim> getExternalClaims(String externalDialectURI, int tenantId) throws ClaimMetadataException {
ExternalClaimCacheKey cacheKey = new ExternalClaimCacheKey(externalDialectURI);
List<ExternalClaim> externalClaimList = externalClaimCache.getValueFromCache(cacheKey, tenantId);
if (externalClaimList == null) {
if (log.isDebugEnabled()) {
log.debug("Cache miss for external claim list for dialect: " + externalDialectURI + " in tenant: " + tenantId);
}
externalClaimList = externalClaimDAO.getExternalClaims(externalDialectURI, tenantId);
externalClaimCache.addToCache(cacheKey, new ArrayList<>(externalClaimList), tenantId);
} else {
if (log.isDebugEnabled()) {
log.debug("Cache hit for external claim list for dialect: " + externalDialectURI + " in tenant: " + tenantId);
}
}
return externalClaimList;
}
use of org.wso2.carbon.identity.application.common.model.xsd.Claim in project carbon-identity-framework by wso2.
the class ClaimDAO method addClaim.
public int addClaim(Connection connection, String claimDialectURI, String claimURI, int tenantId) throws ClaimMetadataException {
PreparedStatement prepStmt = null;
ResultSet rs = null;
int claimId = 0;
String query = SQLConstants.ADD_CLAIM;
try {
String dbProductName = connection.getMetaData().getDatabaseProductName();
prepStmt = connection.prepareStatement(query, new String[] { DBUtils.getConvertedAutoGeneratedColumnName(dbProductName, SQLConstants.ID_COLUMN) });
prepStmt.setString(1, claimDialectURI);
prepStmt.setInt(2, tenantId);
prepStmt.setString(3, claimURI);
prepStmt.setInt(4, tenantId);
prepStmt.executeUpdate();
rs = prepStmt.getGeneratedKeys();
if (rs.next()) {
claimId = rs.getInt(1);
}
} catch (SQLException e) {
throw new ClaimMetadataException("Error while adding claim " + claimURI + " to dialect " + claimDialectURI, e);
} finally {
IdentityDatabaseUtil.closeResultSet(rs);
IdentityDatabaseUtil.closeStatement(prepStmt);
}
return claimId;
}
use of org.wso2.carbon.identity.application.common.model.xsd.Claim in project carbon-identity-framework by wso2.
the class ClaimDAO method removeClaim.
public void removeClaim(String claimDialectURI, String localClaimURI, int tenantId) throws ClaimMetadataException {
Connection connection = IdentityDatabaseUtil.getDBConnection();
PreparedStatement prepStmt = null;
String query = SQLConstants.REMOVE_CLAIM;
try {
prepStmt = connection.prepareStatement(query);
prepStmt.setString(1, claimDialectURI);
prepStmt.setInt(2, tenantId);
prepStmt.setString(3, localClaimURI);
prepStmt.setInt(4, tenantId);
prepStmt.executeUpdate();
IdentityDatabaseUtil.commitTransaction(connection);
} catch (SQLException e) {
IdentityDatabaseUtil.rollbackTransaction(connection);
throw new ClaimMetadataException("Error while deleting claim " + localClaimURI + " from dialect" + claimDialectURI, e);
} finally {
IdentityDatabaseUtil.closeStatement(prepStmt);
IdentityDatabaseUtil.closeConnection(connection);
}
}
Aggregations