/** * Utility method to close a database connection * * @param dbConnection Database <code>Connection</code> object */ public static void closeConnection(Connection dbConnection) { IdentityDatabaseUtil.closeConnection(dbConnection); }
/** * Utility method to close a database connection * * @param dbConnection Database <code>Connection</code> object */ public static void closeConnection(Connection dbConnection) { IdentityDatabaseUtil.closeConnection(dbConnection); }
private void addUserDataValue(String userName, int tenantId, String key, String value) throws SQLException { Connection connection = IdentityDatabaseUtil.getDBConnection(); PreparedStatement prepStmt = null; try { prepStmt = connection.prepareStatement(SQLQuery.STORE_USER_DATA); prepStmt.setInt(1, tenantId); prepStmt.setString(2, userName); prepStmt.setString(3, key); prepStmt.setString(4, value); prepStmt.execute(); connection.commit(); } finally { IdentityDatabaseUtil.closeStatement(prepStmt); IdentityDatabaseUtil.closeConnection(connection); } }
private void addUserDataValue(String userName, int tenantId, String key, String value) throws SQLException { Connection connection = IdentityDatabaseUtil.getDBConnection(); PreparedStatement prepStmt = null; try { prepStmt = connection.prepareStatement(SQLQuery.STORE_USER_DATA); prepStmt.setInt(1, tenantId); prepStmt.setString(2, userName); prepStmt.setString(3, key); prepStmt.setString(4, value); prepStmt.execute(); connection.commit(); } finally { IdentityDatabaseUtil.closeStatement(prepStmt); IdentityDatabaseUtil.closeConnection(connection); } }
private void addUserDataValue(String userName, int tenantId, String key, String value) throws SQLException { Connection connection = IdentityDatabaseUtil.getDBConnection(); PreparedStatement prepStmt = null; try { prepStmt = connection.prepareStatement(SQLQuery.STORE_USER_DATA); prepStmt.setInt(1, tenantId); prepStmt.setString(2, userName); prepStmt.setString(3, key); prepStmt.setString(4, value); prepStmt.execute(); connection.commit(); } finally { IdentityDatabaseUtil.closeStatement(prepStmt); IdentityDatabaseUtil.closeConnection(connection); } }
private void addUserDataValue(String userName, int tenantId, String key, String value) throws SQLException { Connection connection = IdentityDatabaseUtil.getDBConnection(); PreparedStatement prepStmt = null; try { prepStmt = connection.prepareStatement(SQLQuery.STORE_USER_DATA); prepStmt.setInt(1, tenantId); prepStmt.setString(2, userName); prepStmt.setString(3, key); prepStmt.setString(4, value); prepStmt.execute(); connection.commit(); } finally { IdentityDatabaseUtil.closeStatement(prepStmt); IdentityDatabaseUtil.closeConnection(connection); } }
/** * Delete permission entry for a given id * * @param entry_id Entry id * @throws SQLException */ private void deletePermission(int entry_id) throws SQLException { PreparedStatement deletePermissionPrepStmt = null; Connection connection = null; try { connection = IdentityDatabaseUtil.getUserDBConnection(); deletePermissionPrepStmt = connection.prepareStatement(ApplicationMgtDBQueries.REMOVE_UM_PERMISSIONS); deletePermissionPrepStmt.setInt(1, entry_id); deletePermissionPrepStmt.executeUpdate(); } finally { IdentityApplicationManagementUtil.closeStatement(deletePermissionPrepStmt); IdentityDatabaseUtil.closeConnection(connection); } }
/** * Delete role permission mapping for a given permission id * * @param id Permission id * @throws SQLException */ private void deleteRolePermissionMapping(int id) throws SQLException { PreparedStatement deleteRolePermissionPrepStmt = null; Connection connection = null; try { connection = IdentityDatabaseUtil.getUserDBConnection(); deleteRolePermissionPrepStmt = connection.prepareStatement(ApplicationMgtDBQueries.REMOVE_UM_ROLE_PERMISSION); deleteRolePermissionPrepStmt.setInt(1, id); deleteRolePermissionPrepStmt.executeUpdate(); } finally { IdentityApplicationManagementUtil.closeStatement(deleteRolePermissionPrepStmt); IdentityDatabaseUtil.closeConnection(connection); } }
public static void closeAllConnections(Connection dbConnection, ResultSet rs, PreparedStatement prepStmt) { closeResultSet(rs); closeStatement(prepStmt); closeConnection(dbConnection); }
public static void closeAllConnections(Connection dbConnection, ResultSet rs, PreparedStatement prepStmt) { closeResultSet(rs); closeStatement(prepStmt); closeConnection(dbConnection); }
public static void closeAllConnections(Connection dbConnection, ResultSet rs, PreparedStatement prepStmt) { closeResultSet(rs); closeStatement(prepStmt); closeConnection(dbConnection); }
@Override public void invalidate(String code) throws IdentityException { Connection connection = IdentityDatabaseUtil.getDBConnection(); PreparedStatement prepStmt = null; try { prepStmt = connection.prepareStatement(SQLQuery.INVALIDATE_METADATA_FROM_CODE); prepStmt.setString(1, code.toLowerCase()); prepStmt.execute(); connection.commit(); } catch (SQLException e) { throw IdentityException.error("Error while invalidating user identity data for code: " + code, e); } finally { IdentityDatabaseUtil.closeStatement(prepStmt); IdentityDatabaseUtil.closeConnection(connection); } }
@Override public void invalidate(String code) throws IdentityRecoveryException { PreparedStatement prepStmt = null; Connection connection = IdentityDatabaseUtil.getDBConnection(); try { String sql = IdentityRecoveryConstants.SQLQueries.INVALIDATE_CODE; prepStmt = connection.prepareStatement(sql); prepStmt.setString(1, code); prepStmt.execute(); connection.commit(); } catch (SQLException e) { throw Utils.handleServerException(IdentityRecoveryConstants.ErrorMessages.ERROR_CODE_UNEXPECTED, null, e); } finally { IdentityDatabaseUtil.closeStatement(prepStmt); IdentityDatabaseUtil.closeConnection(connection); } }
public void deactivateAuthorizationCode(AuthzCodeDO authzCodeDO) throws IdentityOAuth2Exception { Connection connection = IdentityDatabaseUtil.getDBConnection(); try { deactivateAuthorizationCode(authzCodeDO, connection); connection.commit(); } catch (SQLException e) { throw new IdentityOAuth2Exception("Error when deactivating authorization code", e); } finally { IdentityDatabaseUtil.closeConnection(connection); } }
public void deactivateAuthorizationCode(AuthzCodeDO authzCodeDO) throws IdentityOAuth2Exception { Connection connection = IdentityDatabaseUtil.getDBConnection(); try { deactivateAuthorizationCode(authzCodeDO, connection); connection.commit(); } catch (SQLException e) { throw new IdentityOAuth2Exception("Error when deactivating authorization code", e); } finally { IdentityDatabaseUtil.closeConnection(connection); } }
public void addClaimDialect(ClaimDialect claimDialect, int tenantId) throws ClaimMetadataException { Connection connection = IdentityDatabaseUtil.getDBConnection(); PreparedStatement prepStmt = null; String query = SQLConstants.ADD_CLAIM_DIALECT; try { prepStmt = connection.prepareStatement(query); prepStmt.setString(1, claimDialect.getClaimDialectURI()); prepStmt.setInt(2, tenantId); prepStmt.executeUpdate(); connection.commit(); } catch (SQLException e) { throw new ClaimMetadataException("Error while adding claim dialect " + claimDialect .getClaimDialectURI(), e); } finally { IdentityDatabaseUtil.closeStatement(prepStmt); IdentityDatabaseUtil.closeConnection(connection); } }
public void addClaimDialect(ClaimDialect claimDialect, int tenantId) throws ClaimMetadataException { Connection connection = IdentityDatabaseUtil.getDBConnection(); PreparedStatement prepStmt = null; String query = SQLConstants.ADD_CLAIM_DIALECT; try { prepStmt = connection.prepareStatement(query); prepStmt.setString(1, claimDialect.getClaimDialectURI()); prepStmt.setInt(2, tenantId); prepStmt.executeUpdate(); connection.commit(); } catch (SQLException e) { throw new ClaimMetadataException("Error while adding claim dialect " + claimDialect .getClaimDialectURI(), e); } finally { IdentityDatabaseUtil.closeStatement(prepStmt); IdentityDatabaseUtil.closeConnection(connection); } }
public void removeClaimDialect(ClaimDialect claimDialect, int tenantId) throws ClaimMetadataException { Connection connection = IdentityDatabaseUtil.getDBConnection(); PreparedStatement prepStmt = null; String query = SQLConstants.REMOVE_CLAIM_DIALECT; try { prepStmt = connection.prepareStatement(query); prepStmt.setString(1, claimDialect.getClaimDialectURI()); prepStmt.setInt(2, tenantId); prepStmt.executeUpdate(); connection.commit(); } catch (SQLException e) { throw new ClaimMetadataException("Error while deleting claim dialect " + claimDialect .getClaimDialectURI(), e); } finally { IdentityDatabaseUtil.closeStatement(prepStmt); IdentityDatabaseUtil.closeConnection(connection); } } }
public void addClaimDialect(ClaimDialect claimDialect, int tenantId) throws ClaimMetadataException { Connection connection = IdentityDatabaseUtil.getDBConnection(); PreparedStatement prepStmt = null; String query = SQLConstants.ADD_CLAIM_DIALECT; try { prepStmt = connection.prepareStatement(query); prepStmt.setString(1, claimDialect.getClaimDialectURI()); prepStmt.setInt(2, tenantId); prepStmt.executeUpdate(); connection.commit(); } catch (SQLException e) { throw new ClaimMetadataException("Error while adding claim dialect " + claimDialect .getClaimDialectURI(), e); } finally { IdentityDatabaseUtil.closeStatement(prepStmt); IdentityDatabaseUtil.closeConnection(connection); } }
public void renameClaimDialect(ClaimDialect oldClaimDialect, ClaimDialect newClaimDialect, int tenantId) throws ClaimMetadataException { Connection connection = IdentityDatabaseUtil.getDBConnection(); PreparedStatement prepStmt = null; String query = SQLConstants.UPDATE_CLAIM_DIALECT; try { prepStmt = connection.prepareStatement(query); prepStmt.setString(1, newClaimDialect.getClaimDialectURI()); prepStmt.setString(2, oldClaimDialect.getClaimDialectURI()); prepStmt.setInt(3, tenantId); prepStmt.executeUpdate(); connection.commit(); } catch (SQLException e) { throw new ClaimMetadataException("Error while renaming claim dialect " + oldClaimDialect .getClaimDialectURI(), e); } finally { IdentityDatabaseUtil.closeStatement(prepStmt); IdentityDatabaseUtil.closeConnection(connection); } }