org.restlet.ext.crypto
Class DigestVerifier<T extends SecretVerifier>

java.lang.Object
  extended by org.restlet.security.SecretVerifier
      extended by org.restlet.ext.crypto.DigestVerifier<T>
All Implemented Interfaces:
Verifier

public class DigestVerifier<T extends SecretVerifier>
extends SecretVerifier

Wrapper verifier that can verify digested secrets. If the provided secret is a digest, then the local secret must either be a digest of the same algorithm or the wrapped verifier must be a LocalVerifier returning secrets in clear.

If the provided secret is a regular secret, then the local secret can be in any digest algorithm or a regular secret.

Author:
Jerome Louvel
See Also:
Digest, DigestAuthenticator

Field Summary
 
Fields inherited from interface org.restlet.security.Verifier
RESULT_INVALID, RESULT_MISSING, RESULT_STALE, RESULT_UNKNOWN, RESULT_UNSUPPORTED, RESULT_VALID
 
Constructor Summary
DigestVerifier(String algorithm, T wrappedVerifier, String wrappedAlgorithm)
          Constructor.
 
Method Summary
protected  char[] digest(String identifier, char[] secret, String algorithm)
          Computes the digest of a secret according to a specified algorithm.
 String getAlgorithm()
          Returns the digest algorithm of provided secrets.
 String getWrappedAlgorithm()
          Returns the digest algorithm of secrets returned by the wrapped verifier.
 char[] getWrappedSecret(String identifier)
          Returns the wrapped secret associated to a given identifier.
 char[] getWrappedSecretDigest(String identifier)
          Returns the digest of the wrapped secret associated to a given identifier.
 T getWrappedVerifier()
          Returns the wrapped secret verifier.
 void setAlgorithm(String algorithm)
          Sets the digest algorithm of provided secrets.
 void setWrappedAlgorithm(String wrappedAlgorithm)
          Sets the digest algorithm of secrets returned by the wrapped verifier.
 void setWrappedVerifier(T wrappedVerifier)
          Sets the wrapped secret verifier.
 int verify(String identifier, char[] secret)
           
 
Methods inherited from class org.restlet.security.SecretVerifier
compare, createUser, createUser, getIdentifier, getSecret, verify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DigestVerifier

public DigestVerifier(String algorithm,
                      T wrappedVerifier,
                      String wrappedAlgorithm)
Constructor.

Parameters:
algorithm - The digest algorithm of provided secrets.
wrappedVerifier - The wrapped secret verifier.
wrappedAlgorithm - The digest algorithm of secrets provided by the wrapped verifier.
See Also:
Digest
Method Detail

digest

protected char[] digest(String identifier,
                        char[] secret,
                        String algorithm)
Computes the digest of a secret according to a specified algorithm. By default, MD5 hashes (represented as a sequence of 32 hexadecimal digits) and SHA-1 hashes are supported. For additional algorithm, override this method.

Parameters:
identifier - The user identifier.
secret - The regular secret to digest.
algorithm - The digest algorithm to use.
Returns:
The digested secret.
See Also:
Digest

getAlgorithm

public String getAlgorithm()
Returns the digest algorithm of provided secrets. Provided secrets are the ones sent by clients when attempting to authenticate.

Returns:
The digest algorithm of input secrets.

getWrappedAlgorithm

public String getWrappedAlgorithm()
Returns the digest algorithm of secrets returned by the wrapped verifier. The secrets from the wrapped verifier are the ones used by the verifier to compare those sent by clients when attempting to authenticate.

Returns:
The digest algorithm of secrets returned by the wrapped verifier.

getWrappedSecret

public char[] getWrappedSecret(String identifier)
Returns the wrapped secret associated to a given identifier. This method can only be called if the wrapped verifier is a LocalVerifier.

Parameters:
identifier - The identifier to lookup.
Returns:
The secret associated to the identifier or null.

getWrappedSecretDigest

public char[] getWrappedSecretDigest(String identifier)
Returns the digest of the wrapped secret associated to a given identifier. If the wrapped algorithm is null it returns the digest of the wrapped secret, otherwise the algorithms must be identical. This method can only be called if the wrapped verifier is a LocalVerifier.

Parameters:
identifier - The identifier to lookup.
Returns:
The secret associated to the identifier or null.

getWrappedVerifier

public T getWrappedVerifier()
Returns the wrapped secret verifier.

Returns:
The wrapped secret verifier.

setAlgorithm

public void setAlgorithm(String algorithm)
Sets the digest algorithm of provided secrets. Provided secrets are the ones sent by clients when attempting to authenticate.

Parameters:
algorithm - The digest algorithm of secrets provided by the user.
See Also:
Digest

setWrappedAlgorithm

public void setWrappedAlgorithm(String wrappedAlgorithm)
Sets the digest algorithm of secrets returned by the wrapped verifier. The secrets from the wrapped verifier are the ones used by the verifier to compare those sent by clients when attempting to authenticate.

Parameters:
wrappedAlgorithm - The digest algorithm of secrets returned by the wrapped verifier.
See Also:
Digest

setWrappedVerifier

public void setWrappedVerifier(T wrappedVerifier)
Sets the wrapped secret verifier.

Parameters:
wrappedVerifier - The wrapped secret verifier.

verify

public int verify(String identifier,
                  char[] secret)
Specified by:
verify in class SecretVerifier


Copyright © 2005-2013 Restlet.