@Test public void testLookUpUserProperty() throws Exception { Authenticator authenticator = new Authenticator(connection); String username = "TestAccount1"; Object foo = authenticator.lookUpUserProperty(username, "Foo"); Assert.assertEquals(foo, "Bar"); }
public Object lookUpUserProperty(String username, String propertyName) throws SQLException { String propertyQuery = "SELECT * FROM " + PROPERTIES_TABLE + " " + "WHERE " + USER + " = ? AND " + PROPERTY_NAME + " = ?"; Object r = null; synchronized (dbConnection) { PreparedStatement statement = dbConnection.prepareStatement(propertyQuery); statement.setString(1, username); statement.setString(2, propertyName); ResultSet results = statement.executeQuery(); if (results.next()) { r = results.getObject(PROPERTY_VALUE); } } return r; }
Authenticator { public Object lookUpUserProperty(String username, String propertyName) throws SQLException { String propertyQuery = "SELECT * FROM " + PROPERTIES_TABLE + " " + "WHERE " + USER + " = ? AND " + PROPERTY_NAME + " = ?"; Object r = null; synchronized (dbConnection) { PreparedStatement statement = dbConnection.prepareStatement(propertyQuery); statement.setString(1, username); statement.setString(2, propertyName); ResultSet results = statement.executeQuery(); if (results.next()) { r = results.getObject(PROPERTY_VALUE); } } return r; } }
Authenticator { public Object lookUpUserProperty(String username, String propertyName) throws SQLException { String propertyQuery = "SELECT * FROM " + PROPERTIES_TABLE + " " + "WHERE " + USER + " = ? AND " + PROPERTY_NAME + " = ?"; Object r = null; synchronized (dbConnection) { PreparedStatement statement = dbConnection.prepareStatement(propertyQuery); statement.setString(1, username); statement.setString(2, propertyName); ResultSet results = statement.executeQuery(); if (results.next()) { r = results.getObject(PROPERTY_VALUE); } } return r; } Authenticator(Connection dbConnection); }
Authenticator { public Object lookUpUserProperty(String username, String propertyName) throws SQLException { String propertyQuery = "SELECT * FROM " + PROPERTIES_TABLE + " " + "WHERE " + USER + " = ? AND " + PROPERTY_NAME + " = ?"; Object r = null; synchronized (dbConnection) { PreparedStatement statement = dbConnection.prepareStatement(propertyQuery); statement.setString(1, username); statement.setString(2, propertyName); ResultSet results = statement.executeQuery(); if (results.next()) { r = results.getObject(PROPERTY_VALUE); } } return r; } Authenticator(Connection dbConnection); static String getSaltedSHA256String(String input, String salt); User logInUser(String username, String password); User lookUpUser(String username); Map<String, Object> lookUpUserProperties(String username); User logOutUser(String username); Object lookUpUserProperty(String username, String propertyName); static boolean isWrapperType(Class<?> clazz); }
Authenticator { public Object lookUpUserProperty(String username, String propertyName) throws SQLException { String propertyQuery = "SELECT * FROM " + PROPERTIES_TABLE + " " + "WHERE " + USER + " = ? AND " + PROPERTY_NAME + " = ?"; Object r = null; synchronized (dbConnection) { PreparedStatement statement = dbConnection.prepareStatement(propertyQuery); statement.setString(1, username); statement.setString(2, propertyName); ResultSet results = statement.executeQuery(); if (results.next()) { r = results.getObject(PROPERTY_VALUE); } } return r; } Authenticator(Connection dbConnection); static String getSaltedSHA256String(String input, String salt); User logInUser(String username, String password); User lookUpUser(String username); Map<String, Object> lookUpUserProperties(String username); User logOutUser(String username); Object lookUpUserProperty(String username, String propertyName); static boolean isWrapperType(Class<?> clazz); static final int HEX_CONVERSION_CONSTANT; }