FileDocCategorySizeDatePackage
MessageDigestAlgorithm.javaAPI DocJava SE 6 API8578Tue Jun 10 00:23:00 BST 2008com.sun.org.apache.xml.internal.security.algorithms

MessageDigestAlgorithm

public class MessageDigestAlgorithm extends Algorithm
Digest Message wrapper & selector class.
MessageDigestAlgorithm.getInstance()

Fields Summary
static Logger
log
{@link java.util.logging} logging facility
public static final String
ALGO_ID_DIGEST_NOT_RECOMMENDED_MD5
Message Digest - NOT RECOMMENDED MD5
public static final String
ALGO_ID_DIGEST_SHA1
Digest - Required SHA1
public static final String
ALGO_ID_DIGEST_SHA256
Message Digest - RECOMMENDED SHA256
public static final String
ALGO_ID_DIGEST_SHA384
Message Digest - OPTIONAL SHA384
public static final String
ALGO_ID_DIGEST_SHA512
Message Digest - OPTIONAL SHA512
public static final String
ALGO_ID_DIGEST_RIPEMD160
Message Digest - OPTIONAL RIPEMD-160
MessageDigest
algorithm
Field algorithm stores the actual {@link java.security.MessageDigest}
Constructors Summary
private MessageDigestAlgorithm(Document doc, MessageDigest messageDigest, String algorithmURI)
Constructor for the brave who pass their own message digest algorithms and the corresponding URI.

param
doc
param
messageDigest
param
algorithmURI


                            
       
                                    

      super(doc, algorithmURI);

      this.algorithm = messageDigest;
   
Methods Summary
public byte[]digest()
Proxy method for {@link java.security.MessageDigest#digest()} which is executed on the internal {@link java.security.MessageDigest} object.

return
the result of the {@link java.security.MessageDigest#digest()} method

      return this.algorithm.digest();
   
public byte[]digest(byte[] input)
Proxy method for {@link java.security.MessageDigest#digest(byte[])} which is executed on the internal {@link java.security.MessageDigest} object.

param
input
return
the result of the {@link java.security.MessageDigest#digest(byte[])} method

      return this.algorithm.digest(input);
   
public intdigest(byte[] buf, int offset, int len)
Proxy method for {@link java.security.MessageDigest#digest(byte[], int, int)} which is executed on the internal {@link java.security.MessageDigest} object.

param
buf
param
offset
param
len
return
the result of the {@link java.security.MessageDigest#digest(byte[], int, int)} method
throws
java.security.DigestException

      return this.algorithm.digest(buf, offset, len);
   
public java.security.MessageDigestgetAlgorithm()
Returns the actual {@link java.security.MessageDigest} algorithm object

return
the actual {@link java.security.MessageDigest} algorithm object

      return this.algorithm;
   
public java.lang.StringgetBaseLocalName()

inheritDoc

      return Constants._TAG_DIGESTMETHOD;
   
public java.lang.StringgetBaseNamespace()

inheritDoc

      return Constants.SignatureSpecNS;
   
public intgetDigestLength()
Proxy method for {@link java.security.MessageDigest#getDigestLength} which is executed on the internal {@link java.security.MessageDigest} object.

return
the result of the {@link java.security.MessageDigest#getDigestLength} method

      return this.algorithm.getDigestLength();
   
public static com.sun.org.apache.xml.internal.security.algorithms.MessageDigestAlgorithmgetInstance(org.w3c.dom.Document doc, java.lang.String algorithmURI)
Factory method for constructing a message digest algorithm by name.

param
doc
param
algorithmURI
return
The MessageDigestAlgorithm element to attach in document and to digest
throws
XMLSignatureException


      String algorithmID = JCEMapper.translateURItoJCEID(algorithmURI);

	  if (algorithmID == null) {
		  Object[] exArgs = { algorithmURI };
		  throw new XMLSignatureException("algorithms.NoSuchMap", exArgs);
	  }

      MessageDigest md;
      String provider=JCEMapper.getProviderId();
      try {      	
      	 if (provider==null) {
      	 	md = MessageDigest.getInstance(algorithmID);
      	 } else {
      	 	md = MessageDigest.getInstance(algorithmID,provider);
      	 }
      } catch (java.security.NoSuchAlgorithmException ex) {
         Object[] exArgs = { algorithmID,
                             ex.getLocalizedMessage() };

         throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
      } catch (NoSuchProviderException ex) {
      	Object[] exArgs = { algorithmID,
      						ex.getLocalizedMessage() };
      	
      	throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
	}
      return new MessageDigestAlgorithm(doc, md, algorithmURI);
   
public java.lang.StringgetJCEAlgorithmString()
Proxy method for {@link java.security.MessageDigest#getAlgorithm} which is executed on the internal {@link java.security.MessageDigest} object.

return
the result of the {@link java.security.MessageDigest#getAlgorithm} method

      return this.algorithm.getAlgorithm();
   
public java.security.ProvidergetJCEProvider()
Proxy method for {@link java.security.MessageDigest#getProvider} which is executed on the internal {@link java.security.MessageDigest} object.

return
the result of the {@link java.security.MessageDigest#getProvider} method

      return this.algorithm.getProvider();
   
public static booleanisEqual(byte[] digesta, byte[] digestb)
Proxy method for {@link java.security.MessageDigest#isEqual} which is executed on the internal {@link java.security.MessageDigest} object.

param
digesta
param
digestb
return
the result of the {@link java.security.MessageDigest#isEqual} method

      return java.security.MessageDigest.isEqual(digesta, digestb);
   
public voidreset()
Proxy method for {@link java.security.MessageDigest#reset} which is executed on the internal {@link java.security.MessageDigest} object.

      this.algorithm.reset();
   
public voidupdate(byte[] input)
Proxy method for {@link java.security.MessageDigest#update(byte[])} which is executed on the internal {@link java.security.MessageDigest} object.

param
input

      this.algorithm.update(input);
   
public voidupdate(byte input)
Proxy method for {@link java.security.MessageDigest#update(byte)} which is executed on the internal {@link java.security.MessageDigest} object.

param
input

      this.algorithm.update(input);
   
public voidupdate(byte[] buf, int offset, int len)
Proxy method for {@link java.security.MessageDigest#update(byte[], int, int)} which is executed on the internal {@link java.security.MessageDigest} object.

param
buf
param
offset
param
len

      this.algorithm.update(buf, offset, len);