/** * Get a database connection instance from the Identity Persistence Manager * @return Database Connection */ public static Connection getDBConnection(){ return IdentityDatabaseUtil.getDBConnection(); }
protected Connection getConnection() { return IdentityDatabaseUtil.getDBConnection(); }
public void updateConsumerAppState(String consumerKey, String state) throws IdentityApplicationManagementException { try (Connection connection = IdentityDatabaseUtil.getDBConnection(); PreparedStatement statement = connection.prepareStatement(SQLQueries.OAuthAppDAOSQLQueries.UPDATE_APPLICATION_STATE)) { statement.setString(1, state); statement.setString(2, consumerKey); statement.execute(); connection.commit(); } catch (SQLException e) { throw new IdentityApplicationManagementException("Error while executing the SQL statement.", e); } }
private void deleteRequestObjectReferenceforCode(String tokenId) throws IdentityOAuthAdminException { try (Connection connection = IdentityDatabaseUtil.getDBConnection(); PreparedStatement prepStmt = connection.prepareStatement(SQLQueries.DELETE_REQ_OBJECT_TOKEN_FOR_CODE)) { prepStmt.setString(1, tokenId); prepStmt.execute(); connection.commit(); } catch (SQLException e) { throw handleError("Can not delete existing entry for the same token id" + tokenId, e); } }
public void deleteRequestObjectReferenceByTokenId(String tokenId) throws IdentityOAuthAdminException { try (Connection connection = IdentityDatabaseUtil.getDBConnection(); PreparedStatement prepStmt = connection.prepareStatement(SQLQueries.DELETE_REQ_OBJECT_BY_TOKEN_ID)) { prepStmt.setString(1, tokenId); prepStmt.execute(); connection.commit(); } catch (SQLException e) { throw handleError("Error when executing the SQL : " + SQLQueries.DELETE_REQ_OBJECT_BY_TOKEN_ID, e); } }
public void deleteRequestObjectReferenceByCode(String codeId) throws IdentityOAuthAdminException { try (Connection connection = IdentityDatabaseUtil.getDBConnection(); PreparedStatement prepStmt = connection.prepareStatement(SQLQueries.DELETE_REQ_OBJECT_BY_CODE_ID)) { prepStmt.setString(1, codeId); prepStmt.execute(); connection.commit(); } catch (SQLException e) { throw handleError("Error when executing the SQL : " + SQLQueries.DELETE_REQ_OBJECT_BY_CODE_ID, e); } } }
public void removeConsumerApplication(String consumerKey) throws IdentityOAuthAdminException { Connection connection = IdentityDatabaseUtil.getDBConnection(); PreparedStatement prepStmt = null; try { prepStmt = connection.prepareStatement(SQLQueries.OAuthAppDAOSQLQueries.REMOVE_APPLICATION); prepStmt.setString(1, consumerKey); prepStmt.execute(); connection.commit(); } catch (SQLException e) {; throw new IdentityOAuthAdminException("Error when executing the SQL : " + SQLQueries.OAuthAppDAOSQLQueries.REMOVE_APPLICATION, e); } finally { IdentityDatabaseUtil.closeAllConnections(connection, null, prepStmt); } }
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); } }
public void removeWaitStatus(String waitKey) throws FrameworkException { String query = "DELETE FROM IDN_AUTH_WAIT_STATUS WHERE LONG_WAIT_KEY=?"; try (Connection connection = IdentityDatabaseUtil.getDBConnection()) { try (PreparedStatement addPrepStmt = connection.prepareStatement(query)) { addPrepStmt.setString(1, waitKey); addPrepStmt.execute(); if (log.isDebugEnabled()) { log.debug("Removed wait status for wait key: " + waitKey); } connection.commit(); } catch (SQLException e) { throw new FrameworkException("Error while removing wait status with key:" + waitKey, e); } } catch (SQLException e) { throw new FrameworkException("Error while removing wait status with key:" + waitKey, e); } }
public void updateSecretKey(String consumerKey, String newSecretKey) throws IdentityApplicationManagementException { PreparedStatement statement = null; Connection connection = null; try { connection = IdentityDatabaseUtil.getDBConnection(); statement = connection.prepareStatement(SQLQueries.OAuthAppDAOSQLQueries.UPDATE_OAUTH_SECRET_KEY); statement.setString(1, newSecretKey); statement.setString(2, consumerKey); statement.execute(); connection.commit(); } catch (SQLException e) { throw new IdentityApplicationManagementException("Error while executing the SQL statement.", e); } finally { IdentityDatabaseUtil.closeAllConnections(connection, null, statement); } }
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); } }
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); } }
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); } }
@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 removeConsumerApplication(String consumerKey) throws IdentityOAuthAdminException { try (Connection connection = IdentityDatabaseUtil.getDBConnection(); PreparedStatement prepStmt = connection.prepareStatement(SQLQueries.OAuthAppDAOSQLQueries.REMOVE_APPLICATION)) { prepStmt.setString(1, consumerKey); prepStmt.execute(); if (isOIDCAudienceEnabled()) { String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain(); removeOauthOIDCPropertyTable(connection, tenantDomain, consumerKey); } connection.commit(); } catch (SQLException e) { throw handleError("Error when executing the SQL : " + SQLQueries.OAuthAppDAOSQLQueries .REMOVE_APPLICATION, e); } }