CryptPasswordStorageScheme.java revision d1da51a3ced79e0dba9bf146328497b5f01900ee
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the fields enclosed
* by brackets "[]" replaced with your own identifying information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Portions Copyright 2007 Sun Microsystems, Inc.
*/
/**
* This class defines a Directory Server password storage scheme based on the
* UNIX Crypt algorithm. This is a legacy one-way digest algorithm
* intended only for situations where passwords have not yet been
* updated to modern hashes such as SHA-1 and friends. This
* implementation does perform weak salting, which means that it is more
* vulnerable to dictionary attacks than schemes with larger salts.
*/
public class CryptPasswordStorageScheme
extends PasswordStorageScheme
{
/**
* The fully-qualified name of this class for debugging purposes.
*/
private static final String CLASS_NAME =
"org.opends.server.extensions.CryptPasswordStorageScheme";
/**
* An array of values that can be used to create salt characters
* when encoding new crypt hashes.
* */
private static final byte[] SALT_CHARS =
("./0123456789abcdefghijklmnopqrstuvwxyz"
+"ABCDEFGHIJKLMNOPQRSTUVWXYZ").getBytes();
/**
* Creates a new instance of this password storage scheme. Note that no
* initialization should be performed here, as all initialization should be
* done in the <CODE>initializePasswordStorageScheme</CODE> method.
*/
public CryptPasswordStorageScheme()
{
super();
}
/**
* {@inheritDoc}
*/
@Override()
public void initializePasswordStorageScheme(
throws ConfigException, InitializationException {
// Nothing to configure
}
/**
* {@inheritDoc}
*/
@Override()
public String getStorageSchemeName()
{
return STORAGE_SCHEME_NAME_CRYPT;
}
/**
* {@inheritDoc}
*/
@Override()
throws DirectoryException
{
byte[] digestBytes;
try
{
}
catch (Exception e)
{
}
}
/**
* Return a random 2-byte salt.
*
* @return a random 2-byte salt
*/
private byte[] randomSalt() {
try {
byte[] salt = new byte[2];
return salt;
} finally {
}
}
/**
* {@inheritDoc}
*/
@Override()
throws DirectoryException
{
}
/**
* {@inheritDoc}
*/
@Override()
{
byte[] userPWDigestBytes;
try
{
// The salt is stored as the first two bytes of the storedPassword
// value, and crypt.crypt() only looks at the first two bytes, so
// we can pass it in directly.
byte[] salt = storedPWDigestBytes;
}
catch (Exception e)
{
return false;
}
}
/**
* {@inheritDoc}
*/
@Override()
public boolean supportsAuthPasswordSyntax()
{
// This storage scheme does not support the authentication password syntax.
return false;
}
/**
* {@inheritDoc}
*/
@Override()
throws DirectoryException
{
msgID);
}
/**
* {@inheritDoc}
*/
@Override()
{
// This storage scheme does not support the authentication password syntax.
return false;
}
/**
* {@inheritDoc}
*/
@Override()
public boolean isReversible()
{
return false;
}
/**
* {@inheritDoc}
*/
@Override()
throws DirectoryException
{
msgID);
}
/**
* {@inheritDoc}
*/
@Override()
throws DirectoryException
{
msgID);
}
/**
* {@inheritDoc}
*/
@Override()
public boolean isStorageSchemeSecure()
{
// FIXME:
// Technically, this isn't quite in keeping with the original spirit of
// this method, since the point was to determine whether the scheme could
// be trivially reversed. I'm not sure I would put crypt into that
// category, but it's certainly a lot more vulnerable to lookup tables
// than most other algorithms. I'd say we can keep it this way for now,
// but it might be something to reconsider later.
//
// Currently, this method is unused. However, the intended purpose is
// eventually for use in issue #321, where we could do things like prevent
// even authorized users from seeing the password value over an insecure
// connection if it isn't considered secure.
return false;
}
}