public AbstractJDBCRegistry(String envName, String jndiName) { try { Context initContext = new InitialContext(); Context envContext = (Context) initContext.lookup(envName); dataSource = (DataSource) envContext.lookup(jndiName); if (dataSource == null) { throw logger.datasourceIsNull(); } } catch (NamingException e) { throw logger.jbdcInitializationError(e); } }
public AbstractJDBCRegistry(String envName, String jndiName) { try { Context initContext = new InitialContext(); Context envContext = (Context) initContext.lookup(envName); dataSource = (DataSource) envContext.lookup(jndiName); if (dataSource == null) { throw logger.datasourceIsNull(); } } catch (NamingException e) { throw logger.jbdcInitializationError(e); } }
/** * @see SecurityTokenRegistry#removeToken(String) */ @Override public void removeToken(String tokenID) throws IOException { if (dataSource == null) { throw logger.datasourceIsNull(); } Connection conn = null; PreparedStatement preparedStatement = null; try { conn = dataSource.getConnection(); preparedStatement = conn.prepareStatement(DELETE_SQL); preparedStatement.setString(1, tokenID); preparedStatement.executeUpdate(); } catch (SQLException e) { throw new IOException(e); } finally { safeClose(preparedStatement); safeClose(conn); } }
/** * @see SecurityTokenRegistry#removeToken(String) */ public void removeToken(String tokenID) throws IOException { if (dataSource == null) { throw logger.datasourceIsNull(); } String deleteSQL = "DELETE FROM TOKEN_REGISTRY WHERE TOKEN_ID = ?"; Connection conn = null; PreparedStatement preparedStatement = null; try { conn = dataSource.getConnection(); preparedStatement = conn.prepareStatement(deleteSQL); preparedStatement.setString(1, tokenID); preparedStatement.executeUpdate(); } catch (SQLException e) { throw new IOException(e); } finally { safeClose(preparedStatement); safeClose(conn); } }
/** * @see SecurityTokenRegistry#removeToken(String) */ public void removeToken(String tokenID) throws IOException { if (dataSource == null) { throw logger.datasourceIsNull(); } String deleteSQL = "DELETE FROM TOKEN_REGISTRY WHERE TOKEN_ID = ?"; Connection conn = null; PreparedStatement preparedStatement = null; try { conn = dataSource.getConnection(); preparedStatement = conn.prepareStatement(deleteSQL); preparedStatement.setString(1, tokenID); preparedStatement.executeUpdate(); } catch (SQLException e) { throw new IOException(e); } finally { safeClose(preparedStatement); safeClose(conn); } }
/** * @see SecurityTokenRegistry#removeToken(String) */ @Override public void removeToken(String tokenID) throws IOException { if (dataSource == null) { throw logger.datasourceIsNull(); } Connection conn = null; PreparedStatement preparedStatement = null; try { conn = dataSource.getConnection(); preparedStatement = conn.prepareStatement(DELETE_SQL); preparedStatement.setString(1, tokenID); preparedStatement.executeUpdate(); } catch (SQLException e) { throw new IOException(e); } finally { safeClose(preparedStatement); safeClose(conn); } }
private String getLOB(String tokenID) throws IOException { if (dataSource == null) { throw logger.datasourceIsNull(); } String selectSQL = "select TOKEN from TOKEN_REGISTRY where TOKEN_ID = ?"; Connection conn = null; PreparedStatement preparedStatement = null; ResultSet resultSet = null; try { conn = dataSource.getConnection(); preparedStatement = conn.prepareStatement(selectSQL); preparedStatement.setString(1, tokenID); resultSet = preparedStatement.executeQuery(); return resultSet.getString(1); } catch (SQLException e) { throw new IOException(e); } finally { safeClose(resultSet); safeClose(preparedStatement); safeClose(conn); } } }
/** * @see SecurityTokenRegistry#addToken(String, Object) */ public void addToken(String tokenID, Object token) throws IOException { if (dataSource == null) { throw logger.datasourceIsNull(); } String insertTableSQL = "INSERT INTO TOKEN_REGISTRY" + "(TOKEN_ID, TOKEN, CREATED_DATE) VALUES" + "(?,?,?)"; Connection conn = null; PreparedStatement preparedStatement = null; try { conn = dataSource.getConnection(); Date tokenCreationDate = Calendar.getInstance().getTime(); byte[] marshalledToken = marshallToken(token); String theToken = new String(marshalledToken, "UTF-8"); preparedStatement = conn.prepareStatement(insertTableSQL); preparedStatement.setString(1, tokenID); preparedStatement.setString(2, theToken); preparedStatement.setTimestamp(3, new Timestamp(tokenCreationDate.getTime())); preparedStatement.executeUpdate(); } catch (SQLException e) { throw new IOException(e); } finally { safeClose(preparedStatement); safeClose(conn); } }
/** * @see RevocationRegistry#revokeToken(String, String) */ public void revokeToken(String tokenType, String tokenID) { if (dataSource == null) { throw logger.datasourceIsNull(); } Connection conn = null; PreparedStatement preparedStatement = null; try { conn = dataSource.getConnection(); Date tokenCreationDate = Calendar.getInstance().getTime(); preparedStatement = conn.prepareStatement(INSERT_TABLE_SQL); preparedStatement.setString(1, tokenID); preparedStatement.setString(2, tokenType); preparedStatement .setTimestamp(3, new Timestamp(tokenCreationDate.getTime()), Calendar.getInstance(TimeZone.getTimeZone("UTC"))); preparedStatement.executeUpdate(); } catch (SQLException e) { throw logger.runtimeException("revokeToken", e); } finally { safeClose(preparedStatement); safeClose(conn); } } }
/** * @see SecurityTokenRegistry#addToken(String, Object) */ @Override public void addToken(String tokenID, Object token) throws IOException { if (dataSource == null) { throw logger.datasourceIsNull(); } Connection conn = null; PreparedStatement preparedStatement = null; try { byte[] marshalledToken = marshallToken(token); conn = dataSource.getConnection(); Date tokenCreationDate = Calendar.getInstance().getTime(); preparedStatement = conn.prepareStatement(INSERT_SQL); preparedStatement.setString(1, tokenID); preparedStatement.setBytes(2, marshalledToken); preparedStatement .setTimestamp(3, new Timestamp(tokenCreationDate.getTime()), Calendar.getInstance(TimeZone.getTimeZone("UTC"))); preparedStatement.executeUpdate(); } catch (SQLException e) { throw new IOException(e); } finally { safeClose(preparedStatement); safeClose(conn); } }
/** * @see RevocationRegistry#revokeToken(String, String) */ public void revokeToken(String tokenType, String tokenID) { if (dataSource == null) { throw logger.datasourceIsNull(); } String insertTableSQL = "INSERT INTO REVOCATION_REGISTRY" + "(TOKEN_ID, TOKEN_TYPE, CREATED_DATE) VALUES" + "(?,?,?)"; Connection conn = null; PreparedStatement preparedStatement = null; try { conn = dataSource.getConnection(); Date tokenCreationDate = Calendar.getInstance().getTime(); preparedStatement = conn.prepareStatement(insertTableSQL); preparedStatement.setString(1, tokenID); preparedStatement.setString(2, tokenType); preparedStatement.setTimestamp(3, new Timestamp(tokenCreationDate.getTime())); preparedStatement.executeUpdate(); } catch (SQLException e) { throw logger.runtimeException("revokeToken", e); } finally { safeClose(preparedStatement); safeClose(conn); } } }
/** * @see SecurityTokenRegistry#addToken(String, Object) */ public void addToken(String tokenID, Object token) throws IOException { if (dataSource == null) { throw logger.datasourceIsNull(); } String insertTableSQL = "INSERT INTO TOKEN_REGISTRY" + "(TOKEN_ID, TOKEN, CREATED_DATE) VALUES" + "(?,?,?)"; Connection conn = null; PreparedStatement preparedStatement = null; try { conn = dataSource.getConnection(); Date tokenCreationDate = Calendar.getInstance().getTime(); byte[] marshalledToken = marshallToken(token); String theToken = new String(marshalledToken, "UTF-8"); preparedStatement = conn.prepareStatement(insertTableSQL); preparedStatement.setString(1, tokenID); preparedStatement.setString(2, theToken); preparedStatement.setTimestamp(3, new Timestamp(tokenCreationDate.getTime())); preparedStatement.executeUpdate(); } catch (SQLException e) { throw new IOException(e); } finally { safeClose(preparedStatement); safeClose(conn); } }
/** * @see RevocationRegistry#revokeToken(String, String) */ public void revokeToken(String tokenType, String tokenID) { if (dataSource == null) { throw logger.datasourceIsNull(); } Connection conn = null; PreparedStatement preparedStatement = null; try { conn = dataSource.getConnection(); Date tokenCreationDate = Calendar.getInstance().getTime(); preparedStatement = conn.prepareStatement(INSERT_TABLE_SQL); preparedStatement.setString(1, tokenID); preparedStatement.setString(2, tokenType); preparedStatement .setTimestamp(3, new Timestamp(tokenCreationDate.getTime()), Calendar.getInstance(TimeZone.getTimeZone("UTC"))); preparedStatement.executeUpdate(); } catch (SQLException e) { throw logger.runtimeException("revokeToken", e); } finally { safeClose(preparedStatement); safeClose(conn); } } }
/** * @see RevocationRegistry#revokeToken(String, String) */ public void revokeToken(String tokenType, String tokenID) { if (dataSource == null) { throw logger.datasourceIsNull(); } String insertTableSQL = "INSERT INTO REVOCATION_REGISTRY" + "(TOKEN_ID, TOKEN_TYPE, CREATED_DATE) VALUES" + "(?,?,?)"; Connection conn = null; PreparedStatement preparedStatement = null; try { conn = dataSource.getConnection(); Date tokenCreationDate = Calendar.getInstance().getTime(); preparedStatement = conn.prepareStatement(insertTableSQL); preparedStatement.setString(1, tokenID); preparedStatement.setString(2, tokenType); preparedStatement.setTimestamp(3, new Timestamp(tokenCreationDate.getTime())); preparedStatement.executeUpdate(); } catch (SQLException e) { throw logger.runtimeException("revokeToken", e); } finally { safeClose(preparedStatement); safeClose(conn); } } }
/** * @see SecurityTokenRegistry#addToken(String, Object) */ @Override public void addToken(String tokenID, Object token) throws IOException { if (dataSource == null) { throw logger.datasourceIsNull(); } Connection conn = null; PreparedStatement preparedStatement = null; try { byte[] marshalledToken = marshallToken(token); conn = dataSource.getConnection(); Date tokenCreationDate = Calendar.getInstance().getTime(); preparedStatement = conn.prepareStatement(INSERT_SQL); preparedStatement.setString(1, tokenID); preparedStatement.setBytes(2, marshalledToken); preparedStatement .setTimestamp(3, new Timestamp(tokenCreationDate.getTime()), Calendar.getInstance(TimeZone.getTimeZone("UTC"))); preparedStatement.executeUpdate(); } catch (SQLException e) { throw new IOException(e); } finally { safeClose(preparedStatement); safeClose(conn); } }
private String getLOB(String tokenID) throws IOException { if (dataSource == null) { throw logger.datasourceIsNull(); } String selectSQL = "select TOKEN from TOKEN_REGISTRY where TOKEN_ID = ?"; Connection conn = null; PreparedStatement preparedStatement = null; ResultSet resultSet = null; try { conn = dataSource.getConnection(); preparedStatement = conn.prepareStatement(selectSQL); preparedStatement.setString(1, tokenID); resultSet = preparedStatement.executeQuery(); return resultSet.getString(1); } catch (SQLException e) { throw new IOException(e); } finally { safeClose(resultSet); safeClose(preparedStatement); safeClose(conn); } } }
/** * @see RevocationRegistry#isRevoked(String, String) */ public boolean isRevoked(String tokenType, String tokenID) { if (dataSource == null) { throw logger.datasourceIsNull(); } String existsTableSQL = "SELECT COUNT(*) FROM REVOCATION_REGISTRY WHERE TOKEN_ID =? AND TOKEN_TYPE = ?"; Connection conn = null; PreparedStatement preparedStatement = null; ResultSet resultSet = null; try { conn = dataSource.getConnection(); Date tokenCreationDate = Calendar.getInstance().getTime(); preparedStatement = conn.prepareStatement(existsTableSQL); preparedStatement.setString(1, tokenID); preparedStatement.setString(2, tokenType); resultSet = preparedStatement.executeQuery(); return resultSet.getInt(1) > 0; } catch (SQLException e) { throw logger.runtimeException("revokeToken", e); } finally { safeClose(resultSet); safeClose(preparedStatement); safeClose(conn); } }
/** * @see RevocationRegistry#isRevoked(String, String) */ public boolean isRevoked(String tokenType, String tokenID) { if (dataSource == null) { throw logger.datasourceIsNull(); } Connection conn = null; PreparedStatement preparedStatement = null; ResultSet resultSet = null; try { conn = dataSource.getConnection(); preparedStatement = conn.prepareStatement(EXISTS_TABLE_SQL); preparedStatement.setString(1, tokenID); preparedStatement.setString(2, tokenType); resultSet = preparedStatement.executeQuery(); return resultSet.getInt(1) > 0; } catch (SQLException e) { throw logger.runtimeException("revokeToken", e); } finally { safeClose(resultSet); safeClose(preparedStatement); safeClose(conn); } }
/** * @see RevocationRegistry#isRevoked(String, String) */ public boolean isRevoked(String tokenType, String tokenID) { if (dataSource == null) { throw logger.datasourceIsNull(); } Connection conn = null; PreparedStatement preparedStatement = null; ResultSet resultSet = null; try { conn = dataSource.getConnection(); preparedStatement = conn.prepareStatement(EXISTS_TABLE_SQL); preparedStatement.setString(1, tokenID); preparedStatement.setString(2, tokenType); resultSet = preparedStatement.executeQuery(); return resultSet.getInt(1) > 0; } catch (SQLException e) { throw logger.runtimeException("revokeToken", e); } finally { safeClose(resultSet); safeClose(preparedStatement); safeClose(conn); } }
/** * @see RevocationRegistry#isRevoked(String, String) */ public boolean isRevoked(String tokenType, String tokenID) { if (dataSource == null) { throw logger.datasourceIsNull(); } String existsTableSQL = "SELECT COUNT(*) FROM REVOCATION_REGISTRY WHERE TOKEN_ID =? AND TOKEN_TYPE = ?"; Connection conn = null; PreparedStatement preparedStatement = null; ResultSet resultSet = null; try { conn = dataSource.getConnection(); Date tokenCreationDate = Calendar.getInstance().getTime(); preparedStatement = conn.prepareStatement(existsTableSQL); preparedStatement.setString(1, tokenID); preparedStatement.setString(2, tokenType); resultSet = preparedStatement.executeQuery(); return resultSet.getInt(1) > 0; } catch (SQLException e) { throw logger.runtimeException("revokeToken", e); } finally { safeClose(resultSet); safeClose(preparedStatement); safeClose(conn); } }