|
From: <bob...@us...> - 2003-08-20 09:09:34
|
Update of /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/packaging
In directory sc8-pr-cvs1:/tmp/cvs-serv16393/hk/hku/cecid/phoenix/message/packaging
Modified Files:
EbxmlMessage.java PKISignatureImpl.java Signature.java
Log Message:
add sign(tring username, char[] password, String keyStoreLocation,
String algorithm, String digestAlgorithm,
boolean signEnvelopeOnly)
on EbxmlMessage, which allow the user to sign the envelope only,
and specify the digest algorithm.
Index: EbxmlMessage.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/packaging/EbxmlMessage.java,v
retrieving revision 1.35
retrieving revision 1.36
diff -C2 -d -r1.35 -r1.36
*** EbxmlMessage.java 31 Jul 2003 06:55:59 -0000 1.35
--- EbxmlMessage.java 20 Aug 2003 08:02:09 -0000 1.36
***************
*** 941,944 ****
--- 941,977 ----
}
+ /**
+ * Sign this <code>EbxmlMessage</code> with XML signature
+ *
+ * @param username User name used to open the keystore
+ * @param password Password used to open the keystore
+ * @param keyStoreLocation File location of the keystore
+ * @param algorithm Specifies the algorithm used to generate
+ * the digital signature. Refer to <a href=
+ * "http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/#sec-AlgID">
+ * XML-Signature Syntax and Processing: Algorithm Identifiers and
+ * Implementation Requirements</a> for details.
+ * @param digestAlgo Specifies the algorithm used to make the digest.
+ * Refer to <a href=
+ * "http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/#sec-AlgID">
+ * XML-Signature Syntax and Processing: Algorithm Identifiers and
+ * Implementation Requirements</a> for details.
+ * @param signEnvelopeOnly whether it should sign the envelope only,
+ * without signing the payload.
+ *
+ * @throws SOAPException
+ * @throws SignatureException
+ */
+ public void sign(String username, char[] password, String keyStoreLocation,
+ String algorithm, String digestAlgorithm,
+ boolean signEnvelopeOnly)
+ throws SOAPException, SignatureException {
+ final Signature signature = Signature.newInstance(this);
+ signature.sign(username, password, keyStoreLocation, algorithm,
+ digestAlgorithm, signEnvelopeOnly);
+ headerContainer.addExtensionElement(signature);
+ saveChanges();
+ }
+
/**
* Verify the message using trusted keystore.
Index: PKISignatureImpl.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/packaging/PKISignatureImpl.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** PKISignatureImpl.java 16 Jul 2003 08:54:10 -0000 1.9
--- PKISignatureImpl.java 20 Aug 2003 08:02:09 -0000 1.10
***************
*** 130,133 ****
--- 130,139 ----
void sign(String alias, char[] password, String keyStoreLocation,
String algo) throws SignatureException {
+ sign(alias, password, keyStoreLocation, null, null, false);
+ }
+
+ void sign(String alias, char[] password, String keyStoreLocation,
+ String algo, String digestAlgo, boolean signEnvelopeOnly)
+ throws SignatureException {
try {
final SOAPPart soapPart = ebxmlMessage.getSOAPMessage().
***************
*** 159,163 ****
// use user-defined algorithm, only support dsa-sha1 and
// rsa-sha1
! signature.setEnvelope(soapPartDocument, algo);
}
--- 165,173 ----
// use user-defined algorithm, only support dsa-sha1 and
// rsa-sha1
! if (digestAlgo == null) {
! signature.setEnvelope(soapPartDocument, algo);
! } else {
! signature.setEnvelope(soapPartDocument, algo, digestAlgo);
! }
}
***************
*** 165,173 ****
soapHeader.appendChild(signature.getElement());
! Iterator i = ebxmlMessage.getPayloadContainers();
! while (i.hasNext()) {
! PayloadContainer pc = (PayloadContainer) i.next();
! signature.addDocument(pc.getHref(),
! pc.getDataHandler().getInputStream(), pc.getContentType());
}
--- 175,186 ----
soapHeader.appendChild(signature.getElement());
! if (!signEnvelopeOnly) {
! Iterator i = ebxmlMessage.getPayloadContainers();
! while (i.hasNext()) {
! PayloadContainer pc = (PayloadContainer) i.next();
! signature.addDocument(pc.getHref(),
! pc.getDataHandler().getInputStream(),
! pc.getContentType());
! }
}
Index: Signature.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/packaging/Signature.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** Signature.java 16 Jul 2003 08:54:10 -0000 1.8
--- Signature.java 20 Aug 2003 08:02:09 -0000 1.9
***************
*** 407,410 ****
--- 407,429 ----
* @param password Password required to open the private key.
* @param keyStoreLocation File location of the keystore.
+ * @param algorithm Name of the algorithm used to sign the
+ * message.
+ * @param digestAlgo Name of the algorithm used to make the
+ * digest.
+ * @param signEnvelopeOnly whether sign the envelope only.,
+ * @throws SignatureException
+ */
+ abstract void sign(String username, char[] password,
+ String keyStoreLocation, String algorithm,
+ String digestAlgo, boolean signEnvelopeOnly)
+ throws SignatureException;
+
+ /**
+ * Sign the <code>EbxmlMessage</code> with the <code>username<code> and
+ * <code>password</code> used to retrieve private key from the keystore
+ *
+ * @param username User name required to open the private key.
+ * @param password Password required to open the private key.
+ * @param keyStoreLocation File location of the keystore.
* @throws SignatureException
*/
|