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); } }
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); } }
/** * */ @Override public void removeOAuthApplication(String clientIdentifier) throws IdentityApplicationManagementException { Connection connection = IdentityDatabaseUtil.getDBConnection(); PreparedStatement prepStmt = null; try { prepStmt = connection.prepareStatement(ApplicationMgtDBQueries.REMOVE_OAUTH_APPLICATION); prepStmt.setString(1, clientIdentifier); prepStmt.execute(); connection.commit(); } catch (SQLException e) { log.error("Error when executing the SQL : " + ApplicationMgtDBQueries.REMOVE_OAUTH_APPLICATION); log.error(e.getMessage(), e); throw new IdentityApplicationManagementException("Error removing the consumer application."); } finally { IdentityDatabaseUtil.closeAllConnections(connection, null, prepStmt); } }
public String findScopeOfResource(String resourceUri) throws IdentityOAuth2Exception { Connection connection = IdentityDatabaseUtil.getDBConnection();; PreparedStatement ps = null; ResultSet rs = null; try { String sql = SQLQueries.RETRIEVE_IOS_SCOPE_KEY; ps = connection.prepareStatement(sql); ps.setString(1, resourceUri); rs = ps.executeQuery(); if (rs.next()) { return rs.getString("SCOPE_KEY"); } connection.commit(); return null; } catch (SQLException e) { String errorMsg = "Error getting scopes for resource - " + resourceUri + " : " + e.getMessage(); throw new IdentityOAuth2Exception(errorMsg, e); } finally { IdentityDatabaseUtil.closeAllConnections(connection, rs, ps); } }
/** * */ @Override public void removeOAuthApplication(String clientIdentifier) throws IdentityApplicationManagementException { Connection connection = IdentityDatabaseUtil.getDBConnection(); PreparedStatement prepStmt = null; try { prepStmt = connection.prepareStatement(ApplicationMgtDBQueries.REMOVE_OAUTH_APPLICATION); prepStmt.setString(1, clientIdentifier); prepStmt.execute(); connection.commit(); } catch (SQLException e) { log.error("Error when executing the SQL : " + ApplicationMgtDBQueries.REMOVE_OAUTH_APPLICATION); log.error(e.getMessage(), e); throw new IdentityApplicationManagementException("Error removing the consumer application."); } finally { IdentityDatabaseUtil.closeAllConnections(connection, null, prepStmt); } }
private String getCallbackURLOfApp(String consumerKey) throws IdentityOAuthAdminException { String callbackURL = null; Connection connection = IdentityDatabaseUtil.getDBConnection(); PreparedStatement prepStmt = null; ResultSet resultSet = null; try { prepStmt = connection.prepareStatement(SQLQueries.OAuthConsumerDAOSQLQueries.GET_REGISTERED_CALLBACK_URL); prepStmt.setString(1, consumerKey); resultSet = prepStmt.executeQuery(); if (resultSet.next()) { callbackURL = resultSet.getString(1); } connection.commit(); } catch (SQLException e) { throw new IdentityOAuthAdminException("Error when reading the callback url for consumer key : " + consumerKey, e); } finally { IdentityDatabaseUtil.closeAllConnections(connection, resultSet, prepStmt); } return callbackURL; }
private String getCallbackURLOfReqToken(String oauthToken) throws IdentityOAuthAdminException { String callbackURL = null; Connection connection = IdentityDatabaseUtil.getDBConnection(); PreparedStatement prepStmt = null; ResultSet resultSet = null; try { prepStmt = connection.prepareStatement(SQLQueries.OAuthConsumerDAOSQLQueries.GET_CALLBACK_URL_OF_REQ_TOKEN); prepStmt.setString(1, oauthToken); resultSet = prepStmt.executeQuery(); if (resultSet.next()) { callbackURL = resultSet.getString(1); } connection.commit(); } catch (SQLException e) { throw new IdentityOAuthAdminException("Error when reading the callback url for OAuth Token : " + oauthToken, e); } finally { IdentityDatabaseUtil.closeAllConnections(connection, resultSet, prepStmt); } return callbackURL; }
private String getCallbackURLOfReqToken(String oauthToken) throws IdentityOAuthAdminException { String callbackURL = null; Connection connection = IdentityDatabaseUtil.getDBConnection(); PreparedStatement prepStmt = null; ResultSet resultSet = null; try { prepStmt = connection.prepareStatement(SQLQueries.OAuthConsumerDAOSQLQueries.GET_CALLBACK_URL_OF_REQ_TOKEN); prepStmt.setString(1, oauthToken); resultSet = prepStmt.executeQuery(); if (resultSet.next()) { callbackURL = resultSet.getString(1); } connection.commit(); } catch (SQLException e) { throw new IdentityOAuthAdminException("Error when reading the callback url for OAuth Token : " + oauthToken, e); } finally { IdentityDatabaseUtil.closeAllConnections(connection, resultSet, prepStmt); } return callbackURL; }
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); } }
/** * * @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(); connection.commit(); } catch (SQLException e) { throw new InternalWorkflowException(errorMessage, e); } finally { IdentityDatabaseUtil.closeAllConnections(connection, null, prepStmt); } }
/** * * @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(); connection.commit(); } catch (SQLException e) { throw new InternalWorkflowException(errorMessage, e); } finally { IdentityDatabaseUtil.closeAllConnections(connection, null, prepStmt); } }
/** * Delete existing relationships of a request. * * @param uuid * @throws InternalWorkflowException */ public void deleteRelationshipsOfRequest(String uuid) throws InternalWorkflowException { Connection connection = IdentityDatabaseUtil.getDBConnection(); PreparedStatement prepStmt = null; String query = SQLConstants.DELETE_REQUEST_ENTITY_RELATIONSHIP; try { prepStmt = connection.prepareStatement(query); prepStmt.setString(1, uuid); prepStmt.executeUpdate(); connection.commit(); } catch (SQLException e) { throw new InternalWorkflowException("Error when executing the sql query", e); } finally { IdentityDatabaseUtil.closeAllConnections(connection, null, prepStmt); } }
/** * 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); } }
public void renameTenantRole(String newRoleName, String oldRoleName, int tenantId, String tenantDomain) throws IdentityProviderManagementException { Connection dbConnection = IdentityDatabaseUtil.getDBConnection(); PreparedStatement prepStmt = null; try { String sqlStmt = IdPManagementConstants.SQLQueries.RENAME_ROLE_LISTENER_SQL; prepStmt = dbConnection.prepareStatement(sqlStmt); prepStmt.setString(1, newRoleName); prepStmt.setInt(2, tenantId); prepStmt.setString(3, oldRoleName); prepStmt.executeUpdate(); dbConnection.commit(); } catch (SQLException e) { IdentityApplicationManagementUtil.rollBack(dbConnection); throw new IdentityProviderManagementException("Error occurred while renaming tenant role " + oldRoleName + " to " + newRoleName + " of tenant " + tenantDomain, e); } finally { IdentityDatabaseUtil.closeAllConnections(dbConnection, null, prepStmt); } }
private void deactivateAuthorizationCode(AuthzCodeDO authzCodeDO, Connection connection) throws IdentityOAuth2Exception { PreparedStatement prepStmt = null; try { prepStmt = connection.prepareStatement(SQLQueries.DEACTIVATE_AUTHZ_CODE_AND_INSERT_CURRENT_TOKEN); prepStmt.setString(1, authzCodeDO.getOauthTokenId()); prepStmt.setString(2, persistenceProcessor.getPreprocessedAuthzCode(authzCodeDO.getAuthorizationCode())); prepStmt.executeUpdate(); } catch (SQLException e) { throw new IdentityOAuth2Exception("Error when deactivating authorization code", e); } finally { IdentityDatabaseUtil.closeAllConnections(null, null, prepStmt); } }
public void deleteTenantRole(int tenantId, String role, String tenantDomain) throws IdentityProviderManagementException { Connection dbConnection = IdentityDatabaseUtil.getDBConnection(); PreparedStatement prepStmt = null; try { String sqlStmt = IdPManagementConstants.SQLQueries.DELETE_ROLE_LISTENER_SQL; prepStmt = dbConnection.prepareStatement(sqlStmt); prepStmt.setInt(1, tenantId); prepStmt.setString(2, role); prepStmt.executeUpdate(); dbConnection.commit(); } catch (SQLException e) { IdentityApplicationManagementUtil.rollBack(dbConnection); throw new IdentityProviderManagementException("Error occurred while deleting tenant role " + role + " of tenant " + tenantDomain, e); } finally { IdentityDatabaseUtil.closeAllConnections(dbConnection, null, prepStmt); } }
public void deactivateAuthorizationCode(List<AuthzCodeDO> authzCodeDOs) throws IdentityOAuth2Exception { Connection connection = IdentityDatabaseUtil.getDBConnection(); PreparedStatement prepStmt = null; try { prepStmt = connection.prepareStatement(SQLQueries.DEACTIVATE_AUTHZ_CODE_AND_INSERT_CURRENT_TOKEN); for (AuthzCodeDO authzCodeDO : authzCodeDOs){ prepStmt.setString(1, authzCodeDO.getOauthTokenId()); prepStmt.setString(2, persistenceProcessor.getPreprocessedAuthzCode(authzCodeDO.getAuthorizationCode())); prepStmt.addBatch(); } prepStmt.executeBatch(); connection.commit(); } catch (SQLException e) { throw new IdentityOAuth2Exception("Error when deactivating authorization code", e); } finally { IdentityDatabaseUtil.closeAllConnections(connection, null, prepStmt); } }
private void deactivateAuthorizationCode(AuthzCodeDO authzCodeDO, Connection connection) throws IdentityOAuth2Exception { if (log.isDebugEnabled() && IdentityUtil.isTokenLoggable(IdentityConstants.IdentityTokens.AUTHORIZATION_CODE)) { log.debug("Deactivating authorization code(hashed): " + DigestUtils.sha256Hex(authzCodeDO .getAuthorizationCode())); } PreparedStatement prepStmt = null; try { prepStmt = connection.prepareStatement(SQLQueries.DEACTIVATE_AUTHZ_CODE_AND_INSERT_CURRENT_TOKEN); prepStmt.setString(1, authzCodeDO.getOauthTokenId()); prepStmt.setString(2, hashingPersistenceProcessor.getProcessedAuthzCode(authzCodeDO.getAuthorizationCode())); prepStmt.executeUpdate(); } catch (SQLException e) { throw new IdentityOAuth2Exception("Error when deactivating authorization code", e); } finally { IdentityDatabaseUtil.closeAllConnections(null, null, prepStmt); } }