/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
/*
*/
/*
* $Id: DOMDigestMethod.java,v 1.2 2008/07/24 15:20:32 mullan Exp $
*/
/**
* DOM-based abstract implementation of DigestMethod.
*
* @author Sean Mullan
*/
implements DigestMethod {
"http://www.w3.org/2001/04/xmldsig-more#sha384"; // see RFC 4051
/**
* Creates a <code>DOMDigestMethod</code>.
*
* @param params the algorithm-specific params (may be <code>null</code>)
* @throws InvalidAlgorithmParameterException if the parameters are not
* appropriate for this digest method
*/
throws InvalidAlgorithmParameterException {
throw new InvalidAlgorithmParameterException
("params must be of type DigestMethodParameterSpec");
}
}
/**
* Creates a <code>DOMDigestMethod</code> from an element. This constructor
* invokes the abstract {@link #unmarshalParams unmarshalParams} method to
* unmarshal any algorithm-specific input parameters.
*
* @param dmElem a DigestMethod element
*/
if (paramsElem != null) {
}
try {
} catch (InvalidAlgorithmParameterException iape) {
throw new MarshalException(iape);
}
}
} else {
throw new MarshalException
("unsupported DigestMethod algorithm: " + alg);
}
}
/**
* Checks if the specified parameters are valid for this algorithm. By
* default, this method throws an exception if parameters are specified
* since most DigestMethod algorithms do not have parameters. Subclasses
* should override it if they have parameters.
*
* @param params the algorithm-specific params (may be <code>null</code>)
* @throws InvalidAlgorithmParameterException if the parameters are not
* appropriate for this digest method
*/
throws InvalidAlgorithmParameterException {
throw new InvalidAlgorithmParameterException("no parameters " +
"should be specified for the " + getMessageDigestAlgorithm()
+ " DigestMethod algorithm");
}
}
return params;
}
/**
* Unmarshals <code>DigestMethodParameterSpec</code> from the specified
* <code>Element</code>. By default, this method throws an exception since
* most DigestMethod algorithms do not have parameters. Subclasses should
* override it if they have parameters.
*
* @param paramsElem the <code>Element</code> holding the input params
* @return the algorithm-specific <code>DigestMethodParameterSpec</code>
* @throws MarshalException if the parameters cannot be unmarshalled
*/
throw new MarshalException("no parameters should " +
"be specified for the " + getMessageDigestAlgorithm() +
" DigestMethod algorithm");
}
/**
* This method invokes the abstract {@link #marshalParams marshalParams}
* method to marshal any algorithm-specific parameters.
*/
throws MarshalException {
}
}
if (this == o) {
return true;
}
if (!(o instanceof DigestMethod)) {
return false;
}
}
/**
* Marshals the algorithm-specific parameters to an Element and
* appends it to the specified parent element. By default, this method
* throws an exception since most DigestMethod algorithms do not have
* parameters. Subclasses should override it if they have parameters.
*
* @param parent the parent element to append the parameters to
* @param the namespace prefix to use
* @throws MarshalException if the parameters cannot be marshalled
*/
throws MarshalException {
throw new MarshalException("no parameters should " +
"be specified for the " + getMessageDigestAlgorithm() +
" DigestMethod algorithm");
}
/**
* Returns the MessageDigest standard algorithm name.
*/
throws InvalidAlgorithmParameterException {
super(params);
}
super(dmElem);
}
return DigestMethod.SHA1;
}
return "SHA-1";
}
}
throws InvalidAlgorithmParameterException {
super(params);
}
super(dmElem);
}
return DigestMethod.SHA256;
}
return "SHA-256";
}
}
throws InvalidAlgorithmParameterException {
super(params);
}
super(dmElem);
}
return SHA384;
}
return "SHA-384";
}
}
throws InvalidAlgorithmParameterException {
super(params);
}
super(dmElem);
}
return DigestMethod.SHA512;
}
return "SHA-512";
}
}
}