| | |
| | | public void initializePasswordStorageScheme(ConfigEntry configEntry) |
| | | throws ConfigException, InitializationException |
| | | { |
| | | |
| | | try |
| | | { |
| | | messageDigest = MessageDigest.getInstance(MESSAGE_DIGEST_ALGORITHM_MD5); |
| | |
| | | @Override() |
| | | public String getStorageSchemeName() |
| | | { |
| | | |
| | | return STORAGE_SCHEME_NAME_SALTED_MD5; |
| | | } |
| | | |
| | |
| | | public ByteString encodePassword(ByteString plaintext) |
| | | throws DirectoryException |
| | | { |
| | | |
| | | byte[] plainBytes = plaintext.value(); |
| | | byte[] saltBytes = new byte[NUM_SALT_BYTES]; |
| | | byte[] plainPlusSalt = new byte[plainBytes.length + NUM_SALT_BYTES]; |
| | |
| | | public ByteString encodePasswordWithScheme(ByteString plaintext) |
| | | throws DirectoryException |
| | | { |
| | | |
| | | StringBuilder buffer = new StringBuilder(); |
| | | buffer.append('{'); |
| | | buffer.append(STORAGE_SCHEME_NAME_SALTED_MD5); |
| | |
| | | public boolean passwordMatches(ByteString plaintextPassword, |
| | | ByteString storedPassword) |
| | | { |
| | | |
| | | |
| | | // Base64-decode the stored value and take the last 8 bytes as the salt. |
| | | byte[] saltBytes = new byte[NUM_SALT_BYTES]; |
| | | byte[] digestBytes; |
| | |
| | | @Override() |
| | | public boolean supportsAuthPasswordSyntax() |
| | | { |
| | | |
| | | // This storage scheme does support the authentication password syntax. |
| | | return true; |
| | | } |
| | |
| | | @Override() |
| | | public String getAuthPasswordSchemeName() |
| | | { |
| | | |
| | | return AUTH_PASSWORD_SCHEME_NAME_SALTED_MD5; |
| | | } |
| | | |
| | |
| | | public ByteString encodeAuthPassword(ByteString plaintext) |
| | | throws DirectoryException |
| | | { |
| | | |
| | | |
| | | byte[] plainBytes = plaintext.value(); |
| | | byte[] saltBytes = new byte[NUM_SALT_BYTES]; |
| | | byte[] plainPlusSalt = new byte[plainBytes.length + NUM_SALT_BYTES]; |
| | |
| | | public boolean authPasswordMatches(ByteString plaintextPassword, |
| | | String authInfo, String authValue) |
| | | { |
| | | |
| | | |
| | | byte[] saltBytes; |
| | | byte[] digestBytes; |
| | | try |
| | |
| | | @Override() |
| | | public boolean isReversible() |
| | | { |
| | | |
| | | return false; |
| | | } |
| | | |
| | |
| | | public ByteString getPlaintextValue(ByteString storedPassword) |
| | | throws DirectoryException |
| | | { |
| | | |
| | | int msgID = MSGID_PWSCHEME_NOT_REVERSIBLE; |
| | | String message = getMessage(msgID, STORAGE_SCHEME_NAME_SALTED_MD5); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message, |
| | |
| | | String authValue) |
| | | throws DirectoryException |
| | | { |
| | | |
| | | int msgID = MSGID_PWSCHEME_NOT_REVERSIBLE; |
| | | String message = getMessage(msgID, AUTH_PASSWORD_SCHEME_NAME_SALTED_MD5); |
| | | throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message, |
| | |
| | | @Override() |
| | | public boolean isStorageSchemeSecure() |
| | | { |
| | | |
| | | // MD5 may be considered reasonably secure for this purpose. |
| | | return true; |
| | | } |