use of org.wso2.carbon.identity.application.common.model.xsd.Claim in project carbon-identity-framework by wso2.
the class ApplicationDAOImpl method getClaimMapping.
/**
* @param serviceProviderName
* @param tenantDomain
* @param localIdpAsKey
* @return
* @throws SQLException
* @throws IdentityApplicationManagementException
*/
private Map<String, String> getClaimMapping(String serviceProviderName, String tenantDomain, boolean localIdpAsKey) throws SQLException, IdentityApplicationManagementException {
int tenantID = -123;
if (tenantDomain != null) {
try {
tenantID = ApplicationManagementServiceComponentHolder.getInstance().getRealmService().getTenantManager().getTenantId(tenantDomain);
} catch (UserStoreException e1) {
throw new IdentityApplicationManagementException("Error while reading application");
}
}
Map<String, String> claimMapping = new HashMap<String, String>();
if (log.isDebugEnabled()) {
log.debug("Reading Claim Mappings of Application " + serviceProviderName);
}
PreparedStatement getClaimPreStmt = null;
ResultSet resultSet = null;
Connection connection = IdentityDatabaseUtil.getDBConnection(false);
try {
getClaimPreStmt = connection.prepareStatement(LOAD_CLAIM_MAPPING_BY_APP_NAME);
// IDP_CLAIM, SP_CLAIM, IS_REQUESTED
getClaimPreStmt.setString(1, serviceProviderName);
getClaimPreStmt.setInt(2, tenantID);
resultSet = getClaimPreStmt.executeQuery();
while (resultSet.next()) {
if (localIdpAsKey) {
claimMapping.put(resultSet.getString(1), resultSet.getString(2));
} else {
claimMapping.put(resultSet.getString(2), resultSet.getString(1));
}
}
} finally {
IdentityApplicationManagementUtil.closeStatement(getClaimPreStmt);
IdentityApplicationManagementUtil.closeResultSet(resultSet);
IdentityApplicationManagementUtil.closeConnection(connection);
}
return claimMapping;
}
use of org.wso2.carbon.identity.application.common.model.xsd.Claim in project carbon-identity-framework by wso2.
the class ApplicationDAOImpl method isClaimReferredByAnySp.
@Override
public boolean isClaimReferredByAnySp(Connection dbConnection, String claimUri, int tenantId) throws IdentityApplicationManagementException {
boolean dbConnInitialized = true;
PreparedStatement prepStmt = null;
ResultSet rs = null;
boolean isClaimReferred = false;
if (dbConnection == null) {
dbConnection = IdentityDatabaseUtil.getDBConnection(false);
} else {
dbConnInitialized = false;
}
try {
String sqlStmt = ApplicationMgtDBQueries.GET_TOTAL_SP_CLAIM_USAGES;
prepStmt = dbConnection.prepareStatement(sqlStmt);
prepStmt.setInt(1, tenantId);
prepStmt.setString(2, claimUri);
rs = prepStmt.executeQuery();
if (rs.next()) {
isClaimReferred = rs.getInt(1) > 0;
}
return isClaimReferred;
} catch (SQLException e) {
throw new IdentityApplicationManagementException("Error occurred while retrieving application usages of " + "the claim " + claimUri, e);
} finally {
if (dbConnInitialized) {
IdentityDatabaseUtil.closeAllConnections(dbConnection, rs, prepStmt);
} else {
IdentityDatabaseUtil.closeAllConnections(null, rs, prepStmt);
}
}
}
use of org.wso2.carbon.identity.application.common.model.xsd.Claim in project carbon-identity-framework by wso2.
the class ApplicationDAOImpl method getAllRequestedClaimsByServiceProvider.
@Override
public List<String> getAllRequestedClaimsByServiceProvider(String serviceProviderName, String tenantDomain) throws IdentityApplicationManagementException {
int tenantID = -123;
if (tenantDomain != null) {
try {
tenantID = ApplicationManagementServiceComponentHolder.getInstance().getRealmService().getTenantManager().getTenantId(tenantDomain);
} catch (UserStoreException e1) {
throw new IdentityApplicationManagementException("Error while reading application");
}
}
List<String> reqClaimUris = new ArrayList<String>();
if (log.isDebugEnabled()) {
log.debug("Reading Claim Mappings of Application " + serviceProviderName);
}
PreparedStatement getClaimPreStmt = null;
ResultSet resultSet = null;
Connection connection = IdentityDatabaseUtil.getDBConnection(false);
try {
getClaimPreStmt = connection.prepareStatement(LOAD_CLAIM_MAPPING_BY_APP_NAME);
// IDP_CLAIM, SP_CLAIM, IS_REQUESTED
getClaimPreStmt.setString(1, serviceProviderName);
getClaimPreStmt.setInt(2, tenantID);
resultSet = getClaimPreStmt.executeQuery();
while (resultSet.next()) {
if ("1".equalsIgnoreCase(resultSet.getString(3))) {
reqClaimUris.add(resultSet.getString(1));
}
}
} catch (SQLException e) {
throw new IdentityApplicationManagementException("Error while retrieving requested claims", e);
} finally {
IdentityApplicationManagementUtil.closeStatement(getClaimPreStmt);
IdentityApplicationManagementUtil.closeResultSet(resultSet);
IdentityApplicationManagementUtil.closeConnection(connection);
}
return reqClaimUris;
}
use of org.wso2.carbon.identity.application.common.model.xsd.Claim in project carbon-identity-framework by wso2.
the class ApplicationManagementServiceImpl method getAllRequestedClaimsByServiceProvider.
/**
* Returns back the requested set of claims by the provided service provider in local idp claim
* dialect.
*
* @param serviceProviderName
* @param tenantDomain
* @return
* @throws IdentityApplicationManagementException
*/
@Override
public List<String> getAllRequestedClaimsByServiceProvider(String serviceProviderName, String tenantDomain) throws IdentityApplicationManagementException {
ApplicationDAO appDAO = ApplicationMgtSystemConfig.getInstance().getApplicationDAO();
List<String> reqClaims = appDAO.getAllRequestedClaimsByServiceProvider(serviceProviderName, tenantDomain);
if (reqClaims == null || reqClaims.isEmpty() && ApplicationManagementServiceComponent.getFileBasedSPs().containsKey(serviceProviderName)) {
return new FileBasedApplicationDAO().getAllRequestedClaimsByServiceProvider(serviceProviderName, tenantDomain);
}
return reqClaims;
}
use of org.wso2.carbon.identity.application.common.model.xsd.Claim in project carbon-identity-framework by wso2.
the class ClaimMetadataManagementAdminService method updateLocalClaim.
@SuppressWarnings("unused")
public void updateLocalClaim(LocalClaimDTO localClaim) throws ClaimMetadataException {
try {
LocalClaim claim = ClaimMetadataUtils.convertLocalClaimDTOToLocalClaim(localClaim);
String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
IdentityClaimManagementServiceDataHolder.getInstance().getClaimManagementService().updateLocalClaim(claim, tenantDomain);
} catch (Throwable e) {
log.error(e.getMessage(), e);
throw new ClaimMetadataException(e.getMessage(), e);
}
}
Aggregations