use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider in project carbon-identity-framework by wso2.
the class CacheBackedIdPMgtDAO method clearIdpCache.
public void clearIdpCache(String idPName, String resourceId, int tenantId, String tenantDomain) throws IdentityProviderManagementException {
// clearing cache entries related to the IDP.
IdentityProvider identityProvider;
if (StringUtils.isNotBlank(resourceId)) {
identityProvider = this.getIdPByResourceId(resourceId, tenantId, tenantDomain);
} else {
identityProvider = this.getIdPByName(null, idPName, tenantId, tenantDomain);
}
if (identityProvider != null) {
if (log.isDebugEnabled()) {
log.debug("Removing entry for Identity Provider " + idPName + " of tenantDomain:" + tenantDomain + " from cache.");
}
IdPNameCacheKey idPNameCacheKey = new IdPNameCacheKey(idPName);
idPCacheByName.clearCacheEntry(idPNameCacheKey, tenantDomain);
if (identityProvider.getHomeRealmId() != null) {
IdPHomeRealmIdCacheKey idPHomeRealmIdCacheKey = new IdPHomeRealmIdCacheKey(identityProvider.getHomeRealmId());
idPCacheByHRI.clearCacheEntry(idPHomeRealmIdCacheKey, tenantDomain);
}
if (StringUtils.isNotBlank(resourceId)) {
IdPResourceIdCacheKey idPResourceIdCacheKey = new IdPResourceIdCacheKey(resourceId);
idPCacheByResourceId.clearCacheEntry(idPResourceIdCacheKey, tenantDomain);
}
String idPIssuerName = getIDPIssuerName(identityProvider);
if (StringUtils.isNotBlank(idPIssuerName)) {
IdPMetadataPropertyCacheKey cacheKey = new IdPMetadataPropertyCacheKey(IdentityApplicationConstants.IDP_ISSUER_NAME, idPIssuerName);
idPCacheByMetadataProperty.clearCacheEntry(cacheKey, tenantDomain);
}
} else {
log.debug("Entry for Identity Provider " + idPName + " not found in cache or DB");
}
}
use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider in project carbon-identity-framework by wso2.
the class CacheBackedIdPMgtDAO method deleteIdP.
/**
* @param idPName
* @param tenantId
* @param tenantDomain
* @throws IdentityProviderManagementException
*/
public void deleteIdP(String idPName, int tenantId, String tenantDomain) throws IdentityProviderManagementException {
if (idPMgtDAO.isIdpReferredBySP(idPName, tenantId)) {
throw new IdentityProviderManagementException("Identity Provider '" + idPName + "' " + "cannot be deleted as it is referred by Service Providers.");
}
IdentityProvider identityProvider = this.getIdPByName(null, idPName, tenantId, tenantDomain);
if (identityProvider != null) {
idPMgtDAO.deleteIdP(idPName, tenantId, tenantDomain);
clearIdpCache(idPName, tenantId, tenantDomain);
} else {
if (log.isDebugEnabled()) {
log.debug(String.format("IDP:%s of tenantDomain:%s is not found is cache or DB", idPName, tenantDomain));
}
}
}
use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider in project carbon-identity-framework by wso2.
the class IdPManagementDAO method getIdPsSearch.
/**
* Get all identity provider's Basic information along with additionally requested information depends on the
* requiredAttributes for a given matching filter.
*
* @param tenantId Tenant Id of the identity provider.
* @param expressionNode List of filter value for IdP search.
* @param limit Limit per page.
* @param offset Offset value.
* @param sortOrder Order of IdP ASC/DESC.
* @param sortBy The attribute need to sort.
* @param requiredAttributes Required attributes which needs to be return.
* @return Identity Provider's Basic Information array along with requested attribute information.
* @throws IdentityProviderManagementServerException Error when getting list of Identity Providers.
* @throws IdentityProviderManagementClientException Error when append the filer string.
*/
List<IdentityProvider> getIdPsSearch(int tenantId, List<ExpressionNode> expressionNode, int limit, int offset, String sortOrder, String sortBy, List<String> requiredAttributes) throws IdentityProviderManagementServerException, IdentityProviderManagementClientException {
FilterQueryBuilder filterQueryBuilder = new FilterQueryBuilder();
appendFilterQuery(expressionNode, filterQueryBuilder);
String sortedOrder = sortBy + " " + sortOrder;
try (Connection dbConnection = IdentityDatabaseUtil.getDBConnection(false);
ResultSet resultSet = getIdpQueryResultSet(dbConnection, sortedOrder, tenantId, offset, limit, filterQueryBuilder, requiredAttributes)) {
return populateIdentityProviderList(resultSet, dbConnection, requiredAttributes, tenantId);
} catch (SQLException e) {
String message = "Error occurred while retrieving Identity Provider for tenant: " + IdentityTenantUtil.getTenantDomain(tenantId);
throw IdPManagementUtil.handleServerException(IdPManagementConstants.ErrorMessage.ERROR_CODE_CONNECTING_DATABASE, message, e);
}
}
use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider in project carbon-identity-framework by wso2.
the class IdPManagementDAO method forceDeleteIdP.
public void forceDeleteIdP(String idPName, int tenantId, String tenantDomain) throws IdentityProviderManagementException {
Connection dbConnection = IdentityDatabaseUtil.getDBConnection();
try {
IdentityProvider identityProvider = getIdPByName(dbConnection, idPName, tenantId, tenantDomain);
if (identityProvider == null) {
String msg = "Trying to force delete non-existent Identity Provider: %s in tenantDomain: %s";
throw new IdentityProviderManagementException(String.format(msg, idPName, tenantDomain));
}
if (log.isDebugEnabled()) {
log.debug(String.format("Deleting SP Authentication Associations for IDP:%s of tenantDomain:%s", idPName, tenantDomain));
}
// Delete IDPs association with SPs in authentication sequences
deleteIdpSpAuthAssociations(dbConnection, tenantId, idPName);
// Delete IDPs association with SPs in outbound provisioning
if (log.isDebugEnabled()) {
log.debug(String.format("Deleting SP Provisioning Associations for IDP:%s of tenantDomain:%s", idPName, tenantDomain));
}
deleteIdpSpProvisioningAssociations(dbConnection, tenantId, idPName);
deleteIdP(dbConnection, tenantId, idPName, null);
IdentityDatabaseUtil.commitTransaction(dbConnection);
} catch (SQLException e) {
IdentityDatabaseUtil.rollbackTransaction(dbConnection);
throw new IdentityProviderManagementException(String.format("Error occurred while deleting Identity Provider:%s of tenant:%s ", idPName, tenantDomain), e);
} finally {
IdentityDatabaseUtil.closeConnection(dbConnection);
}
}
use of org.wso2.carbon.identity.application.common.model.idp.xsd.IdentityProvider in project carbon-identity-framework by wso2.
the class IdPManagementDAO method populateIdentityProviderList.
/**
* Populate the result set.
*
* @param resultSet ResultSet.
* @param dbConnection Database Connection.
* @param requiredAttributes Required attributes which needs to be return.
* @param tenantId Tenant Id of the identity provider.
* @return List of Identity Provider.
* @throws SQLException Database Exception.
*/
private List<IdentityProvider> populateIdentityProviderList(ResultSet resultSet, Connection dbConnection, List<String> requiredAttributes, int tenantId) throws SQLException, IdentityProviderManagementServerException {
List<IdentityProvider> identityProviderList = new ArrayList<>();
while (resultSet.next()) {
IdentityProvider identityProvider = new IdentityProvider();
// First set the basic attributes such as id, name, description, isEnabled, image url, uuid.
identityProvider.setId(resultSet.getString("ID"));
identityProvider.setIdentityProviderName(resultSet.getString("NAME"));
identityProvider.setIdentityProviderDescription(resultSet.getString("DESCRIPTION"));
// IS_ENABLE
if ((IdPManagementConstants.IS_TRUE_VALUE).equals(resultSet.getString("IS_ENABLED"))) {
identityProvider.setEnable(true);
} else {
identityProvider.setEnable(false);
}
identityProvider.setImageUrl(resultSet.getString("IMAGE_URL"));
identityProvider.setResourceId(resultSet.getString("UUID"));
populateRequiredAttributesForIdentityProviderList(resultSet, dbConnection, requiredAttributes, tenantId, identityProvider);
if (!IdentityApplicationConstants.RESIDENT_IDP_RESERVED_NAME.equals(identityProvider.getIdentityProviderName())) {
identityProviderList.add(identityProvider);
}
List<IdentityProviderProperty> propertyList = getIdentityPropertiesByIdpId(dbConnection, Integer.parseInt(resultSet.getString("ID")));
identityProvider.setIdpProperties(propertyList.toArray(new IdentityProviderProperty[0]));
}
return identityProviderList;
}
Aggregations