Java Code Examples for org.wso2.carbon.identity.core.util.IdentityDatabaseUtil#closeAllConnections()

The following examples show how to use org.wso2.carbon.identity.core.util.IdentityDatabaseUtil#closeAllConnections() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RequestEntityRelationshipDAO.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
/**
 * Add a new relationship between a workflow request and an entity.
 *
 * @param entity
 * @param uuid
 * @throws InternalWorkflowException
 */
public void addRelationship(Entity entity, String uuid) throws InternalWorkflowException {

    Connection connection = IdentityDatabaseUtil.getDBConnection();
    PreparedStatement prepStmt = null;
    String query = SQLConstants.ADD_REQUEST_ENTITY_RELATIONSHIP;
    try {
        prepStmt = connection.prepareStatement(query);
        prepStmt.setString(1, uuid);
        prepStmt.setString(2, entity.getEntityId());
        prepStmt.setString(3, entity.getEntityType());
        prepStmt.setInt(4, entity.getTenantId());
        prepStmt.executeUpdate();
        connection.commit();
    } catch (SQLException e) {
        throw new InternalWorkflowException("Error when executing the sql query", e);
    } finally {
        IdentityDatabaseUtil.closeAllConnections(connection, null, prepStmt);
    }
}
 
Example 2
Source File: GroupDAO.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
public void removeSCIMGroup(int tenantId, String roleName) throws IdentitySCIMException {
    Connection connection = IdentityDatabaseUtil.getDBConnection();
    PreparedStatement prepStmt = null;

    try {
        prepStmt = connection.prepareStatement(SQLQueries.DELETE_GROUP_SQL);
        prepStmt.setInt(1, tenantId);
        prepStmt.setString(2, SCIMCommonUtils.getGroupNameWithDomain(roleName));

        prepStmt.execute();
        connection.commit();

    } catch (SQLException e) {
        log.error("Error when executing the SQL : " + SQLQueries.DELETE_GROUP_SQL);
        throw new IdentitySCIMException("Error deleting the SCIM Group.", e);
    } finally {
        IdentityDatabaseUtil.closeAllConnections(connection, null, prepStmt);
    }
}
 
Example 3
Source File: AssociationDAO.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
/**
 *
 * @param id
 * @throws InternalWorkflowException
 */
public void removeAssociation(int id) throws InternalWorkflowException {

    Connection connection = IdentityDatabaseUtil.getDBConnection();
    PreparedStatement prepStmt = null;
    String query = SQLConstants.DELETE_ASSOCIATION_QUERY;
    try {
        prepStmt = connection.prepareStatement(query);
        prepStmt.setInt(1, id);
        prepStmt.executeUpdate();
        IdentityDatabaseUtil.commitTransaction(connection);
    } catch (SQLException e) {
        IdentityDatabaseUtil.rollbackTransaction(connection);
        throw new InternalWorkflowException(errorMessage, e);
    } finally {
        IdentityDatabaseUtil.closeAllConnections(connection, null, prepStmt);
    }
}
 
Example 4
Source File: DBStsDAO.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
/**
 * This is for removing token
 *
 * @param tokenId tokenId
 */
public void removeToken(String tokenId) throws TrustException {
    Connection connection = IdentityDatabaseUtil.getDBConnection();
    PreparedStatement prepStmt = null;
    ResultSet rs = null;

    String query = DBQueries.REMOVE_TOKEN;
    try {
        prepStmt = connection.prepareStatement(query);
        prepStmt.setString(1, tokenId);
        prepStmt.executeUpdate();

    } catch (Exception e) {
        String msg = "Failed to remove token";
        throw new TrustException(msg, e);
    } finally {
        IdentityDatabaseUtil.closeAllConnections(connection, rs, prepStmt);
    }

}
 
Example 5
Source File: IdPManagementDAO.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
/**
 * @param dbConnection
 * @param idPName
 * @param tenantId
 * @return
 * @throws SQLException
 * @throws IdentityProviderManagementException
 */
private int getIdentityProviderIdentifier(Connection dbConnection, String idPName, int tenantId)
        throws SQLException, IdentityProviderManagementException {

    String sqlStmt = null;
    PreparedStatement prepStmt = null;
    ResultSet rs = null;
    try {
        sqlStmt = IdPManagementConstants.SQLQueries.GET_IDP_BY_NAME_SQL;
        prepStmt = dbConnection.prepareStatement(sqlStmt);
        prepStmt.setInt(1, tenantId);
        prepStmt.setInt(2, MultitenantConstants.SUPER_TENANT_ID);
        prepStmt.setString(3, idPName);
        rs = prepStmt.executeQuery();
        if (rs.next()) {
            return rs.getInt("ID");
        } else {
            throw new IdentityProviderManagementException("Invalid Identity Provider Name "
                    + idPName);
        }
    } finally {
        IdentityDatabaseUtil.closeAllConnections(null, rs, prepStmt);
    }
}
 
Example 6
Source File: RequestEntityRelationshipDAO.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
/**
 * Add a new relationship between a workflow request and an entity.
 *
 * @param entity
 * @param uuid
 * @throws InternalWorkflowException
 */
public void addRelationship(Entity entity, String uuid) throws InternalWorkflowException {

    Connection connection = IdentityDatabaseUtil.getDBConnection();
    PreparedStatement prepStmt = null;
    String query = SQLConstants.ADD_REQUEST_ENTITY_RELATIONSHIP;
    try {
        prepStmt = connection.prepareStatement(query);
        prepStmt.setString(1, uuid);
        prepStmt.setString(2, entity.getEntityId());
        prepStmt.setString(3, entity.getEntityType());
        prepStmt.setInt(4, entity.getTenantId());
        prepStmt.executeUpdate();
        IdentityDatabaseUtil.commitTransaction(connection);
    } catch (SQLException e) {
        IdentityDatabaseUtil.rollbackTransaction(connection);
        throw new InternalWorkflowException("Error when executing the sql query", e);
    } finally {
        IdentityDatabaseUtil.closeAllConnections(connection, null, prepStmt);
    }
}
 
Example 7
Source File: TokenMgtDAO.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
public void renameUserStoreDomainInAuthorizationCodeTable(int tenantId, String currentUserStoreDomain, String
        newUserStoreDomain) throws IdentityOAuth2Exception {

    //we do not support access token partitioning here
    Connection connection = IdentityDatabaseUtil.getDBConnection();
    PreparedStatement ps = null;
    try {
        String sqlQuery = SQLQueries.RENAME_USER_STORE_IN_AUTHORIZATION_CODES_TABLE;
        ps = connection.prepareStatement(sqlQuery);
        ps.setString(1, newUserStoreDomain.toUpperCase());
        ps.setInt(2, tenantId);
        ps.setString(3, currentUserStoreDomain.toUpperCase());
        int count = ps.executeUpdate();
        if (log.isDebugEnabled()) {
            log.debug("Number of rows being updated : " + count);
        }
        connection.commit();
    } catch (SQLException e) {
        IdentityDatabaseUtil.rollBack(connection);
        throw new IdentityOAuth2Exception("Error occurred while renaming user store : " + currentUserStoreDomain +
                "in tenant :" + tenantId, e);
    } finally {
        IdentityDatabaseUtil.closeAllConnections(connection, null, ps);
    }
}
 
Example 8
Source File: WorkflowRequestDAO.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
/**
 * Update state of a existing workflow request
 *
 * @param requestId
 * @param newState
 * @throws InternalWorkflowException
 */
public void updateStatusOfRequest(String requestId, String newState) throws InternalWorkflowException {

    Connection connection = IdentityDatabaseUtil.getDBConnection();
    PreparedStatement prepStmt = null;
    String query = SQLConstants.UPDATE_STATUS_OF_REQUEST;
    try {
        prepStmt = connection.prepareStatement(query);
        prepStmt.setString(1, newState);
        prepStmt.setTimestamp(2, new Timestamp(System.currentTimeMillis()));
        prepStmt.setString(3, requestId);
        prepStmt.execute();
        IdentityDatabaseUtil.commitTransaction(connection);
    } catch (SQLException e) {
        IdentityDatabaseUtil.rollbackTransaction(connection);
        throw new InternalWorkflowException("Error when executing the sql query:" + query, e);
    } finally {
        IdentityDatabaseUtil.closeAllConnections(connection, null, prepStmt);
    }
}
 
Example 9
Source File: RequestEntityRelationshipDAO.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
/**
 * Check if a given entity as any pending workflows of a given type associated with it.
 *
 * @param entity
 * @param requsetType
 * @return
 * @throws InternalWorkflowException
 */
public boolean entityHasPendingWorkflowsOfType(Entity entity, String requsetType) throws
        InternalWorkflowException {

    Connection connection = IdentityDatabaseUtil.getDBConnection(false);
    PreparedStatement prepStmt = null;
    String query = SQLConstants.GET_PENDING_RELATIONSHIPS_OF_GIVEN_TYPE_FOR_ENTITY;
    ResultSet resultSet = null;
    try {
        prepStmt = connection.prepareStatement(query);
        prepStmt.setString(1, entity.getEntityType());
        prepStmt.setString(2, entity.getEntityId());
        prepStmt.setString(3, WorkflowRequestStatus.PENDING.toString());
        prepStmt.setString(4, requsetType);
        prepStmt.setInt(5, entity.getTenantId());
        resultSet = prepStmt.executeQuery();
        if (resultSet.next()) {
            return true;
        }
    } catch (SQLException e) {
        throw new InternalWorkflowException("Error when executing the sql query", e);
    } finally {
        IdentityDatabaseUtil.closeAllConnections(connection, resultSet, prepStmt);
    }
    return false;
}
 
Example 10
Source File: AssociationDAO.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
/**
 *
 * @param associationName
 * @param workflowId
 * @param eventId
 * @param condition
 * @throws InternalWorkflowException
 */
public void addAssociation(String associationName, String workflowId, String eventId, String condition)
        throws InternalWorkflowException {

    Connection connection = IdentityDatabaseUtil.getDBConnection();
    PreparedStatement prepStmt = null;

    String query = SQLConstants.ASSOCIATE_WF_TO_EVENT;
    try {
        prepStmt = connection.prepareStatement(query);
        prepStmt.setString(1, eventId);
        prepStmt.setString(2, associationName);
        prepStmt.setString(3, condition);
        prepStmt.setString(4, workflowId);
        prepStmt.executeUpdate();
        connection.commit();
    } catch (SQLException e) {
        throw new InternalWorkflowException(errorMessage, e);
    } finally {
        IdentityDatabaseUtil.closeAllConnections(connection, null, prepStmt);
    }
}
 
Example 11
Source File: WorkflowDAO.java    From carbon-identity-framework with Apache License 2.0 6 votes vote down vote up
/**
 * Adding a workflow
 *
 * @param workflow Workflow bean object
 * @param tenantId Tenant ID
 * @throws InternalWorkflowException
 */
public void addWorkflow(Workflow workflow, int
        tenantId) throws InternalWorkflowException {

    Connection connection = IdentityDatabaseUtil.getDBConnection();
    PreparedStatement prepStmt = null;
    String query = SQLConstants.ADD_WORKFLOW_QUERY;
    try {
        prepStmt = connection.prepareStatement(query);
        prepStmt.setString(1, workflow.getWorkflowId());
        prepStmt.setString(2, workflow.getWorkflowName());
        prepStmt.setString(3, workflow.getWorkflowDescription());
        prepStmt.setString(4, workflow.getTemplateId());
        prepStmt.setString(5, workflow.getWorkflowImplId());
        prepStmt.setInt(6, tenantId);
        prepStmt.executeUpdate();
        IdentityDatabaseUtil.commitTransaction(connection);
    } catch (SQLException e) {
        IdentityDatabaseUtil.rollbackTransaction(connection);
        throw new InternalWorkflowException(errorMessage , e);
    } finally {
        IdentityDatabaseUtil.closeAllConnections(connection, null, prepStmt);
    }
}
 
Example 12
Source File: WorkflowDAO.java    From carbon-identity with Apache License 2.0 6 votes vote down vote up
/**
 * Clear all the parameters that stored under workflow Id
 *
 * @param workflowId WorkflowId
 * @throws InternalWorkflowException
 */
public void removeWorkflowParams(String workflowId) throws InternalWorkflowException {

    Connection connection = IdentityDatabaseUtil.getDBConnection();
    PreparedStatement prepStmt = null;
    String query = SQLConstants.DELETE_WORKFLOW_PARAMS_QUERY;
    try {
        prepStmt = connection.prepareStatement(query);
        prepStmt.setString(1, workflowId);
        prepStmt.executeUpdate();
        connection.commit();
    } catch (SQLException e) {
        throw new InternalWorkflowException(errorMessage, e);
    } finally {
        IdentityDatabaseUtil.closeAllConnections(connection, null, prepStmt);
    }
}
 
Example 13
Source File: OpenIDAssociationDAO.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * Loads the association in the identity database.
 *
 * @param handle
 * @return <code>Association</code>
 */
public Association loadAssociation(String handle) {

    Connection connection = IdentityDatabaseUtil.getDBConnection();
    PreparedStatement prepStmt = null;
    ResultSet results = null;

    try {
        prepStmt = connection.prepareStatement(OpenIDSQLQueries.LOAD_ASSOCIATION);
        prepStmt.setString(1, handle);
        results = prepStmt.executeQuery();

        if (results.next()) {
            log.debug("Loading association " + handle);
            return buildAssociationObject(results);
        }
        connection.commit();
    } catch (SQLException e) {
        log.error("Failed to load the association " + handle, e);
    } finally {
        IdentityDatabaseUtil.closeAllConnections(connection, results, prepStmt);
    }
    if(log.isDebugEnabled()) {
        log.debug("Failed to load the association " + handle + " from the database");
    }
    return null;
}
 
Example 14
Source File: DeviceStoreDAO.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * Remove all registered device from store.
 *
 * @param username
 * @param tenantDomain
 * @param userStoreDomain
 * @throws FIDOAuthenticatorServerException
 */
public void removeAllRegistrations(String username, String tenantDomain, String userStoreDomain)
        throws FIDOAuthenticatorServerException {

    if (log.isDebugEnabled()) {
        log.debug("removeRegistration inputs {username:" + username + "}");
    }
    Connection connection = IdentityDatabaseUtil.getDBConnection();
    PreparedStatement preparedStatement = null;

    try {
        preparedStatement = connection.prepareStatement(FIDOAuthenticatorConstants.SQLQueries.REMOVE_ALL_REGISTRATION_QUERY);
        preparedStatement.setInt(1, IdentityTenantUtil.getTenantId(tenantDomain));
        preparedStatement.setString(2, userStoreDomain);
        preparedStatement.setString(3, username);
        preparedStatement.executeUpdate();

        if (!connection.getAutoCommit()) {
            connection.commit();
        }
    } catch (SQLException e) {
        throw new FIDOAuthenticatorServerException(
                "Error executing remove all registrations SQL : " +
                FIDOAuthenticatorConstants.SQLQueries.REMOVE_ALL_REGISTRATION_QUERY, e
        );
    } finally {
        IdentityDatabaseUtil.closeAllConnections(connection, null, preparedStatement);
    }
}
 
Example 15
Source File: GroupDAO.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public String getGroupNameById(int tenantId, String id) throws IdentitySCIMException {
    Connection connection = IdentityDatabaseUtil.getDBConnection();
    PreparedStatement prepStmt = null;
    ResultSet rSet = null;
    String roleName = null;

    try {
        prepStmt = connection.prepareStatement(SQLQueries.GET_GROUP_NAME_BY_ID_SQL);
        prepStmt.setInt(1, tenantId);
        prepStmt.setString(2, id);
        prepStmt.setString(3, SCIMConstants.ID_URI);
        rSet = prepStmt.executeQuery();
        while (rSet.next()) {
            //we assume only one result since group id and tenant id is unique.
            roleName = rSet.getString(1);
        }
        connection.commit();
    } catch (SQLException e) {
        throw new IdentitySCIMException("Error when reading the SCIM Group information from the persistence store.", e);
    } finally {
        IdentityDatabaseUtil.closeAllConnections(connection, rSet, prepStmt);
    }
    if (StringUtils.isNotEmpty(roleName)) {
        return SCIMCommonUtils.getPrimaryFreeGroupName(roleName);
    }
    return null;
}
 
Example 16
Source File: IdPManagementDAO.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
/**
 * @param dbConnection
 * @param idpName
 * @param tenantId
 * @return
 * @throws SQLException
 * @throws IdentityProviderManagementException
 */
private int getIdentityProviderIdByName(Connection dbConnection, String idpName, int tenantId)
        throws SQLException, IdentityProviderManagementException {

    boolean dbConnInitialized = true;
    PreparedStatement prepStmt = null;
    ResultSet rs = null;
    if (dbConnection == null) {
        dbConnection = IdentityDatabaseUtil.getDBConnection(false);
    } else {
        dbConnInitialized = false;
    }
    try {

        String sqlStmt = IdPManagementConstants.SQLQueries.GET_IDP_ROW_ID_SQL;
        prepStmt = dbConnection.prepareStatement(sqlStmt);
        prepStmt.setInt(1, tenantId);
        prepStmt.setInt(2, MultitenantConstants.SUPER_TENANT_ID);
        prepStmt.setString(3, idpName);
        rs = prepStmt.executeQuery();
        if (rs.next()) {
            return rs.getInt(1);
        }
    } finally {
        if (dbConnInitialized) {
            IdentityDatabaseUtil.closeAllConnections(dbConnection, rs, prepStmt);
        } else {
            IdentityDatabaseUtil.closeAllConnections(null, rs, prepStmt);
        }
    }
    return 0;
}
 
Example 17
Source File: TokenMgtDAO.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
public void doExpireAuthzCode(String authzCode) throws IdentityOAuth2Exception {
    Connection connection = IdentityDatabaseUtil.getDBConnection();
    PreparedStatement prepStmt = null;

    try {
        prepStmt = connection.prepareStatement(SQLQueries.EXPIRE_AUTHZ_CODE);
        prepStmt.setString(1, persistenceProcessor.getPreprocessedAuthzCode(authzCode));
        prepStmt.execute();
        connection.commit();
    } catch (SQLException e) {
        throw new IdentityOAuth2Exception("Error when cleaning up an authorization code", e);
    } finally {
        IdentityDatabaseUtil.closeAllConnections(connection, null, prepStmt);
    }
}
 
Example 18
Source File: WorkflowDAO.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * Add new parameter List to given workflow id
 *
 * @param parameterList Paramter List
 * @param workflowId Workflow Id
 * @throws InternalWorkflowException
 */
public void addWorkflowParams(List<Parameter> parameterList, String workflowId, int tenantId) throws
        InternalWorkflowException {

    Connection connection = IdentityDatabaseUtil.getDBConnection();
    PreparedStatement prepStmt = null;

    String query = SQLConstants.ADD_WORKFLOW_PARAMS_QUERY;
    try {
        for (Parameter parameter : parameterList){
            prepStmt = connection.prepareStatement(query);
            prepStmt.setString(1, workflowId);
            prepStmt.setString(2, parameter.getParamName());
            prepStmt.setString(3, parameter.getParamValue());
            prepStmt.setString(4, parameter.getqName());
            prepStmt.setString(5, parameter.getHolder());
            prepStmt.setInt(6, tenantId);

            prepStmt.executeUpdate();
        }
        connection.commit();
    } catch (SQLException e) {
        throw new InternalWorkflowException(errorMessage, e);
    } finally {
        IdentityDatabaseUtil.closeAllConnections(connection, null, prepStmt);
    }
}
 
Example 19
Source File: RequestEntityRelationshipDAO.java    From carbon-identity with Apache License 2.0 5 votes vote down vote up
/**
 * Check if a given entity as any pending workflows of a given type associated with it.
 *
 * @param entity
 * @param requsetType
 * @return
 * @throws InternalWorkflowException
 */
public boolean entityHasPendingWorkflowsOfType(Entity entity, String requsetType) throws
        InternalWorkflowException {

    Connection connection = IdentityDatabaseUtil.getDBConnection();
    PreparedStatement prepStmt = null;
    String query = SQLConstants.GET_PENDING_RELATIONSHIPS_OF_GIVEN_TYPE_FOR_ENTITY;
    ResultSet resultSet = null;
    try {
        prepStmt = connection.prepareStatement(query);
        prepStmt.setString(1, entity.getEntityType());
        prepStmt.setString(2, entity.getEntityId());
        prepStmt.setString(3, WorkflowRequestStatus.PENDING.toString());
        prepStmt.setString(4, requsetType);
        prepStmt.setInt(5, entity.getTenantId());
        resultSet = prepStmt.executeQuery();
        if (resultSet.next()) {
            return true;
        }
        connection.commit();
    } catch (SQLException e) {
        throw new InternalWorkflowException("Error when executing the sql query", e);
    } finally {
        IdentityDatabaseUtil.closeAllConnections(connection, resultSet, prepStmt);
    }
    return false;
}
 
Example 20
Source File: IdPManagementDAO.java    From carbon-identity-framework with Apache License 2.0 4 votes vote down vote up
/**
 * @param dbConnection
 * @param idPName
 * @param tenantId
 * @return
 * @throws IdentityProviderManagementException
 * @throws SQLException
 */
private FederatedAuthenticatorConfig[] getFederatedAuthenticatorConfigs(
        Connection dbConnection, String idPName, IdentityProvider federatedIdp, int tenantId)
        throws IdentityProviderManagementException, SQLException {

    int idPId = getIdentityProviderIdentifier(dbConnection, idPName, tenantId);

    PreparedStatement prepStmt1 = null;
    PreparedStatement prepStmt2 = null;
    ResultSet rs = null;
    ResultSet proprs = null;
    String defaultAuthName = null;

    if (federatedIdp != null && federatedIdp.getDefaultAuthenticatorConfig() != null) {
        defaultAuthName = federatedIdp.getDefaultAuthenticatorConfig().getName();
    }

    String sqlStmt = IdPManagementConstants.SQLQueries.GET_ALL_IDP_AUTH_SQL;
    Set<FederatedAuthenticatorConfig> federatedAuthenticatorConfigs = new HashSet<FederatedAuthenticatorConfig>();
    try {
        prepStmt1 = dbConnection.prepareStatement(sqlStmt);
        prepStmt1.setInt(1, idPId);
        rs = prepStmt1.executeQuery();

        while (rs.next()) {
            FederatedAuthenticatorConfig authnConfig = new FederatedAuthenticatorConfig();
            int authnId = rs.getInt("ID");
            authnConfig.setName(rs.getString("NAME"));

            if ((IdPManagementConstants.IS_TRUE_VALUE).equals(rs.getString("IS_ENABLED"))) {
                authnConfig.setEnabled(true);
            } else {
                authnConfig.setEnabled(false);
            }

            authnConfig.setDisplayName(rs.getString("DISPLAY_NAME"));

            if (defaultAuthName != null && authnConfig.getName().equals(defaultAuthName)) {
                federatedIdp.getDefaultAuthenticatorConfig().setDisplayName(authnConfig.getDisplayName());
            }

            sqlStmt = IdPManagementConstants.SQLQueries.GET_IDP_AUTH_PROPS_SQL;
            prepStmt2 = dbConnection.prepareStatement(sqlStmt);
            prepStmt2.setInt(1, authnId);
            proprs = prepStmt2.executeQuery();
            Set<Property> properties = new HashSet<Property>();
            while (proprs.next()) {
                Property property = new Property();
                property.setName(proprs.getString("PROPERTY_KEY"));
                property.setValue(proprs.getString("PROPERTY_VALUE"));
                if ((IdPManagementConstants.IS_TRUE_VALUE).equals(proprs.getString("IS_SECRET"))) {
                    property.setConfidential(true);
                }
                properties.add(property);
            }
            authnConfig.setProperties(properties.toArray(new Property[properties.size()]));
            federatedAuthenticatorConfigs.add(authnConfig);
        }

        return federatedAuthenticatorConfigs
                .toArray(new FederatedAuthenticatorConfig[federatedAuthenticatorConfigs.size()]);
    } finally {
        IdentityDatabaseUtil.closeAllConnections(null, proprs, prepStmt2);
        IdentityDatabaseUtil.closeAllConnections(null, rs, prepStmt1);
    }
}