public final int compareTo(Identity identity) { return getPrincipalName().compareTo(identity.getPrincipalName()); }
/** * Very inefficient default implementation. It is highly recommended * sub-classes override this. * * @param name * @return identity * @see {@link Connector#getIdentityByName(String)} * @throws PrincipalNotFoundException * @throws {@link ConnectorException} */ public Identity getIdentityByName(String name) throws PrincipalNotFoundException, ConnectorException { for (Iterator<Identity> identityIterator = allIdentities(); identityIterator.hasNext();) { Identity identity = identityIterator.next(); if (identity.getPrincipalName().equals(name)) { return identity; } } throw new PrincipalNotFoundException(name + " not found."); }
private void assertValidCredentials(Identity identity, char[] password) throws ConnectorException, InvalidLoginCredentialsException { if (!areCredentialsValid(identity, password)) { throw new InvalidLoginCredentialsException("Invalid username or password: '" + identity.getPrincipalName() + "'"); } }
@Override public Identity createIdentity(Identity identity, char[] password) throws ConnectorException { String encodedPassword = new String(encoderManager.encode(password, configuration.getIdentityPasswordEncoding(), configuration.getCharset(), null, null)); Statement statement = null; ResultSet resultSet = null; try { statement = connect.createStatement(); String sql = configuration.getCreateSQL(identity, encodedPassword, new String(password)); statement.executeUpdate(sql); } catch (SQLException e) { throw new ConnectorException(e); } finally { closeStatement(statement); closeResultSet(resultSet); } return getIdentityByName(identity.getPrincipalName()); }
return resultSet.next(); } else { sql = configuration.getSelectIdentitySQL(identity.getPrincipalName()); resultSet = statement.executeQuery(sql); if (resultSet.next()) {