提交 eff43a56 编写于 作者: V valeriep

Merge

...@@ -218,3 +218,4 @@ a2a2a91075ad85becbe10a39d7fd04ef9bea8df5 jdk8-b92 ...@@ -218,3 +218,4 @@ a2a2a91075ad85becbe10a39d7fd04ef9bea8df5 jdk8-b92
51479fa56b7c4363c6d87c2e8b898d8185cf4b22 jdk8-b94 51479fa56b7c4363c6d87c2e8b898d8185cf4b22 jdk8-b94
42aa9f1828852bb8b77e98ec695211493ae0759d jdk8-b95 42aa9f1828852bb8b77e98ec695211493ae0759d jdk8-b95
4a5d3cf2b3af1660db0237e8da324c140e534fa4 jdk8-b96 4a5d3cf2b3af1660db0237e8da324c140e534fa4 jdk8-b96
978a95239044f26dcc8a6d59246be07ad6ca6be2 jdk8-b97
...@@ -36,7 +36,11 @@ PRODUCT = sun ...@@ -36,7 +36,11 @@ PRODUCT = sun
CPLUSPLUSLIBRARY=true CPLUSPLUSLIBRARY=true
# Use higher optimization level # Use higher optimization level
ifeq ($(PLATFORM), windows)
OPTIMIZATION_LEVEL = HIGHEST
else
OPTIMIZATION_LEVEL = HIGHER OPTIMIZATION_LEVEL = HIGHER
endif
include $(BUILDDIR)/common/Defs.gmk include $(BUILDDIR)/common/Defs.gmk
......
...@@ -1332,7 +1332,7 @@ LIBFONTMANAGER_OPTIMIZATION:=HIGH ...@@ -1332,7 +1332,7 @@ LIBFONTMANAGER_OPTIMIZATION:=HIGH
ifeq ($(OPENJDK_TARGET_OS),windows) ifeq ($(OPENJDK_TARGET_OS),windows)
LIBFONTMANAGER_EXCLUDE_FILES += X11FontScaler.c \ LIBFONTMANAGER_EXCLUDE_FILES += X11FontScaler.c \
X11TextRenderer.c X11TextRenderer.c
LIBFONTMANAGER_OPTIMIZATION:=LOW LIBFONTMANAGER_OPTIMIZATION:=HIGHEST
else else
LIBFONTMANAGER_EXCLUDE_FILES += fontpath.c \ LIBFONTMANAGER_EXCLUDE_FILES += fontpath.c \
lcdglyph.c lcdglyph.c
......
/* /*
* Copyright (c) 2005, 2013 Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
...@@ -127,8 +127,21 @@ public class CEmbeddedFrame extends EmbeddedFrame { ...@@ -127,8 +127,21 @@ public class CEmbeddedFrame extends EmbeddedFrame {
} }
} }
/**
* When the parent window is activated this method is called for all EmbeddedFrames in it.
*
* For the CEmbeddedFrame which had focus before the deactivation this method triggers
* focus events in the following order:
* 1. WINDOW_ACTIVATED for this EmbeddedFrame
* 2. WINDOW_GAINED_FOCUS for this EmbeddedFrame
* 3. FOCUS_GAINED for the most recent focus owner in this EmbeddedFrame
*
* The caller must not requestFocus on the EmbeddedFrame together with calling this method.
*
* @param parentWindowActive true if the window is activated, false otherwise
*/
// handleWindowFocusEvent is called for all applets, when the browser // handleWindowFocusEvent is called for all applets, when the browser
// becames active/inactive. This event should be filtered out for // becomes active/inactive. This event should be filtered out for
// non-focused applet. This method can be called from different threads. // non-focused applet. This method can be called from different threads.
public void handleWindowFocusEvent(boolean parentWindowActive) { public void handleWindowFocusEvent(boolean parentWindowActive) {
this.parentWindowActive = parentWindowActive; this.parentWindowActive = parentWindowActive;
......
...@@ -2,82 +2,78 @@ ...@@ -2,82 +2,78 @@
* reserved comment block * reserved comment block
* DO NOT REMOVE OR ALTER! * DO NOT REMOVE OR ALTER!
*/ */
/* /**
* Copyright 1999-2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one
* * or more contributor license agreements. See the NOTICE file
* Licensed under the Apache License, Version 2.0 (the "License"); * distributed with this work for additional information
* you may not use this file except in compliance with the License. * regarding copyright ownership. The ASF licenses this file
* You may obtain a copy of the License at * to you under the Apache License, Version 2.0 (the
* * "License"); you may not use this file except in compliance
* http://www.apache.org/licenses/LICENSE-2.0 * with the License. You may obtain a copy of the License at
* *
* Unless required by applicable law or agreed to in writing, software * http://www.apache.org/licenses/LICENSE-2.0
* 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.
* *
* 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.
*/ */
package com.sun.org.apache.xml.internal.security.algorithms; package com.sun.org.apache.xml.internal.security.algorithms;
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException; import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
import com.sun.org.apache.xml.internal.security.utils.Constants; import com.sun.org.apache.xml.internal.security.utils.Constants;
import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy; import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
/** /**
* The Algorithm class which stores the Algorithm URI as a string. * The Algorithm class which stores the Algorithm URI as a string.
*
*/ */
public abstract class Algorithm extends SignatureElementProxy { public abstract class Algorithm extends SignatureElementProxy {
/** /**
* *
* @param doc * @param doc
* @param algorithmURI is the URI of the algorithm as String * @param algorithmURI is the URI of the algorithm as String
*/ */
public Algorithm(Document doc, String algorithmURI) { public Algorithm(Document doc, String algorithmURI) {
super(doc);
super(doc);
this.setAlgorithmURI(algorithmURI);
}
/** this.setAlgorithmURI(algorithmURI);
* Constructor Algorithm }
*
* @param element
* @param BaseURI
* @throws XMLSecurityException
*/
public Algorithm(Element element, String BaseURI)
throws XMLSecurityException {
super(element, BaseURI);
}
/** /**
* Method getAlgorithmURI * Constructor Algorithm
* *
* @return The URI of the alogrithm * @param element
*/ * @param BaseURI
public String getAlgorithmURI() { * @throws XMLSecurityException
return this._constructionElement.getAttributeNS(null, Constants._ATT_ALGORITHM); */
} public Algorithm(Element element, String BaseURI) throws XMLSecurityException {
super(element, BaseURI);
}
/** /**
* Sets the algorithm's URI as used in the signature. * Method getAlgorithmURI
* *
* @param algorithmURI is the URI of the algorithm as String * @return The URI of the algorithm
*/ */
protected void setAlgorithmURI(String algorithmURI) { public String getAlgorithmURI() {
return this.constructionElement.getAttributeNS(null, Constants._ATT_ALGORITHM);
}
if ( (algorithmURI != null)) { /**
this._constructionElement.setAttributeNS(null, Constants._ATT_ALGORITHM, * Sets the algorithm's URI as used in the signature.
algorithmURI); *
} * @param algorithmURI is the URI of the algorithm as String
} */
protected void setAlgorithmURI(String algorithmURI) {
if (algorithmURI != null) {
this.constructionElement.setAttributeNS(
null, Constants._ATT_ALGORITHM, algorithmURI
);
}
}
} }
...@@ -114,6 +114,18 @@ public class JCEMapper { ...@@ -114,6 +114,18 @@ public class JCEMapper {
XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA1, XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA1,
new Algorithm("", "SHA1withECDSA", "Signature") new Algorithm("", "SHA1withECDSA", "Signature")
); );
algorithmsMap.put(
XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA256,
new Algorithm("", "SHA256withECDSA", "Signature")
);
algorithmsMap.put(
XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA384,
new Algorithm("", "SHA384withECDSA", "Signature")
);
algorithmsMap.put(
XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA512,
new Algorithm("", "SHA512withECDSA", "Signature")
);
algorithmsMap.put( algorithmsMap.put(
XMLSignature.ALGO_ID_MAC_HMAC_NOT_RECOMMENDED_MD5, XMLSignature.ALGO_ID_MAC_HMAC_NOT_RECOMMENDED_MD5,
new Algorithm("", "HmacMD5", "Mac") new Algorithm("", "HmacMD5", "Mac")
...@@ -154,6 +166,18 @@ public class JCEMapper { ...@@ -154,6 +166,18 @@ public class JCEMapper {
XMLCipher.AES_256, XMLCipher.AES_256,
new Algorithm("AES", "AES/CBC/ISO10126Padding", "BlockEncryption", 256) new Algorithm("AES", "AES/CBC/ISO10126Padding", "BlockEncryption", 256)
); );
algorithmsMap.put(
XMLCipher.AES_128_GCM,
new Algorithm("AES", "AES/GCM/NoPadding", "BlockEncryption", 128)
);
algorithmsMap.put(
XMLCipher.AES_192_GCM,
new Algorithm("AES", "AES/GCM/NoPadding", "BlockEncryption", 192)
);
algorithmsMap.put(
XMLCipher.AES_256_GCM,
new Algorithm("AES", "AES/GCM/NoPadding", "BlockEncryption", 256)
);
algorithmsMap.put( algorithmsMap.put(
XMLCipher.RSA_v1dot5, XMLCipher.RSA_v1dot5,
new Algorithm("RSA", "RSA/ECB/PKCS1Padding", "KeyTransport") new Algorithm("RSA", "RSA/ECB/PKCS1Padding", "KeyTransport")
...@@ -162,6 +186,10 @@ public class JCEMapper { ...@@ -162,6 +186,10 @@ public class JCEMapper {
XMLCipher.RSA_OAEP, XMLCipher.RSA_OAEP,
new Algorithm("RSA", "RSA/ECB/OAEPPadding", "KeyTransport") new Algorithm("RSA", "RSA/ECB/OAEPPadding", "KeyTransport")
); );
algorithmsMap.put(
XMLCipher.RSA_OAEP_11,
new Algorithm("RSA", "RSA/ECB/OAEPPadding", "KeyTransport")
);
algorithmsMap.put( algorithmsMap.put(
XMLCipher.DIFFIE_HELLMAN, XMLCipher.DIFFIE_HELLMAN,
new Algorithm("", "", "KeyAgreement") new Algorithm("", "", "KeyAgreement")
......
...@@ -2,265 +2,254 @@ ...@@ -2,265 +2,254 @@
* reserved comment block * reserved comment block
* DO NOT REMOVE OR ALTER! * DO NOT REMOVE OR ALTER!
*/ */
/* /**
* Copyright 1999-2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one
* * or more contributor license agreements. See the NOTICE file
* Licensed under the Apache License, Version 2.0 (the "License"); * distributed with this work for additional information
* you may not use this file except in compliance with the License. * regarding copyright ownership. The ASF licenses this file
* You may obtain a copy of the License at * to you under the Apache License, Version 2.0 (the
* * "License"); you may not use this file except in compliance
* http://www.apache.org/licenses/LICENSE-2.0 * with the License. You may obtain a copy of the License at
* *
* Unless required by applicable law or agreed to in writing, software * http://www.apache.org/licenses/LICENSE-2.0
* 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.
* *
* 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.
*/ */
package com.sun.org.apache.xml.internal.security.algorithms; package com.sun.org.apache.xml.internal.security.algorithms;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchProviderException; import java.security.NoSuchProviderException;
import java.util.HashMap;
import java.util.Map;
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException; import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException;
import com.sun.org.apache.xml.internal.security.utils.Constants; import com.sun.org.apache.xml.internal.security.utils.Constants;
import com.sun.org.apache.xml.internal.security.utils.EncryptionConstants; import com.sun.org.apache.xml.internal.security.utils.EncryptionConstants;
import org.w3c.dom.Document; import org.w3c.dom.Document;
/** /**
* Digest Message wrapper & selector class. * Digest Message wrapper & selector class.
* *
* <pre> * <pre>
* MessageDigestAlgorithm.getInstance() * MessageDigestAlgorithm.getInstance()
* </pre> * </pre>
*
*/ */
public class MessageDigestAlgorithm extends Algorithm { public class MessageDigestAlgorithm extends Algorithm {
/** Message Digest - NOT RECOMMENDED MD5*/ /** Message Digest - NOT RECOMMENDED MD5*/
public static final String ALGO_ID_DIGEST_NOT_RECOMMENDED_MD5 = Constants.MoreAlgorithmsSpecNS + "md5"; public static final String ALGO_ID_DIGEST_NOT_RECOMMENDED_MD5 =
/** Digest - Required SHA1*/ Constants.MoreAlgorithmsSpecNS + "md5";
public static final String ALGO_ID_DIGEST_SHA1 = Constants.SignatureSpecNS + "sha1"; /** Digest - Required SHA1*/
/** Message Digest - RECOMMENDED SHA256*/ public static final String ALGO_ID_DIGEST_SHA1 = Constants.SignatureSpecNS + "sha1";
public static final String ALGO_ID_DIGEST_SHA256 = EncryptionConstants.EncryptionSpecNS + "sha256"; /** Message Digest - RECOMMENDED SHA256*/
/** Message Digest - OPTIONAL SHA384*/ public static final String ALGO_ID_DIGEST_SHA256 =
public static final String ALGO_ID_DIGEST_SHA384 = Constants.MoreAlgorithmsSpecNS + "sha384"; EncryptionConstants.EncryptionSpecNS + "sha256";
/** Message Digest - OPTIONAL SHA512*/ /** Message Digest - OPTIONAL SHA384*/
public static final String ALGO_ID_DIGEST_SHA512 = EncryptionConstants.EncryptionSpecNS + "sha512"; public static final String ALGO_ID_DIGEST_SHA384 =
/** Message Digest - OPTIONAL RIPEMD-160*/ Constants.MoreAlgorithmsSpecNS + "sha384";
public static final String ALGO_ID_DIGEST_RIPEMD160 = EncryptionConstants.EncryptionSpecNS + "ripemd160"; /** Message Digest - OPTIONAL SHA512*/
public static final String ALGO_ID_DIGEST_SHA512 =
/** Field algorithm stores the actual {@link java.security.MessageDigest} */ EncryptionConstants.EncryptionSpecNS + "sha512";
java.security.MessageDigest algorithm = null; /** Message Digest - OPTIONAL RIPEMD-160*/
public static final String ALGO_ID_DIGEST_RIPEMD160 =
/** EncryptionConstants.EncryptionSpecNS + "ripemd160";
* Constructor for the brave who pass their own message digest algorithms and the corresponding URI.
* @param doc /** Field algorithm stores the actual {@link java.security.MessageDigest} */
* @param messageDigest private final MessageDigest algorithm;
* @param algorithmURI
*/ /**
private MessageDigestAlgorithm(Document doc, MessageDigest messageDigest, * Constructor for the brave who pass their own message digest algorithms and the
String algorithmURI) { * corresponding URI.
* @param doc
super(doc, algorithmURI); * @param algorithmURI
*/
this.algorithm = messageDigest; private MessageDigestAlgorithm(Document doc, String algorithmURI)
} throws XMLSignatureException {
super(doc, algorithmURI);
static ThreadLocal<Map<String, MessageDigest>> instances=new
ThreadLocal<Map<String, MessageDigest>>() { algorithm = getDigestInstance(algorithmURI);
protected Map<String, MessageDigest> initialValue() { }
return new HashMap<String, MessageDigest>();
}; /**
}; * Factory method for constructing a message digest algorithm by name.
*
/** * @param doc
* Factory method for constructing a message digest algorithm by name. * @param algorithmURI
* * @return The MessageDigestAlgorithm element to attach in document and to digest
* @param doc * @throws XMLSignatureException
* @param algorithmURI */
* @return The MessageDigestAlgorithm element to attach in document and to digest public static MessageDigestAlgorithm getInstance(
* @throws XMLSignatureException Document doc, String algorithmURI
*/ ) throws XMLSignatureException {
public static MessageDigestAlgorithm getInstance( return new MessageDigestAlgorithm(doc, algorithmURI);
Document doc, String algorithmURI) throws XMLSignatureException { }
MessageDigest md = getDigestInstance(algorithmURI);
return new MessageDigestAlgorithm(doc, md, algorithmURI); private static MessageDigest getDigestInstance(String algorithmURI) throws XMLSignatureException {
} String algorithmID = JCEMapper.translateURItoJCEID(algorithmURI);
private static MessageDigest getDigestInstance(String algorithmURI) throws XMLSignatureException { if (algorithmID == null) {
MessageDigest result= instances.get().get(algorithmURI); Object[] exArgs = { algorithmURI };
if (result!=null) throw new XMLSignatureException("algorithms.NoSuchMap", exArgs);
return result; }
String algorithmID = JCEMapper.translateURItoJCEID(algorithmURI);
if (algorithmID == null) {
Object[] exArgs = { algorithmURI };
throw new XMLSignatureException("algorithms.NoSuchMap", exArgs);
}
MessageDigest md; MessageDigest md;
String provider=JCEMapper.getProviderId(); String provider = JCEMapper.getProviderId();
try { try {
if (provider==null) { if (provider == null) {
md = MessageDigest.getInstance(algorithmID); md = MessageDigest.getInstance(algorithmID);
} else { } else {
md = MessageDigest.getInstance(algorithmID,provider); md = MessageDigest.getInstance(algorithmID, provider);
} }
} catch (java.security.NoSuchAlgorithmException ex) { } catch (java.security.NoSuchAlgorithmException ex) {
Object[] exArgs = { algorithmID, Object[] exArgs = { algorithmID, ex.getLocalizedMessage() };
ex.getLocalizedMessage() };
throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs); throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
} catch (NoSuchProviderException ex) { } catch (NoSuchProviderException ex) {
Object[] exArgs = { algorithmID, Object[] exArgs = { algorithmID, ex.getLocalizedMessage() };
ex.getLocalizedMessage() };
throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs); throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
} }
instances.get().put(algorithmURI, md);
return md;
}
/**
* Returns the actual {@link java.security.MessageDigest} algorithm object
*
* @return the actual {@link java.security.MessageDigest} algorithm object
*/
public java.security.MessageDigest getAlgorithm() {
return this.algorithm;
}
/**
* 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
*/
public static boolean isEqual(byte[] digesta, byte[] digestb) {
return java.security.MessageDigest.isEqual(digesta, digestb);
}
/**
* 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
*/
public byte[] digest() {
return this.algorithm.digest();
}
/**
* 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
*/
public byte[] digest(byte input[]) {
return this.algorithm.digest(input);
}
/**
* 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
*/
public int digest(byte buf[], int offset, int len)
throws java.security.DigestException {
return this.algorithm.digest(buf, offset, len);
}
/**
* 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
*/
public String getJCEAlgorithmString() {
return this.algorithm.getAlgorithm();
}
/**
* 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
*/
public java.security.Provider getJCEProvider() {
return this.algorithm.getProvider();
}
/** return md;
* 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 * Returns the actual {@link java.security.MessageDigest} algorithm object
*/ *
public int getDigestLength() { * @return the actual {@link java.security.MessageDigest} algorithm object
return this.algorithm.getDigestLength(); */
} public java.security.MessageDigest getAlgorithm() {
return algorithm;
/** }
* Proxy method for {@link java.security.MessageDigest#reset}
* which is executed on the internal {@link java.security.MessageDigest} object. /**
* * Proxy method for {@link java.security.MessageDigest#isEqual}
*/ * which is executed on the internal {@link java.security.MessageDigest} object.
public void reset() { *
this.algorithm.reset(); * @param digesta
} * @param digestb
* @return the result of the {@link java.security.MessageDigest#isEqual} method
/** */
* Proxy method for {@link java.security.MessageDigest#update(byte[])} public static boolean isEqual(byte[] digesta, byte[] digestb) {
* which is executed on the internal {@link java.security.MessageDigest} object. return java.security.MessageDigest.isEqual(digesta, digestb);
* }
* @param input
*/ /**
public void update(byte[] input) { * Proxy method for {@link java.security.MessageDigest#digest()}
this.algorithm.update(input); * which is executed on the internal {@link java.security.MessageDigest} object.
} *
* @return the result of the {@link java.security.MessageDigest#digest()} method
/** */
* Proxy method for {@link java.security.MessageDigest#update(byte)} public byte[] digest() {
* which is executed on the internal {@link java.security.MessageDigest} object. return algorithm.digest();
* }
* @param input
*/ /**
public void update(byte input) { * Proxy method for {@link java.security.MessageDigest#digest(byte[])}
this.algorithm.update(input); * 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
* Proxy method for {@link java.security.MessageDigest#update(byte[], int, int)} */
* which is executed on the internal {@link java.security.MessageDigest} object. public byte[] digest(byte input[]) {
* return algorithm.digest(input);
* @param buf }
* @param offset
* @param len /**
*/ * Proxy method for {@link java.security.MessageDigest#digest(byte[], int, int)}
public void update(byte buf[], int offset, int len) { * which is executed on the internal {@link java.security.MessageDigest} object.
this.algorithm.update(buf, offset, len); *
} * @param buf
* @param offset
/** @inheritDoc */ * @param len
public String getBaseNamespace() { * @return the result of the {@link java.security.MessageDigest#digest(byte[], int, int)} method
return Constants.SignatureSpecNS; * @throws java.security.DigestException
} */
public int digest(byte buf[], int offset, int len) throws java.security.DigestException {
/** @inheritDoc */ return algorithm.digest(buf, offset, len);
public String getBaseLocalName() { }
return Constants._TAG_DIGESTMETHOD;
} /**
* 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
*/
public String getJCEAlgorithmString() {
return algorithm.getAlgorithm();
}
/**
* 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
*/
public java.security.Provider getJCEProvider() {
return algorithm.getProvider();
}
/**
* 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
*/
public int getDigestLength() {
return algorithm.getDigestLength();
}
/**
* Proxy method for {@link java.security.MessageDigest#reset}
* which is executed on the internal {@link java.security.MessageDigest} object.
*
*/
public void reset() {
algorithm.reset();
}
/**
* Proxy method for {@link java.security.MessageDigest#update(byte[])}
* which is executed on the internal {@link java.security.MessageDigest} object.
*
* @param input
*/
public void update(byte[] input) {
algorithm.update(input);
}
/**
* Proxy method for {@link java.security.MessageDigest#update(byte)}
* which is executed on the internal {@link java.security.MessageDigest} object.
*
* @param input
*/
public void update(byte input) {
algorithm.update(input);
}
/**
* 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
*/
public void update(byte buf[], int offset, int len) {
algorithm.update(buf, offset, len);
}
/** @inheritDoc */
public String getBaseNamespace() {
return Constants.SignatureSpecNS;
}
/** @inheritDoc */
public String getBaseLocalName() {
return Constants._TAG_DIGESTMETHOD;
}
} }
...@@ -74,7 +74,7 @@ public class SignatureAlgorithm extends Algorithm { ...@@ -74,7 +74,7 @@ public class SignatureAlgorithm extends Algorithm {
this.algorithmURI = algorithmURI; this.algorithmURI = algorithmURI;
signatureAlgorithm = getSignatureAlgorithmSpi(algorithmURI); signatureAlgorithm = getSignatureAlgorithmSpi(algorithmURI);
signatureAlgorithm.engineGetContextFromElement(this._constructionElement); signatureAlgorithm.engineGetContextFromElement(this.constructionElement);
} }
/** /**
...@@ -92,10 +92,10 @@ public class SignatureAlgorithm extends Algorithm { ...@@ -92,10 +92,10 @@ public class SignatureAlgorithm extends Algorithm {
this.algorithmURI = algorithmURI; this.algorithmURI = algorithmURI;
signatureAlgorithm = getSignatureAlgorithmSpi(algorithmURI); signatureAlgorithm = getSignatureAlgorithmSpi(algorithmURI);
signatureAlgorithm.engineGetContextFromElement(this._constructionElement); signatureAlgorithm.engineGetContextFromElement(this.constructionElement);
signatureAlgorithm.engineSetHMACOutputLength(hmacOutputLength); signatureAlgorithm.engineSetHMACOutputLength(hmacOutputLength);
((IntegrityHmac)signatureAlgorithm).engineAddContextToElement(_constructionElement); ((IntegrityHmac)signatureAlgorithm).engineAddContextToElement(constructionElement);
} }
/** /**
...@@ -136,7 +136,7 @@ public class SignatureAlgorithm extends Algorithm { ...@@ -136,7 +136,7 @@ public class SignatureAlgorithm extends Algorithm {
} }
signatureAlgorithm = getSignatureAlgorithmSpi(algorithmURI); signatureAlgorithm = getSignatureAlgorithmSpi(algorithmURI);
signatureAlgorithm.engineGetContextFromElement(this._constructionElement); signatureAlgorithm.engineGetContextFromElement(this.constructionElement);
} }
/** /**
...@@ -310,7 +310,7 @@ public class SignatureAlgorithm extends Algorithm { ...@@ -310,7 +310,7 @@ public class SignatureAlgorithm extends Algorithm {
* @return the URI representation of Transformation algorithm * @return the URI representation of Transformation algorithm
*/ */
public final String getURI() { public final String getURI() {
return _constructionElement.getAttributeNS(null, Constants._ATT_ALGORITHM); return constructionElement.getAttributeNS(null, Constants._ATT_ALGORITHM);
} }
/** /**
...@@ -380,9 +380,7 @@ public class SignatureAlgorithm extends Algorithm { ...@@ -380,9 +380,7 @@ public class SignatureAlgorithm extends Algorithm {
* This method registers the default algorithms. * This method registers the default algorithms.
*/ */
public static void registerDefaultAlgorithms() { public static void registerDefaultAlgorithms() {
algorithmHash.put( algorithmHash.put(SignatureDSA.URI, SignatureDSA.class);
XMLSignature.ALGO_ID_SIGNATURE_DSA, SignatureDSA.class
);
algorithmHash.put( algorithmHash.put(
XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1, SignatureBaseRSA.SignatureRSASHA1.class XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1, SignatureBaseRSA.SignatureRSASHA1.class
); );
...@@ -409,6 +407,15 @@ public class SignatureAlgorithm extends Algorithm { ...@@ -409,6 +407,15 @@ public class SignatureAlgorithm extends Algorithm {
algorithmHash.put( algorithmHash.put(
XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA1, SignatureECDSA.SignatureECDSASHA1.class XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA1, SignatureECDSA.SignatureECDSASHA1.class
); );
algorithmHash.put(
XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA256, SignatureECDSA.SignatureECDSASHA256.class
);
algorithmHash.put(
XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA384, SignatureECDSA.SignatureECDSASHA384.class
);
algorithmHash.put(
XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA512, SignatureECDSA.SignatureECDSASHA512.class
);
algorithmHash.put( algorithmHash.put(
XMLSignature.ALGO_ID_MAC_HMAC_NOT_RECOMMENDED_MD5, IntegrityHmac.IntegrityHmacMD5.class XMLSignature.ALGO_ID_MAC_HMAC_NOT_RECOMMENDED_MD5, IntegrityHmac.IntegrityHmacMD5.class
); );
......
...@@ -2,21 +2,23 @@ ...@@ -2,21 +2,23 @@
* reserved comment block * reserved comment block
* DO NOT REMOVE OR ALTER! * DO NOT REMOVE OR ALTER!
*/ */
/* /**
* Copyright 1999-2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one
* * or more contributor license agreements. See the NOTICE file
* Licensed under the Apache License, Version 2.0 (the "License"); * distributed with this work for additional information
* you may not use this file except in compliance with the License. * regarding copyright ownership. The ASF licenses this file
* You may obtain a copy of the License at * to you under the Apache License, Version 2.0 (the
* * "License"); you may not use this file except in compliance
* http://www.apache.org/licenses/LICENSE-2.0 * with the License. You may obtain a copy of the License at
* *
* Unless required by applicable law or agreed to in writing, software * http://www.apache.org/licenses/LICENSE-2.0
* 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.
* *
* 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.
*/ */
package com.sun.org.apache.xml.internal.security.algorithms; package com.sun.org.apache.xml.internal.security.algorithms;
...@@ -27,157 +29,149 @@ import java.security.spec.AlgorithmParameterSpec; ...@@ -27,157 +29,149 @@ import java.security.spec.AlgorithmParameterSpec;
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException; import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException;
import org.w3c.dom.Element; import org.w3c.dom.Element;
/**
*
* @author $Author: mullan $
*/
public abstract class SignatureAlgorithmSpi { public abstract class SignatureAlgorithmSpi {
/** /**
* Returns the URI representation of <code>Transformation algorithm</code> * Returns the URI representation of <code>Transformation algorithm</code>
* *
* @return the URI representation of <code>Transformation algorithm</code> * @return the URI representation of <code>Transformation algorithm</code>
*/ */
protected abstract String engineGetURI(); protected abstract String engineGetURI();
/** /**
* Proxy method for {@link java.security.Signature#getAlgorithm} * Proxy method for {@link java.security.Signature#getAlgorithm}
* which is executed on the internal {@link java.security.Signature} object. * which is executed on the internal {@link java.security.Signature} object.
* *
* @return the result of the {@link java.security.Signature#getAlgorithm} method * @return the result of the {@link java.security.Signature#getAlgorithm} method
*/ */
protected abstract String engineGetJCEAlgorithmString(); protected abstract String engineGetJCEAlgorithmString();
/** /**
* Method engineGetJCEProviderName * Method engineGetJCEProviderName
* *
* @return the JCE ProviderName * @return the JCE ProviderName
*/ */
protected abstract String engineGetJCEProviderName(); protected abstract String engineGetJCEProviderName();
/** /**
* Proxy method for {@link java.security.Signature#update(byte[])} * Proxy method for {@link java.security.Signature#update(byte[])}
* which is executed on the internal {@link java.security.Signature} object. * which is executed on the internal {@link java.security.Signature} object.
* *
* @param input * @param input
* @throws XMLSignatureException * @throws XMLSignatureException
*/ */
protected abstract void engineUpdate(byte[] input) protected abstract void engineUpdate(byte[] input) throws XMLSignatureException;
throws XMLSignatureException;
/**
/** * Proxy method for {@link java.security.Signature#update(byte[])}
* Proxy method for {@link java.security.Signature#update(byte[])} * which is executed on the internal {@link java.security.Signature} object.
* which is executed on the internal {@link java.security.Signature} object. *
* * @param input
* @param input * @throws XMLSignatureException
* @throws XMLSignatureException */
*/ protected abstract void engineUpdate(byte input) throws XMLSignatureException;
protected abstract void engineUpdate(byte input)
throws XMLSignatureException; /**
* Proxy method for {@link java.security.Signature#update(byte[], int, int)}
/** * which is executed on the internal {@link java.security.Signature} object.
* Proxy method for {@link java.security.Signature#update(byte[], int, int)} *
* which is executed on the internal {@link java.security.Signature} object. * @param buf
* * @param offset
* @param buf * @param len
* @param offset * @throws XMLSignatureException
* @param len */
* @throws XMLSignatureException protected abstract void engineUpdate(byte buf[], int offset, int len)
*/ throws XMLSignatureException;
protected abstract void engineUpdate(byte buf[], int offset, int len)
throws XMLSignatureException; /**
* Proxy method for {@link java.security.Signature#initSign(java.security.PrivateKey)}
/** * which is executed on the internal {@link java.security.Signature} object.
* Proxy method for {@link java.security.Signature#initSign(java.security.PrivateKey)} *
* which is executed on the internal {@link java.security.Signature} object. * @param signingKey
* * @throws XMLSignatureException if this method is called on a MAC
* @param signingKey */
* @throws XMLSignatureException if this method is called on a MAC protected abstract void engineInitSign(Key signingKey) throws XMLSignatureException;
*/
protected abstract void engineInitSign(Key signingKey) /**
throws XMLSignatureException; * Proxy method for {@link java.security.Signature#initSign(java.security.PrivateKey,
* java.security.SecureRandom)}
/** * which is executed on the internal {@link java.security.Signature} object.
* Proxy method for {@link java.security.Signature#initSign(java.security.PrivateKey, java.security.SecureRandom)} *
* which is executed on the internal {@link java.security.Signature} object. * @param signingKey
* * @param secureRandom
* @param signingKey * @throws XMLSignatureException if this method is called on a MAC
* @param secureRandom */
* @throws XMLSignatureException if this method is called on a MAC protected abstract void engineInitSign(Key signingKey, SecureRandom secureRandom)
*/ throws XMLSignatureException;
protected abstract void engineInitSign(
Key signingKey, SecureRandom secureRandom) throws XMLSignatureException; /**
* Proxy method for {@link javax.crypto.Mac}
/** * which is executed on the internal {@link javax.crypto.Mac#init(Key)} object.
* Proxy method for {@link javax.crypto.Mac} *
* which is executed on the internal {@link javax.crypto.Mac#init(Key)} object. * @param signingKey
* * @param algorithmParameterSpec
* @param signingKey * @throws XMLSignatureException if this method is called on a Signature
* @param algorithmParameterSpec */
* @throws XMLSignatureException if this method is called on a Signature protected abstract void engineInitSign(
*/ Key signingKey, AlgorithmParameterSpec algorithmParameterSpec
protected abstract void engineInitSign( ) throws XMLSignatureException;
Key signingKey, AlgorithmParameterSpec algorithmParameterSpec)
throws XMLSignatureException; /**
* Proxy method for {@link java.security.Signature#sign()}
/** * which is executed on the internal {@link java.security.Signature} object.
* Proxy method for {@link java.security.Signature#sign()} *
* which is executed on the internal {@link java.security.Signature} object. * @return the result of the {@link java.security.Signature#sign()} method
* * @throws XMLSignatureException
* @return the result of the {@link java.security.Signature#sign()} method */
* @throws XMLSignatureException protected abstract byte[] engineSign() throws XMLSignatureException;
*/
protected abstract byte[] engineSign() throws XMLSignatureException; /**
* Method engineInitVerify
/** *
* Method engineInitVerify * @param verificationKey
* * @throws XMLSignatureException
* @param verificationKey */
* @throws XMLSignatureException protected abstract void engineInitVerify(Key verificationKey) throws XMLSignatureException;
*/
protected abstract void engineInitVerify(Key verificationKey) /**
throws XMLSignatureException; * Proxy method for {@link java.security.Signature#verify(byte[])}
* which is executed on the internal {@link java.security.Signature} object.
/** *
* Proxy method for {@link java.security.Signature#verify(byte[])} * @param signature
* which is executed on the internal {@link java.security.Signature} object. * @return true if the signature is correct
* * @throws XMLSignatureException
* @param signature */
* @return true if the signature is correct protected abstract boolean engineVerify(byte[] signature) throws XMLSignatureException;
* @throws XMLSignatureException
*/ /**
protected abstract boolean engineVerify(byte[] signature) * Proxy method for {@link java.security.Signature#setParameter(
throws XMLSignatureException; * java.security.spec.AlgorithmParameterSpec)}
* which is executed on the internal {@link java.security.Signature} object.
/** *
* Proxy method for {@link java.security.Signature#setParameter(java.security.spec.AlgorithmParameterSpec)} * @param params
* which is executed on the internal {@link java.security.Signature} object. * @throws XMLSignatureException
* */
* @param params protected abstract void engineSetParameter(AlgorithmParameterSpec params)
* @throws XMLSignatureException throws XMLSignatureException;
*/
protected abstract void engineSetParameter(AlgorithmParameterSpec params)
throws XMLSignatureException; /**
* Method engineGetContextFromElement
*
/** * @param element
* Method engineGetContextFromElement */
* protected void engineGetContextFromElement(Element element) {
* @param element }
*/
protected void engineGetContextFromElement(Element element) { /**
} * Method engineSetHMACOutputLength
*
/** * @param HMACOutputLength
* Method engineSetHMACOutputLength * @throws XMLSignatureException
* */
* @param HMACOutputLength protected abstract void engineSetHMACOutputLength(int HMACOutputLength)
* @throws XMLSignatureException throws XMLSignatureException;
*/
protected abstract void engineSetHMACOutputLength(int HMACOutputLength)
throws XMLSignatureException;
public void reset() { public void reset() {
} }
} }
...@@ -2,21 +2,23 @@ ...@@ -2,21 +2,23 @@
* reserved comment block * reserved comment block
* DO NOT REMOVE OR ALTER! * DO NOT REMOVE OR ALTER!
*/ */
/* /**
* Copyright 1999-2007 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one
* * or more contributor license agreements. See the NOTICE file
* Licensed under the Apache License, Version 2.0 (the "License"); * distributed with this work for additional information
* you may not use this file except in compliance with the License. * regarding copyright ownership. The ASF licenses this file
* You may obtain a copy of the License at * to you under the Apache License, Version 2.0 (the
* * "License"); you may not use this file except in compliance
* http://www.apache.org/licenses/LICENSE-2.0 * with the License. You may obtain a copy of the License at
* *
* Unless required by applicable law or agreed to in writing, software * http://www.apache.org/licenses/LICENSE-2.0
* 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.
* *
* 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.
*/ */
package com.sun.org.apache.xml.internal.security.algorithms.implementations; package com.sun.org.apache.xml.internal.security.algorithms.implementations;
...@@ -36,22 +38,17 @@ import com.sun.org.apache.xml.internal.security.algorithms.SignatureAlgorithmSpi ...@@ -36,22 +38,17 @@ import com.sun.org.apache.xml.internal.security.algorithms.SignatureAlgorithmSpi
import com.sun.org.apache.xml.internal.security.signature.XMLSignature; import com.sun.org.apache.xml.internal.security.signature.XMLSignature;
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException; import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException;
/**
*
* @author $Author: mullan $
*/
public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi { public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
/** {@link java.util.logging} logging facility */ /** {@link org.apache.commons.logging} logging facility */
static java.util.logging.Logger log = private static java.util.logging.Logger log =
java.util.logging.Logger.getLogger java.util.logging.Logger.getLogger(SignatureBaseRSA.class.getName());
(SignatureBaseRSA.class.getName());
/** @inheritDoc */ /** @inheritDoc */
public abstract String engineGetURI(); public abstract String engineGetURI();
/** Field algorithm */ /** Field algorithm */
private java.security.Signature _signatureAlgorithm = null; private java.security.Signature signatureAlgorithm = null;
/** /**
* Constructor SignatureRSA * Constructor SignatureRSA
...@@ -59,17 +56,17 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi { ...@@ -59,17 +56,17 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
* @throws XMLSignatureException * @throws XMLSignatureException
*/ */
public SignatureBaseRSA() throws XMLSignatureException { public SignatureBaseRSA() throws XMLSignatureException {
String algorithmID = JCEMapper.translateURItoJCEID(this.engineGetURI()); String algorithmID = JCEMapper.translateURItoJCEID(this.engineGetURI());
if (log.isLoggable(java.util.logging.Level.FINE)) if (log.isLoggable(java.util.logging.Level.FINE)) {
log.log(java.util.logging.Level.FINE, "Created SignatureRSA using " + algorithmID); log.log(java.util.logging.Level.FINE, "Created SignatureRSA using " + algorithmID);
String provider=JCEMapper.getProviderId(); }
String provider = JCEMapper.getProviderId();
try { try {
if (provider==null) { if (provider == null) {
this._signatureAlgorithm = Signature.getInstance(algorithmID); this.signatureAlgorithm = Signature.getInstance(algorithmID);
} else { } else {
this._signatureAlgorithm = Signature.getInstance(algorithmID,provider); this.signatureAlgorithm = Signature.getInstance(algorithmID,provider);
} }
} catch (java.security.NoSuchAlgorithmException ex) { } catch (java.security.NoSuchAlgorithmException ex) {
Object[] exArgs = { algorithmID, ex.getLocalizedMessage() }; Object[] exArgs = { algorithmID, ex.getLocalizedMessage() };
...@@ -85,20 +82,17 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi { ...@@ -85,20 +82,17 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
/** @inheritDoc */ /** @inheritDoc */
protected void engineSetParameter(AlgorithmParameterSpec params) protected void engineSetParameter(AlgorithmParameterSpec params)
throws XMLSignatureException { throws XMLSignatureException {
try { try {
this._signatureAlgorithm.setParameter(params); this.signatureAlgorithm.setParameter(params);
} catch (InvalidAlgorithmParameterException ex) { } catch (InvalidAlgorithmParameterException ex) {
throw new XMLSignatureException("empty", ex); throw new XMLSignatureException("empty", ex);
} }
} }
/** @inheritDoc */ /** @inheritDoc */
protected boolean engineVerify(byte[] signature) protected boolean engineVerify(byte[] signature) throws XMLSignatureException {
throws XMLSignatureException {
try { try {
return this._signatureAlgorithm.verify(signature); return this.signatureAlgorithm.verify(signature);
} catch (SignatureException ex) { } catch (SignatureException ex) {
throw new XMLSignatureException("empty", ex); throw new XMLSignatureException("empty", ex);
} }
...@@ -106,32 +100,29 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi { ...@@ -106,32 +100,29 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
/** @inheritDoc */ /** @inheritDoc */
protected void engineInitVerify(Key publicKey) throws XMLSignatureException { protected void engineInitVerify(Key publicKey) throws XMLSignatureException {
if (!(publicKey instanceof PublicKey)) { if (!(publicKey instanceof PublicKey)) {
String supplied = publicKey.getClass().getName(); String supplied = publicKey.getClass().getName();
String needed = PublicKey.class.getName(); String needed = PublicKey.class.getName();
Object exArgs[] = { supplied, needed }; Object exArgs[] = { supplied, needed };
throw new XMLSignatureException throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs);
("algorithms.WrongKeyForThisOperation", exArgs);
} }
try { try {
this._signatureAlgorithm.initVerify((PublicKey) publicKey); this.signatureAlgorithm.initVerify((PublicKey) publicKey);
} catch (InvalidKeyException ex) { } catch (InvalidKeyException ex) {
// reinstantiate Signature object to work around bug in JDK // reinstantiate Signature object to work around bug in JDK
// see: http://bugs.sun.com/view_bug.do?bug_id=4953555 // see: http://bugs.sun.com/view_bug.do?bug_id=4953555
Signature sig = this._signatureAlgorithm; Signature sig = this.signatureAlgorithm;
try { try {
this._signatureAlgorithm = Signature.getInstance this.signatureAlgorithm = Signature.getInstance(signatureAlgorithm.getAlgorithm());
(_signatureAlgorithm.getAlgorithm());
} catch (Exception e) { } catch (Exception e) {
// this shouldn't occur, but if it does, restore previous // this shouldn't occur, but if it does, restore previous
// Signature // Signature
if (log.isLoggable(java.util.logging.Level.FINE)) { if (log.isLoggable(java.util.logging.Level.FINE)) {
log.log(java.util.logging.Level.FINE, "Exception when reinstantiating Signature:" + e); log.log(java.util.logging.Level.FINE, "Exception when reinstantiating Signature:" + e);
} }
this._signatureAlgorithm = sig; this.signatureAlgorithm = sig;
} }
throw new XMLSignatureException("empty", ex); throw new XMLSignatureException("empty", ex);
} }
...@@ -140,7 +131,7 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi { ...@@ -140,7 +131,7 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
/** @inheritDoc */ /** @inheritDoc */
protected byte[] engineSign() throws XMLSignatureException { protected byte[] engineSign() throws XMLSignatureException {
try { try {
return this._signatureAlgorithm.sign(); return this.signatureAlgorithm.sign();
} catch (SignatureException ex) { } catch (SignatureException ex) {
throw new XMLSignatureException("empty", ex); throw new XMLSignatureException("empty", ex);
} }
...@@ -149,19 +140,16 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi { ...@@ -149,19 +140,16 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
/** @inheritDoc */ /** @inheritDoc */
protected void engineInitSign(Key privateKey, SecureRandom secureRandom) protected void engineInitSign(Key privateKey, SecureRandom secureRandom)
throws XMLSignatureException { throws XMLSignatureException {
if (!(privateKey instanceof PrivateKey)) { if (!(privateKey instanceof PrivateKey)) {
String supplied = privateKey.getClass().getName(); String supplied = privateKey.getClass().getName();
String needed = PrivateKey.class.getName(); String needed = PrivateKey.class.getName();
Object exArgs[] = { supplied, needed }; Object exArgs[] = { supplied, needed };
throw new XMLSignatureException throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs);
("algorithms.WrongKeyForThisOperation", exArgs);
} }
try { try {
this._signatureAlgorithm.initSign this.signatureAlgorithm.initSign((PrivateKey) privateKey, secureRandom);
((PrivateKey) privateKey, secureRandom);
} catch (InvalidKeyException ex) { } catch (InvalidKeyException ex) {
throw new XMLSignatureException("empty", ex); throw new XMLSignatureException("empty", ex);
} }
...@@ -169,18 +157,16 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi { ...@@ -169,18 +157,16 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
/** @inheritDoc */ /** @inheritDoc */
protected void engineInitSign(Key privateKey) throws XMLSignatureException { protected void engineInitSign(Key privateKey) throws XMLSignatureException {
if (!(privateKey instanceof PrivateKey)) { if (!(privateKey instanceof PrivateKey)) {
String supplied = privateKey.getClass().getName(); String supplied = privateKey.getClass().getName();
String needed = PrivateKey.class.getName(); String needed = PrivateKey.class.getName();
Object exArgs[] = { supplied, needed }; Object exArgs[] = { supplied, needed };
throw new XMLSignatureException throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs);
("algorithms.WrongKeyForThisOperation", exArgs);
} }
try { try {
this._signatureAlgorithm.initSign((PrivateKey) privateKey); this.signatureAlgorithm.initSign((PrivateKey) privateKey);
} catch (InvalidKeyException ex) { } catch (InvalidKeyException ex) {
throw new XMLSignatureException("empty", ex); throw new XMLSignatureException("empty", ex);
} }
...@@ -189,7 +175,7 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi { ...@@ -189,7 +175,7 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
/** @inheritDoc */ /** @inheritDoc */
protected void engineUpdate(byte[] input) throws XMLSignatureException { protected void engineUpdate(byte[] input) throws XMLSignatureException {
try { try {
this._signatureAlgorithm.update(input); this.signatureAlgorithm.update(input);
} catch (SignatureException ex) { } catch (SignatureException ex) {
throw new XMLSignatureException("empty", ex); throw new XMLSignatureException("empty", ex);
} }
...@@ -198,17 +184,16 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi { ...@@ -198,17 +184,16 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
/** @inheritDoc */ /** @inheritDoc */
protected void engineUpdate(byte input) throws XMLSignatureException { protected void engineUpdate(byte input) throws XMLSignatureException {
try { try {
this._signatureAlgorithm.update(input); this.signatureAlgorithm.update(input);
} catch (SignatureException ex) { } catch (SignatureException ex) {
throw new XMLSignatureException("empty", ex); throw new XMLSignatureException("empty", ex);
} }
} }
/** @inheritDoc */ /** @inheritDoc */
protected void engineUpdate(byte buf[], int offset, int len) protected void engineUpdate(byte buf[], int offset, int len) throws XMLSignatureException {
throws XMLSignatureException {
try { try {
this._signatureAlgorithm.update(buf, offset, len); this.signatureAlgorithm.update(buf, offset, len);
} catch (SignatureException ex) { } catch (SignatureException ex) {
throw new XMLSignatureException("empty", ex); throw new XMLSignatureException("empty", ex);
} }
...@@ -216,34 +201,29 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi { ...@@ -216,34 +201,29 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
/** @inheritDoc */ /** @inheritDoc */
protected String engineGetJCEAlgorithmString() { protected String engineGetJCEAlgorithmString() {
return this._signatureAlgorithm.getAlgorithm(); return this.signatureAlgorithm.getAlgorithm();
} }
/** @inheritDoc */ /** @inheritDoc */
protected String engineGetJCEProviderName() { protected String engineGetJCEProviderName() {
return this._signatureAlgorithm.getProvider().getName(); return this.signatureAlgorithm.getProvider().getName();
} }
/** @inheritDoc */ /** @inheritDoc */
protected void engineSetHMACOutputLength(int HMACOutputLength) protected void engineSetHMACOutputLength(int HMACOutputLength)
throws XMLSignatureException { throws XMLSignatureException {
throw new XMLSignatureException throw new XMLSignatureException("algorithms.HMACOutputLengthOnlyForHMAC");
("algorithms.HMACOutputLengthOnlyForHMAC");
} }
/** @inheritDoc */ /** @inheritDoc */
protected void engineInitSign( protected void engineInitSign(
Key signingKey, AlgorithmParameterSpec algorithmParameterSpec) Key signingKey, AlgorithmParameterSpec algorithmParameterSpec
throws XMLSignatureException { ) throws XMLSignatureException {
throw new XMLSignatureException( throw new XMLSignatureException("algorithms.CannotUseAlgorithmParameterSpecOnRSA");
"algorithms.CannotUseAlgorithmParameterSpecOnRSA");
} }
/** /**
* Class SignatureRSASHA1 * Class SignatureRSASHA1
*
* @author $Author: mullan $
* @version $Revision: 1.5 $
*/ */
public static class SignatureRSASHA1 extends SignatureBaseRSA { public static class SignatureRSASHA1 extends SignatureBaseRSA {
...@@ -264,9 +244,6 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi { ...@@ -264,9 +244,6 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
/** /**
* Class SignatureRSASHA256 * Class SignatureRSASHA256
*
* @author $Author: mullan $
* @version $Revision: 1.5 $
*/ */
public static class SignatureRSASHA256 extends SignatureBaseRSA { public static class SignatureRSASHA256 extends SignatureBaseRSA {
...@@ -287,9 +264,6 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi { ...@@ -287,9 +264,6 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
/** /**
* Class SignatureRSASHA384 * Class SignatureRSASHA384
*
* @author $Author: mullan $
* @version $Revision: 1.5 $
*/ */
public static class SignatureRSASHA384 extends SignatureBaseRSA { public static class SignatureRSASHA384 extends SignatureBaseRSA {
...@@ -310,9 +284,6 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi { ...@@ -310,9 +284,6 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
/** /**
* Class SignatureRSASHA512 * Class SignatureRSASHA512
*
* @author $Author: mullan $
* @version $Revision: 1.5 $
*/ */
public static class SignatureRSASHA512 extends SignatureBaseRSA { public static class SignatureRSASHA512 extends SignatureBaseRSA {
...@@ -333,9 +304,6 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi { ...@@ -333,9 +304,6 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
/** /**
* Class SignatureRSARIPEMD160 * Class SignatureRSARIPEMD160
*
* @author $Author: mullan $
* @version $Revision: 1.5 $
*/ */
public static class SignatureRSARIPEMD160 extends SignatureBaseRSA { public static class SignatureRSARIPEMD160 extends SignatureBaseRSA {
...@@ -356,9 +324,6 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi { ...@@ -356,9 +324,6 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
/** /**
* Class SignatureRSAMD5 * Class SignatureRSAMD5
*
* @author $Author: mullan $
* @version $Revision: 1.5 $
*/ */
public static class SignatureRSAMD5 extends SignatureBaseRSA { public static class SignatureRSAMD5 extends SignatureBaseRSA {
......
...@@ -2,21 +2,23 @@ ...@@ -2,21 +2,23 @@
* reserved comment block * reserved comment block
* DO NOT REMOVE OR ALTER! * DO NOT REMOVE OR ALTER!
*/ */
/* /**
* Copyright 1999-2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one
* * or more contributor license agreements. See the NOTICE file
* Licensed under the Apache License, Version 2.0 (the "License"); * distributed with this work for additional information
* you may not use this file except in compliance with the License. * regarding copyright ownership. The ASF licenses this file
* You may obtain a copy of the License at * to you under the Apache License, Version 2.0 (the
* * "License"); you may not use this file except in compliance
* http://www.apache.org/licenses/LICENSE-2.0 * with the License. You may obtain a copy of the License at
* *
* Unless required by applicable law or agreed to in writing, software * http://www.apache.org/licenses/LICENSE-2.0
* 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.
* *
* 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.
*/ */
package com.sun.org.apache.xml.internal.security.algorithms.implementations; package com.sun.org.apache.xml.internal.security.algorithms.implementations;
...@@ -37,21 +39,17 @@ import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException; ...@@ -37,21 +39,17 @@ import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException;
import com.sun.org.apache.xml.internal.security.utils.Base64; import com.sun.org.apache.xml.internal.security.utils.Base64;
import com.sun.org.apache.xml.internal.security.utils.Constants; import com.sun.org.apache.xml.internal.security.utils.Constants;
/**
*
* @author $Author: mullan $
*/
public class SignatureDSA extends SignatureAlgorithmSpi { public class SignatureDSA extends SignatureAlgorithmSpi {
/** {@link java.util.logging} logging facility */ /** {@link org.apache.commons.logging} logging facility */
static java.util.logging.Logger log = private static java.util.logging.Logger log =
java.util.logging.Logger.getLogger(SignatureDSA.class.getName()); java.util.logging.Logger.getLogger(SignatureDSA.class.getName());
/** Field _URI */ /** Field URI */
public static final String _URI = Constants.SignatureSpecNS + "dsa-sha1"; public static final String URI = Constants.SignatureSpecNS + "dsa-sha1";
/** Field algorithm */ /** Field algorithm */
private java.security.Signature _signatureAlgorithm = null; private java.security.Signature signatureAlgorithm = null;
/** /**
* Method engineGetURI * Method engineGetURI
...@@ -59,7 +57,7 @@ public class SignatureDSA extends SignatureAlgorithmSpi { ...@@ -59,7 +57,7 @@ public class SignatureDSA extends SignatureAlgorithmSpi {
* @inheritDoc * @inheritDoc
*/ */
protected String engineGetURI() { protected String engineGetURI() {
return SignatureDSA._URI; return SignatureDSA.URI;
} }
/** /**
...@@ -68,17 +66,17 @@ public class SignatureDSA extends SignatureAlgorithmSpi { ...@@ -68,17 +66,17 @@ public class SignatureDSA extends SignatureAlgorithmSpi {
* @throws XMLSignatureException * @throws XMLSignatureException
*/ */
public SignatureDSA() throws XMLSignatureException { public SignatureDSA() throws XMLSignatureException {
String algorithmID = JCEMapper.translateURItoJCEID(SignatureDSA.URI);
String algorithmID = JCEMapper.translateURItoJCEID(SignatureDSA._URI); if (log.isLoggable(java.util.logging.Level.FINE)) {
if (log.isLoggable(java.util.logging.Level.FINE))
log.log(java.util.logging.Level.FINE, "Created SignatureDSA using " + algorithmID); log.log(java.util.logging.Level.FINE, "Created SignatureDSA using " + algorithmID);
}
String provider = JCEMapper.getProviderId(); String provider = JCEMapper.getProviderId();
try { try {
if (provider == null) { if (provider == null) {
this._signatureAlgorithm = Signature.getInstance(algorithmID); this.signatureAlgorithm = Signature.getInstance(algorithmID);
} else { } else {
this._signatureAlgorithm = this.signatureAlgorithm =
Signature.getInstance(algorithmID, provider); Signature.getInstance(algorithmID, provider);
} }
} catch (java.security.NoSuchAlgorithmException ex) { } catch (java.security.NoSuchAlgorithmException ex) {
...@@ -95,9 +93,8 @@ public class SignatureDSA extends SignatureAlgorithmSpi { ...@@ -95,9 +93,8 @@ public class SignatureDSA extends SignatureAlgorithmSpi {
*/ */
protected void engineSetParameter(AlgorithmParameterSpec params) protected void engineSetParameter(AlgorithmParameterSpec params)
throws XMLSignatureException { throws XMLSignatureException {
try { try {
this._signatureAlgorithm.setParameter(params); this.signatureAlgorithm.setParameter(params);
} catch (InvalidAlgorithmParameterException ex) { } catch (InvalidAlgorithmParameterException ex) {
throw new XMLSignatureException("empty", ex); throw new XMLSignatureException("empty", ex);
} }
...@@ -107,15 +104,15 @@ public class SignatureDSA extends SignatureAlgorithmSpi { ...@@ -107,15 +104,15 @@ public class SignatureDSA extends SignatureAlgorithmSpi {
* @inheritDoc * @inheritDoc
*/ */
protected boolean engineVerify(byte[] signature) protected boolean engineVerify(byte[] signature)
throws XMLSignatureException { throws XMLSignatureException {
try { try {
if (log.isLoggable(java.util.logging.Level.FINE)) if (log.isLoggable(java.util.logging.Level.FINE)) {
log.log(java.util.logging.Level.FINE, "Called DSA.verify() on " + Base64.encode(signature)); log.log(java.util.logging.Level.FINE, "Called DSA.verify() on " + Base64.encode(signature));
}
byte[] jcebytes = SignatureDSA.convertXMLDSIGtoASN1(signature); byte[] jcebytes = SignatureDSA.convertXMLDSIGtoASN1(signature);
return this._signatureAlgorithm.verify(jcebytes); return this.signatureAlgorithm.verify(jcebytes);
} catch (SignatureException ex) { } catch (SignatureException ex) {
throw new XMLSignatureException("empty", ex); throw new XMLSignatureException("empty", ex);
} catch (IOException ex) { } catch (IOException ex) {
...@@ -127,32 +124,29 @@ public class SignatureDSA extends SignatureAlgorithmSpi { ...@@ -127,32 +124,29 @@ public class SignatureDSA extends SignatureAlgorithmSpi {
* @inheritDoc * @inheritDoc
*/ */
protected void engineInitVerify(Key publicKey) throws XMLSignatureException { protected void engineInitVerify(Key publicKey) throws XMLSignatureException {
if (!(publicKey instanceof PublicKey)) { if (!(publicKey instanceof PublicKey)) {
String supplied = publicKey.getClass().getName(); String supplied = publicKey.getClass().getName();
String needed = PublicKey.class.getName(); String needed = PublicKey.class.getName();
Object exArgs[] = { supplied, needed }; Object exArgs[] = { supplied, needed };
throw new XMLSignatureException throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs);
("algorithms.WrongKeyForThisOperation", exArgs);
} }
try { try {
this._signatureAlgorithm.initVerify((PublicKey) publicKey); this.signatureAlgorithm.initVerify((PublicKey) publicKey);
} catch (InvalidKeyException ex) { } catch (InvalidKeyException ex) {
// reinstantiate Signature object to work around bug in JDK // reinstantiate Signature object to work around bug in JDK
// see: http://bugs.sun.com/view_bug.do?bug_id=4953555 // see: http://bugs.sun.com/view_bug.do?bug_id=4953555
Signature sig = this._signatureAlgorithm; Signature sig = this.signatureAlgorithm;
try { try {
this._signatureAlgorithm = Signature.getInstance this.signatureAlgorithm = Signature.getInstance(signatureAlgorithm.getAlgorithm());
(_signatureAlgorithm.getAlgorithm());
} catch (Exception e) { } catch (Exception e) {
// this shouldn't occur, but if it does, restore previous // this shouldn't occur, but if it does, restore previous
// Signature // Signature
if (log.isLoggable(java.util.logging.Level.FINE)) { if (log.isLoggable(java.util.logging.Level.FINE)) {
log.log(java.util.logging.Level.FINE, "Exception when reinstantiating Signature:" + e); log.log(java.util.logging.Level.FINE, "Exception when reinstantiating Signature:" + e);
} }
this._signatureAlgorithm = sig; this.signatureAlgorithm = sig;
} }
throw new XMLSignatureException("empty", ex); throw new XMLSignatureException("empty", ex);
} }
...@@ -162,9 +156,8 @@ public class SignatureDSA extends SignatureAlgorithmSpi { ...@@ -162,9 +156,8 @@ public class SignatureDSA extends SignatureAlgorithmSpi {
* @inheritDoc * @inheritDoc
*/ */
protected byte[] engineSign() throws XMLSignatureException { protected byte[] engineSign() throws XMLSignatureException {
try { try {
byte jcebytes[] = this._signatureAlgorithm.sign(); byte jcebytes[] = this.signatureAlgorithm.sign();
return SignatureDSA.convertASN1toXMLDSIG(jcebytes); return SignatureDSA.convertASN1toXMLDSIG(jcebytes);
} catch (IOException ex) { } catch (IOException ex) {
...@@ -178,20 +171,17 @@ public class SignatureDSA extends SignatureAlgorithmSpi { ...@@ -178,20 +171,17 @@ public class SignatureDSA extends SignatureAlgorithmSpi {
* @inheritDoc * @inheritDoc
*/ */
protected void engineInitSign(Key privateKey, SecureRandom secureRandom) protected void engineInitSign(Key privateKey, SecureRandom secureRandom)
throws XMLSignatureException { throws XMLSignatureException {
if (!(privateKey instanceof PrivateKey)) { if (!(privateKey instanceof PrivateKey)) {
String supplied = privateKey.getClass().getName(); String supplied = privateKey.getClass().getName();
String needed = PrivateKey.class.getName(); String needed = PrivateKey.class.getName();
Object exArgs[] = { supplied, needed }; Object exArgs[] = { supplied, needed };
throw new XMLSignatureException throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs);
("algorithms.WrongKeyForThisOperation", exArgs);
} }
try { try {
this._signatureAlgorithm.initSign((PrivateKey) privateKey, this.signatureAlgorithm.initSign((PrivateKey) privateKey, secureRandom);
secureRandom);
} catch (InvalidKeyException ex) { } catch (InvalidKeyException ex) {
throw new XMLSignatureException("empty", ex); throw new XMLSignatureException("empty", ex);
} }
...@@ -201,18 +191,16 @@ public class SignatureDSA extends SignatureAlgorithmSpi { ...@@ -201,18 +191,16 @@ public class SignatureDSA extends SignatureAlgorithmSpi {
* @inheritDoc * @inheritDoc
*/ */
protected void engineInitSign(Key privateKey) throws XMLSignatureException { protected void engineInitSign(Key privateKey) throws XMLSignatureException {
if (!(privateKey instanceof PrivateKey)) { if (!(privateKey instanceof PrivateKey)) {
String supplied = privateKey.getClass().getName(); String supplied = privateKey.getClass().getName();
String needed = PrivateKey.class.getName(); String needed = PrivateKey.class.getName();
Object exArgs[] = { supplied, needed }; Object exArgs[] = { supplied, needed };
throw new XMLSignatureException throw new XMLSignatureException("algorithms.WrongKeyForThisOperation", exArgs);
("algorithms.WrongKeyForThisOperation", exArgs);
} }
try { try {
this._signatureAlgorithm.initSign((PrivateKey) privateKey); this.signatureAlgorithm.initSign((PrivateKey) privateKey);
} catch (InvalidKeyException ex) { } catch (InvalidKeyException ex) {
throw new XMLSignatureException("empty", ex); throw new XMLSignatureException("empty", ex);
} }
...@@ -223,7 +211,7 @@ public class SignatureDSA extends SignatureAlgorithmSpi { ...@@ -223,7 +211,7 @@ public class SignatureDSA extends SignatureAlgorithmSpi {
*/ */
protected void engineUpdate(byte[] input) throws XMLSignatureException { protected void engineUpdate(byte[] input) throws XMLSignatureException {
try { try {
this._signatureAlgorithm.update(input); this.signatureAlgorithm.update(input);
} catch (SignatureException ex) { } catch (SignatureException ex) {
throw new XMLSignatureException("empty", ex); throw new XMLSignatureException("empty", ex);
} }
...@@ -234,7 +222,7 @@ public class SignatureDSA extends SignatureAlgorithmSpi { ...@@ -234,7 +222,7 @@ public class SignatureDSA extends SignatureAlgorithmSpi {
*/ */
protected void engineUpdate(byte input) throws XMLSignatureException { protected void engineUpdate(byte input) throws XMLSignatureException {
try { try {
this._signatureAlgorithm.update(input); this.signatureAlgorithm.update(input);
} catch (SignatureException ex) { } catch (SignatureException ex) {
throw new XMLSignatureException("empty", ex); throw new XMLSignatureException("empty", ex);
} }
...@@ -243,10 +231,9 @@ public class SignatureDSA extends SignatureAlgorithmSpi { ...@@ -243,10 +231,9 @@ public class SignatureDSA extends SignatureAlgorithmSpi {
/** /**
* @inheritDoc * @inheritDoc
*/ */
protected void engineUpdate(byte buf[], int offset, int len) protected void engineUpdate(byte buf[], int offset, int len) throws XMLSignatureException {
throws XMLSignatureException {
try { try {
this._signatureAlgorithm.update(buf, offset, len); this.signatureAlgorithm.update(buf, offset, len);
} catch (SignatureException ex) { } catch (SignatureException ex) {
throw new XMLSignatureException("empty", ex); throw new XMLSignatureException("empty", ex);
} }
...@@ -258,7 +245,7 @@ public class SignatureDSA extends SignatureAlgorithmSpi { ...@@ -258,7 +245,7 @@ public class SignatureDSA extends SignatureAlgorithmSpi {
* @inheritDoc * @inheritDoc
*/ */
protected String engineGetJCEAlgorithmString() { protected String engineGetJCEAlgorithmString() {
return this._signatureAlgorithm.getAlgorithm(); return this.signatureAlgorithm.getAlgorithm();
} }
/** /**
...@@ -267,7 +254,7 @@ public class SignatureDSA extends SignatureAlgorithmSpi { ...@@ -267,7 +254,7 @@ public class SignatureDSA extends SignatureAlgorithmSpi {
* @inheritDoc * @inheritDoc
*/ */
protected String engineGetJCEProviderName() { protected String engineGetJCEProviderName() {
return this._signatureAlgorithm.getProvider().getName(); return this.signatureAlgorithm.getProvider().getName();
} }
/** /**
...@@ -282,8 +269,7 @@ public class SignatureDSA extends SignatureAlgorithmSpi { ...@@ -282,8 +269,7 @@ public class SignatureDSA extends SignatureAlgorithmSpi {
* @throws IOException * @throws IOException
* @see <A HREF="http://www.w3.org/TR/xmldsig-core/#dsa-sha1">6.4.1 DSA</A> * @see <A HREF="http://www.w3.org/TR/xmldsig-core/#dsa-sha1">6.4.1 DSA</A>
*/ */
private static byte[] convertASN1toXMLDSIG(byte asn1Bytes[]) private static byte[] convertASN1toXMLDSIG(byte asn1Bytes[]) throws IOException {
throws IOException {
byte rLength = asn1Bytes[3]; byte rLength = asn1Bytes[3];
int i; int i;
...@@ -294,19 +280,18 @@ public class SignatureDSA extends SignatureAlgorithmSpi { ...@@ -294,19 +280,18 @@ public class SignatureDSA extends SignatureAlgorithmSpi {
int j; int j;
for (j = sLength; for (j = sLength;
(j > 0) && (asn1Bytes[(6 + rLength + sLength) - j] == 0); j--); (j > 0) && (asn1Bytes[(6 + rLength + sLength) - j] == 0); j--);
if ((asn1Bytes[0] != 48) || (asn1Bytes[1] != asn1Bytes.length - 2) if ((asn1Bytes[0] != 48) || (asn1Bytes[1] != asn1Bytes.length - 2)
|| (asn1Bytes[2] != 2) || (i > 20) || (asn1Bytes[2] != 2) || (i > 20)
|| (asn1Bytes[4 + rLength] != 2) || (j > 20)) { || (asn1Bytes[4 + rLength] != 2) || (j > 20)) {
throw new IOException("Invalid ASN.1 format of DSA signature"); throw new IOException("Invalid ASN.1 format of DSA signature");
} }
byte xmldsigBytes[] = new byte[40]; byte xmldsigBytes[] = new byte[40];
System.arraycopy(asn1Bytes, (4 + rLength) - i, xmldsigBytes, 20 - i, System.arraycopy(asn1Bytes, (4 + rLength) - i, xmldsigBytes, 20 - i, i);
i);
System.arraycopy(asn1Bytes, (6 + rLength + sLength) - j, xmldsigBytes, System.arraycopy(asn1Bytes, (6 + rLength + sLength) - j, xmldsigBytes,
40 - j, j); 40 - j, j);
return xmldsigBytes; return xmldsigBytes;
} }
...@@ -323,8 +308,7 @@ public class SignatureDSA extends SignatureAlgorithmSpi { ...@@ -323,8 +308,7 @@ public class SignatureDSA extends SignatureAlgorithmSpi {
* @throws IOException * @throws IOException
* @see <A HREF="http://www.w3.org/TR/xmldsig-core/#dsa-sha1">6.4.1 DSA</A> * @see <A HREF="http://www.w3.org/TR/xmldsig-core/#dsa-sha1">6.4.1 DSA</A>
*/ */
private static byte[] convertXMLDSIGtoASN1(byte xmldsigBytes[]) private static byte[] convertXMLDSIGtoASN1(byte xmldsigBytes[]) throws IOException {
throws IOException {
if (xmldsigBytes.length != 40) { if (xmldsigBytes.length != 40) {
throw new IOException("Invalid XMLDSIG format of DSA signature"); throw new IOException("Invalid XMLDSIG format of DSA signature");
...@@ -337,7 +321,7 @@ public class SignatureDSA extends SignatureAlgorithmSpi { ...@@ -337,7 +321,7 @@ public class SignatureDSA extends SignatureAlgorithmSpi {
int j = i; int j = i;
if (xmldsigBytes[20 - i] < 0) { if (xmldsigBytes[20 - i] < 0) {
j += 1; j += 1;
} }
int k; int k;
...@@ -373,10 +357,8 @@ public class SignatureDSA extends SignatureAlgorithmSpi { ...@@ -373,10 +357,8 @@ public class SignatureDSA extends SignatureAlgorithmSpi {
* @param HMACOutputLength * @param HMACOutputLength
* @throws XMLSignatureException * @throws XMLSignatureException
*/ */
protected void engineSetHMACOutputLength(int HMACOutputLength) protected void engineSetHMACOutputLength(int HMACOutputLength) throws XMLSignatureException {
throws XMLSignatureException { throw new XMLSignatureException("algorithms.HMACOutputLengthOnlyForHMAC");
throw new XMLSignatureException(
"algorithms.HMACOutputLengthOnlyForHMAC");
} }
/** /**
...@@ -387,9 +369,8 @@ public class SignatureDSA extends SignatureAlgorithmSpi { ...@@ -387,9 +369,8 @@ public class SignatureDSA extends SignatureAlgorithmSpi {
* @throws XMLSignatureException * @throws XMLSignatureException
*/ */
protected void engineInitSign( protected void engineInitSign(
Key signingKey, AlgorithmParameterSpec algorithmParameterSpec) Key signingKey, AlgorithmParameterSpec algorithmParameterSpec
throws XMLSignatureException { ) throws XMLSignatureException {
throw new XMLSignatureException( throw new XMLSignatureException("algorithms.CannotUseAlgorithmParameterSpecOnDSA");
"algorithms.CannotUseAlgorithmParameterSpecOnDSA");
} }
} }
...@@ -2,29 +2,28 @@ ...@@ -2,29 +2,28 @@
* reserved comment block * reserved comment block
* DO NOT REMOVE OR ALTER! * DO NOT REMOVE OR ALTER!
*/ */
/* /**
* Copyright 1999-2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one
* * or more contributor license agreements. See the NOTICE file
* Licensed under the Apache License, Version 2.0 (the "License"); * distributed with this work for additional information
* you may not use this file except in compliance with the License. * regarding copyright ownership. The ASF licenses this file
* You may obtain a copy of the License at * to you under the Apache License, Version 2.0 (the
* * "License"); you may not use this file except in compliance
* http://www.apache.org/licenses/LICENSE-2.0 * with the License. You may obtain a copy of the License at
* *
* Unless required by applicable law or agreed to in writing, software * http://www.apache.org/licenses/LICENSE-2.0
* 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.
* *
* 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.
*/ */
package com.sun.org.apache.xml.internal.security.c14n; package com.sun.org.apache.xml.internal.security.c14n;
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException; import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
/** /**
* Class CanonicalizationException * Class CanonicalizationException
* *
...@@ -32,57 +31,58 @@ import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException; ...@@ -32,57 +31,58 @@ import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
*/ */
public class CanonicalizationException extends XMLSecurityException { public class CanonicalizationException extends XMLSecurityException {
/** /**
* *
*/ */
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* Constructor CanonicalizationException * Constructor CanonicalizationException
* *
*/ */
public CanonicalizationException() { public CanonicalizationException() {
super(); super();
} }
/** /**
* Constructor CanonicalizationException * Constructor CanonicalizationException
* *
* @param _msgID * @param msgID
*/ */
public CanonicalizationException(String _msgID) { public CanonicalizationException(String msgID) {
super(_msgID); super(msgID);
} }
/** /**
* Constructor CanonicalizationException * Constructor CanonicalizationException
* *
* @param _msgID * @param msgID
* @param exArgs * @param exArgs
*/ */
public CanonicalizationException(String _msgID, Object exArgs[]) { public CanonicalizationException(String msgID, Object exArgs[]) {
super(_msgID, exArgs); super(msgID, exArgs);
} }
/** /**
* Constructor CanonicalizationException * Constructor CanonicalizationException
* *
* @param _msgID * @param msgID
* @param _originalException * @param originalException
*/ */
public CanonicalizationException(String _msgID, Exception _originalException) { public CanonicalizationException(String msgID, Exception originalException) {
super(_msgID, _originalException); super(msgID, originalException);
} }
/** /**
* Constructor CanonicalizationException * Constructor CanonicalizationException
* *
* @param _msgID * @param msgID
* @param exArgs * @param exArgs
* @param _originalException * @param originalException
*/ */
public CanonicalizationException(String _msgID, Object exArgs[], public CanonicalizationException(
Exception _originalException) { String msgID, Object exArgs[], Exception originalException
super(_msgID, exArgs, _originalException); ) {
} super(msgID, exArgs, originalException);
}
} }
...@@ -39,6 +39,7 @@ import com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicaliz ...@@ -39,6 +39,7 @@ import com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicaliz
import com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer20010315ExclWithComments; import com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer20010315ExclWithComments;
import com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer20010315OmitComments; import com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer20010315OmitComments;
import com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer20010315WithComments; import com.sun.org.apache.xml.internal.security.c14n.implementations.Canonicalizer20010315WithComments;
import com.sun.org.apache.xml.internal.security.c14n.implementations.CanonicalizerPhysical;
import com.sun.org.apache.xml.internal.security.exceptions.AlgorithmAlreadyRegisteredException; import com.sun.org.apache.xml.internal.security.exceptions.AlgorithmAlreadyRegisteredException;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Node; import org.w3c.dom.Node;
...@@ -91,6 +92,11 @@ public class Canonicalizer { ...@@ -91,6 +92,11 @@ public class Canonicalizer {
*/ */
public static final String ALGO_ID_C14N11_WITH_COMMENTS = public static final String ALGO_ID_C14N11_WITH_COMMENTS =
ALGO_ID_C14N11_OMIT_COMMENTS + "#WithComments"; ALGO_ID_C14N11_OMIT_COMMENTS + "#WithComments";
/**
* Non-standard algorithm to serialize the physical representation for XML Encryption
*/
public static final String ALGO_ID_C14N_PHYSICAL =
"http://santuario.apache.org/c14n/physical";
private static Map<String, Class<? extends CanonicalizerSpi>> canonicalizerHash = private static Map<String, Class<? extends CanonicalizerSpi>> canonicalizerHash =
new ConcurrentHashMap<String, Class<? extends CanonicalizerSpi>>(); new ConcurrentHashMap<String, Class<? extends CanonicalizerSpi>>();
...@@ -202,6 +208,10 @@ public class Canonicalizer { ...@@ -202,6 +208,10 @@ public class Canonicalizer {
Canonicalizer.ALGO_ID_C14N11_WITH_COMMENTS, Canonicalizer.ALGO_ID_C14N11_WITH_COMMENTS,
Canonicalizer11_WithComments.class Canonicalizer11_WithComments.class
); );
canonicalizerHash.put(
Canonicalizer.ALGO_ID_C14N_PHYSICAL,
CanonicalizerPhysical.class
);
} }
/** /**
......
...@@ -2,26 +2,26 @@ ...@@ -2,26 +2,26 @@
* reserved comment block * reserved comment block
* DO NOT REMOVE OR ALTER! * DO NOT REMOVE OR ALTER!
*/ */
/* /**
* Copyright 1999-2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one
* * or more contributor license agreements. See the NOTICE file
* Licensed under the Apache License, Version 2.0 (the "License"); * distributed with this work for additional information
* you may not use this file except in compliance with the License. * regarding copyright ownership. The ASF licenses this file
* You may obtain a copy of the License at * to you under the Apache License, Version 2.0 (the
* * "License"); you may not use this file except in compliance
* http://www.apache.org/licenses/LICENSE-2.0 * with the License. You may obtain a copy of the License at
* *
* Unless required by applicable law or agreed to in writing, software * http://www.apache.org/licenses/LICENSE-2.0
* 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.
* *
* 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.
*/ */
package com.sun.org.apache.xml.internal.security.c14n; package com.sun.org.apache.xml.internal.security.c14n;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.Set; import java.util.Set;
...@@ -29,7 +29,6 @@ import java.util.Set; ...@@ -29,7 +29,6 @@ import java.util.Set;
import javax.xml.XMLConstants; import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.xpath.XPath;
import com.sun.org.apache.xml.internal.security.utils.XMLUtils; import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
import org.w3c.dom.Document; import org.w3c.dom.Document;
...@@ -37,166 +36,134 @@ import org.w3c.dom.Node; ...@@ -37,166 +36,134 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
/** /**
* Base class which all Caninicalization algorithms extend. * Base class which all Canonicalization algorithms extend.
* *
* $todo$ cange JavaDoc
* @author Christian Geuer-Pollmann * @author Christian Geuer-Pollmann
*/ */
public abstract class CanonicalizerSpi { public abstract class CanonicalizerSpi {
/** /** Reset the writer after a c14n */
* Method canonicalize protected boolean reset = false;
*
* /**
* @param inputBytes * Method canonicalize
* @return the c14n bytes. *
* * @param inputBytes
* * @return the c14n bytes.
* @throws CanonicalizationException *
* @throws java.io.IOException * @throws CanonicalizationException
* @throws javax.xml.parsers.ParserConfigurationException * @throws java.io.IOException
* @throws org.xml.sax.SAXException * @throws javax.xml.parsers.ParserConfigurationException
* * @throws org.xml.sax.SAXException
*/ */
public byte[] engineCanonicalize(byte[] inputBytes) public byte[] engineCanonicalize(byte[] inputBytes)
throws javax.xml.parsers.ParserConfigurationException, throws javax.xml.parsers.ParserConfigurationException, java.io.IOException,
java.io.IOException, org.xml.sax.SAXException, org.xml.sax.SAXException, CanonicalizationException {
CanonicalizationException {
java.io.InputStream bais = new ByteArrayInputStream(inputBytes);
java.io.ByteArrayInputStream bais = new ByteArrayInputStream(inputBytes); InputSource in = new InputSource(bais);
InputSource in = new InputSource(bais); DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance(); dfactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
dfactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
// needs to validate for ID attribute normalization
// needs to validate for ID attribute nomalization dfactory.setNamespaceAware(true);
dfactory.setNamespaceAware(true);
DocumentBuilder db = dfactory.newDocumentBuilder();
DocumentBuilder db = dfactory.newDocumentBuilder();
Document document = db.parse(in);
/* return this.engineCanonicalizeSubTree(document);
* for some of the test vectors from the specification, }
* there has to be a validatin parser for ID attributes, default
* attribute values, NMTOKENS, etc. /**
* Unfortunaltely, the test vectors do use different DTDs or * Method engineCanonicalizeXPathNodeSet
* even no DTD. So Xerces 1.3.1 fires many warnings about using *
* ErrorHandlers. * @param xpathNodeSet
* * @return the c14n bytes
* Text from the spec: * @throws CanonicalizationException
* */
* The input octet stream MUST contain a well-formed XML document, public byte[] engineCanonicalizeXPathNodeSet(NodeList xpathNodeSet)
* but the input need not be validated. However, the attribute throws CanonicalizationException {
* value normalization and entity reference resolution MUST be return this.engineCanonicalizeXPathNodeSet(
* performed in accordance with the behaviors of a validating XMLUtils.convertNodelistToSet(xpathNodeSet)
* XML processor. As well, nodes for default attributes (declared );
* in the ATTLIST with an AttValue but not specified) are created }
* in each element. Thus, the declarations in the document type
* declaration are used to help create the canonical form, even /**
* though the document type declaration is not retained in the * Method engineCanonicalizeXPathNodeSet
* canonical form. *
* * @param xpathNodeSet
*/ * @param inclusiveNamespaces
* @return the c14n bytes
// ErrorHandler eh = new C14NErrorHandler(); * @throws CanonicalizationException
// db.setErrorHandler(eh); */
Document document = db.parse(in); public byte[] engineCanonicalizeXPathNodeSet(NodeList xpathNodeSet, String inclusiveNamespaces)
byte result[] = this.engineCanonicalizeSubTree(document); throws CanonicalizationException {
return result; return this.engineCanonicalizeXPathNodeSet(
} XMLUtils.convertNodelistToSet(xpathNodeSet), inclusiveNamespaces
);
/** }
* Method engineCanonicalizeXPathNodeSet
* /**
* @param xpathNodeSet * Returns the URI of this engine.
* @return the c14n bytes * @return the URI
* @throws CanonicalizationException */
*/ public abstract String engineGetURI();
public byte[] engineCanonicalizeXPathNodeSet(NodeList xpathNodeSet)
throws CanonicalizationException { /**
* Returns true if comments are included
return this * @return true if comments are included
.engineCanonicalizeXPathNodeSet(XMLUtils */
.convertNodelistToSet(xpathNodeSet)); public abstract boolean engineGetIncludeComments();
}
/**
/** * C14n a nodeset
* Method engineCanonicalizeXPathNodeSet *
* * @param xpathNodeSet
* @param xpathNodeSet * @return the c14n bytes
* @param inclusiveNamespaces * @throws CanonicalizationException
* @return the c14n bytes */
* @throws CanonicalizationException public abstract byte[] engineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet)
*/ throws CanonicalizationException;
public byte[] engineCanonicalizeXPathNodeSet(NodeList xpathNodeSet, String inclusiveNamespaces)
throws CanonicalizationException { /**
* C14n a nodeset
return this *
.engineCanonicalizeXPathNodeSet(XMLUtils * @param xpathNodeSet
.convertNodelistToSet(xpathNodeSet), inclusiveNamespaces); * @param inclusiveNamespaces
} * @return the c14n bytes
* @throws CanonicalizationException
//J- */
/** Returns the URI of this engine. public abstract byte[] engineCanonicalizeXPathNodeSet(
* @return the URI Set<Node> xpathNodeSet, String inclusiveNamespaces
*/ ) throws CanonicalizationException;
public abstract String engineGetURI();
/**
/** Returns the URI if include comments * C14n a node tree.
* @return true if include. *
*/ * @param rootNode
public abstract boolean engineGetIncludeComments(); * @return the c14n bytes
* @throws CanonicalizationException
/** */
* C14n a nodeset public abstract byte[] engineCanonicalizeSubTree(Node rootNode)
* throws CanonicalizationException;
* @param xpathNodeSet
* @return the c14n bytes /**
* @throws CanonicalizationException * C14n a node tree.
*/ *
public abstract byte[] engineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet) * @param rootNode
throws CanonicalizationException; * @param inclusiveNamespaces
* @return the c14n bytes
/** * @throws CanonicalizationException
* C14n a nodeset */
* public abstract byte[] engineCanonicalizeSubTree(Node rootNode, String inclusiveNamespaces)
* @param xpathNodeSet throws CanonicalizationException;
* @param inclusiveNamespaces
* @return the c14n bytes /**
* @throws CanonicalizationException * Sets the writer where the canonicalization ends. ByteArrayOutputStream if
*/ * none is set.
public abstract byte[] engineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet, String inclusiveNamespaces) * @param os
throws CanonicalizationException; */
public abstract void setWriter(OutputStream os);
/**
* C14n a node tree.
*
* @param rootNode
* @return the c14n bytes
* @throws CanonicalizationException
*/
public abstract byte[] engineCanonicalizeSubTree(Node rootNode)
throws CanonicalizationException;
/**
* C14n a node tree.
*
* @param rootNode
* @param inclusiveNamespaces
* @return the c14n bytes
* @throws CanonicalizationException
*/
public abstract byte[] engineCanonicalizeSubTree(Node rootNode, String inclusiveNamespaces)
throws CanonicalizationException;
/**
* Sets the writter where the cannocalization ends. ByteArrayOutputStream if
* none is setted.
* @param os
*/
public abstract void setWriter(OutputStream os);
/** Reset the writter after a c14n */
protected boolean reset=false;
//J+
} }
...@@ -2,87 +2,82 @@ ...@@ -2,87 +2,82 @@
* reserved comment block * reserved comment block
* DO NOT REMOVE OR ALTER! * DO NOT REMOVE OR ALTER!
*/ */
/* /**
* Copyright 1999-2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one
* * or more contributor license agreements. See the NOTICE file
* Licensed under the Apache License, Version 2.0 (the "License"); * distributed with this work for additional information
* you may not use this file except in compliance with the License. * regarding copyright ownership. The ASF licenses this file
* You may obtain a copy of the License at * to you under the Apache License, Version 2.0 (the
* * "License"); you may not use this file except in compliance
* http://www.apache.org/licenses/LICENSE-2.0 * with the License. You may obtain a copy of the License at
* *
* Unless required by applicable law or agreed to in writing, software * http://www.apache.org/licenses/LICENSE-2.0
* 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.
* *
* 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.
*/ */
package com.sun.org.apache.xml.internal.security.c14n; package com.sun.org.apache.xml.internal.security.c14n;
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException; import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
/**
*
* @author Christian Geuer-Pollmann
*/
public class InvalidCanonicalizerException extends XMLSecurityException { public class InvalidCanonicalizerException extends XMLSecurityException {
/** /**
* *
*/ */
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* Constructor InvalidCanonicalizerException * Constructor InvalidCanonicalizerException
* *
*/ */
public InvalidCanonicalizerException() { public InvalidCanonicalizerException() {
super(); super();
} }
/** /**
* Constructor InvalidCanonicalizerException * Constructor InvalidCanonicalizerException
* *
* @param _msgID * @param msgID
*/ */
public InvalidCanonicalizerException(String _msgID) { public InvalidCanonicalizerException(String msgID) {
super(_msgID); super(msgID);
} }
/** /**
* Constructor InvalidCanonicalizerException * Constructor InvalidCanonicalizerException
* *
* @param _msgID * @param msgID
* @param exArgs * @param exArgs
*/ */
public InvalidCanonicalizerException(String _msgID, Object exArgs[]) { public InvalidCanonicalizerException(String msgID, Object exArgs[]) {
super(_msgID, exArgs); super(msgID, exArgs);
} }
/** /**
* Constructor InvalidCanonicalizerException * Constructor InvalidCanonicalizerException
* *
* @param _msgID * @param msgID
* @param _originalException * @param originalException
*/ */
public InvalidCanonicalizerException(String _msgID, public InvalidCanonicalizerException(String msgID, Exception originalException) {
Exception _originalException) { super(msgID, originalException);
super(_msgID, _originalException); }
}
/** /**
* Constructor InvalidCanonicalizerException * Constructor InvalidCanonicalizerException
* *
* @param _msgID * @param msgID
* @param exArgs * @param exArgs
* @param _originalException * @param originalException
*/ */
public InvalidCanonicalizerException(String _msgID, Object exArgs[], public InvalidCanonicalizerException(
Exception _originalException) { String msgID, Object exArgs[], Exception originalException
super(_msgID, exArgs, _originalException); ) {
} super(msgID, exArgs, originalException);
}
} }
...@@ -2,21 +2,23 @@ ...@@ -2,21 +2,23 @@
* reserved comment block * reserved comment block
* DO NOT REMOVE OR ALTER! * DO NOT REMOVE OR ALTER!
*/ */
/* /**
* Copyright 1999-2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one
* * or more contributor license agreements. See the NOTICE file
* Licensed under the Apache License, Version 2.0 (the "License"); * distributed with this work for additional information
* you may not use this file except in compliance with the License. * regarding copyright ownership. The ASF licenses this file
* You may obtain a copy of the License at * to you under the Apache License, Version 2.0 (the
* * "License"); you may not use this file except in compliance
* http://www.apache.org/licenses/LICENSE-2.0 * with the License. You may obtain a copy of the License at
* *
* Unless required by applicable law or agreed to in writing, software * http://www.apache.org/licenses/LICENSE-2.0
* 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.
* *
* 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.
*/ */
package com.sun.org.apache.xml.internal.security.c14n.helper; package com.sun.org.apache.xml.internal.security.c14n.helper;
...@@ -43,10 +45,10 @@ import java.util.Comparator; ...@@ -43,10 +45,10 @@ import java.util.Comparator;
*/ */
public class AttrCompare implements Comparator<Attr>, Serializable { public class AttrCompare implements Comparator<Attr>, Serializable {
private final static long serialVersionUID = -7113259629930576230L; private static final long serialVersionUID = -7113259629930576230L;
private final static int ATTR0_BEFORE_ATTR1 = -1; private static final int ATTR0_BEFORE_ATTR1 = -1;
private final static int ATTR1_BEFORE_ATTR0 = 1; private static final int ATTR1_BEFORE_ATTR0 = 1;
private final static String XMLNS=Constants.NamespaceSpecNS; private static final String XMLNS = Constants.NamespaceSpecNS;
/** /**
* Compares two attributes based on the C14n specification. * Compares two attributes based on the C14n specification.
...@@ -69,12 +71,11 @@ public class AttrCompare implements Comparator<Attr>, Serializable { ...@@ -69,12 +71,11 @@ public class AttrCompare implements Comparator<Attr>, Serializable {
* *
*/ */
public int compare(Attr attr0, Attr attr1) { public int compare(Attr attr0, Attr attr1) {
String namespaceURI0 = attr0.getNamespaceURI(); String namespaceURI0 = attr0.getNamespaceURI();
String namespaceURI1 = attr1.getNamespaceURI(); String namespaceURI1 = attr1.getNamespaceURI();
boolean isNamespaceAttr0 = XMLNS==namespaceURI0; boolean isNamespaceAttr0 = XMLNS.equals(namespaceURI0);
boolean isNamespaceAttr1 = XMLNS==namespaceURI1; boolean isNamespaceAttr1 = XMLNS.equals(namespaceURI1);
if (isNamespaceAttr0) { if (isNamespaceAttr0) {
if (isNamespaceAttr1) { if (isNamespaceAttr1) {
...@@ -82,11 +83,11 @@ public class AttrCompare implements Comparator<Attr>, Serializable { ...@@ -82,11 +83,11 @@ public class AttrCompare implements Comparator<Attr>, Serializable {
String localname0 = attr0.getLocalName(); String localname0 = attr0.getLocalName();
String localname1 = attr1.getLocalName(); String localname1 = attr1.getLocalName();
if (localname0.equals("xmlns")) { if ("xmlns".equals(localname0)) {
localname0 = ""; localname0 = "";
} }
if (localname1.equals("xmlns")) { if ("xmlns".equals(localname1)) {
localname1 = ""; localname1 = "";
} }
...@@ -94,9 +95,7 @@ public class AttrCompare implements Comparator<Attr>, Serializable { ...@@ -94,9 +95,7 @@ public class AttrCompare implements Comparator<Attr>, Serializable {
} }
// attr0 is a namespace, attr1 is not // attr0 is a namespace, attr1 is not
return ATTR0_BEFORE_ATTR1; return ATTR0_BEFORE_ATTR1;
} } else if (isNamespaceAttr1) {
if (isNamespaceAttr1) {
// attr1 is a namespace, attr0 is not // attr1 is a namespace, attr0 is not
return ATTR1_BEFORE_ATTR0; return ATTR1_BEFORE_ATTR0;
} }
...@@ -109,9 +108,7 @@ public class AttrCompare implements Comparator<Attr>, Serializable { ...@@ -109,9 +108,7 @@ public class AttrCompare implements Comparator<Attr>, Serializable {
return name0.compareTo(name1); return name0.compareTo(name1);
} }
return ATTR0_BEFORE_ATTR1; return ATTR0_BEFORE_ATTR1;
} } else if (namespaceURI1 == null) {
if (namespaceURI1 == null) {
return ATTR1_BEFORE_ATTR0; return ATTR1_BEFORE_ATTR0;
} }
......
...@@ -2,33 +2,32 @@ ...@@ -2,33 +2,32 @@
* reserved comment block * reserved comment block
* DO NOT REMOVE OR ALTER! * DO NOT REMOVE OR ALTER!
*/ */
/* /**
* Copyright 1999-2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one
* * or more contributor license agreements. See the NOTICE file
* Licensed under the Apache License, Version 2.0 (the "License"); * distributed with this work for additional information
* you may not use this file except in compliance with the License. * regarding copyright ownership. The ASF licenses this file
* You may obtain a copy of the License at * to you under the Apache License, Version 2.0 (the
* * "License"); you may not use this file except in compliance
* http://www.apache.org/licenses/LICENSE-2.0 * with the License. You may obtain a copy of the License at
* *
* Unless required by applicable law or agreed to in writing, software * http://www.apache.org/licenses/LICENSE-2.0
* 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.
* *
* 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.
*/ */
package com.sun.org.apache.xml.internal.security.c14n.helper; package com.sun.org.apache.xml.internal.security.c14n.helper;
import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException; import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException;
import org.w3c.dom.Attr; import org.w3c.dom.Attr;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap; import org.w3c.dom.NamedNodeMap;
/** /**
* Temporary swapped static functions from the normalizer Section * Temporary swapped static functions from the normalizer Section
* *
...@@ -36,129 +35,121 @@ import org.w3c.dom.NamedNodeMap; ...@@ -36,129 +35,121 @@ import org.w3c.dom.NamedNodeMap;
*/ */
public class C14nHelper { public class C14nHelper {
/** /**
* Constructor C14nHelper * Constructor C14nHelper
* *
*/ */
private C14nHelper() { private C14nHelper() {
// don't allow instantiation
// don't allow instantiation }
}
/**
/** * Method namespaceIsRelative
* Method namespaceIsRelative *
* * @param namespace
* @param namespace * @return true if the given namespace is relative.
* @return true if the given namespace is relative. */
*/ public static boolean namespaceIsRelative(Attr namespace) {
public static boolean namespaceIsRelative(Attr namespace) { return !namespaceIsAbsolute(namespace);
return !namespaceIsAbsolute(namespace); }
}
/**
/** * Method namespaceIsRelative
* Method namespaceIsRelative *
* * @param namespaceValue
* @param namespaceValue * @return true if the given namespace is relative.
* @return true if the given namespace is relative. */
*/ public static boolean namespaceIsRelative(String namespaceValue) {
public static boolean namespaceIsRelative(String namespaceValue) { return !namespaceIsAbsolute(namespaceValue);
return !namespaceIsAbsolute(namespaceValue); }
}
/**
/** * Method namespaceIsAbsolute
* Method namespaceIsAbsolute *
* * @param namespace
* @param namespace * @return true if the given namespace is absolute.
* @return true if the given namespace is absolute. */
*/ public static boolean namespaceIsAbsolute(Attr namespace) {
public static boolean namespaceIsAbsolute(Attr namespace) { return namespaceIsAbsolute(namespace.getValue());
return namespaceIsAbsolute(namespace.getValue()); }
}
/**
/** * Method namespaceIsAbsolute
* Method namespaceIsAbsolute *
* * @param namespaceValue
* @param namespaceValue * @return true if the given namespace is absolute.
* @return true if the given namespace is absolute. */
*/ public static boolean namespaceIsAbsolute(String namespaceValue) {
public static boolean namespaceIsAbsolute(String namespaceValue) { // assume empty namespaces are absolute
if (namespaceValue.length() == 0) {
// assume empty namespaces are absolute return true;
if (namespaceValue.length() == 0) { }
return true; return namespaceValue.indexOf(':') > 0;
} }
return namespaceValue.indexOf(':')>0;
} /**
* This method throws an exception if the Attribute value contains
/** * a relative URI.
* This method throws an exception if the Attribute value contains *
* a relative URI. * @param attr
* * @throws CanonicalizationException
* @param attr */
* @throws CanonicalizationException public static void assertNotRelativeNS(Attr attr) throws CanonicalizationException {
*/ if (attr == null) {
public static void assertNotRelativeNS(Attr attr) return;
throws CanonicalizationException { }
if (attr == null) { String nodeAttrName = attr.getNodeName();
return; boolean definesDefaultNS = nodeAttrName.equals("xmlns");
} boolean definesNonDefaultNS = nodeAttrName.startsWith("xmlns:");
String nodeAttrName = attr.getNodeName(); if ((definesDefaultNS || definesNonDefaultNS) && namespaceIsRelative(attr)) {
boolean definesDefaultNS = nodeAttrName.equals("xmlns");
boolean definesNonDefaultNS = nodeAttrName.startsWith("xmlns:");
if (definesDefaultNS || definesNonDefaultNS) {
if (namespaceIsRelative(attr)) {
String parentName = attr.getOwnerElement().getTagName(); String parentName = attr.getOwnerElement().getTagName();
String attrValue = attr.getValue(); String attrValue = attr.getValue();
Object exArgs[] = { parentName, nodeAttrName, attrValue }; Object exArgs[] = { parentName, nodeAttrName, attrValue };
throw new CanonicalizationException( throw new CanonicalizationException(
"c14n.Canonicalizer.RelativeNamespace", exArgs); "c14n.Canonicalizer.RelativeNamespace", exArgs
} );
} }
} }
/** /**
* This method throws a CanonicalizationException if the supplied Document * This method throws a CanonicalizationException if the supplied Document
* is not able to be traversed using a TreeWalker. * is not able to be traversed using a TreeWalker.
* *
* @param document * @param document
* @throws CanonicalizationException * @throws CanonicalizationException
*/ */
public static void checkTraversability(Document document) public static void checkTraversability(Document document)
throws CanonicalizationException { throws CanonicalizationException {
if (!document.isSupported("Traversal", "2.0")) {
Object exArgs[] = {document.getImplementation().getClass().getName() };
if (!document.isSupported("Traversal", "2.0")) { throw new CanonicalizationException(
Object exArgs[] = { "c14n.Canonicalizer.TraversalNotSupported", exArgs
document.getImplementation().getClass().getName() }; );
}
throw new CanonicalizationException( }
"c14n.Canonicalizer.TraversalNotSupported", exArgs);
} /**
} * This method throws a CanonicalizationException if the supplied Element
* contains any relative namespaces.
/** *
* This method throws a CanonicalizationException if the supplied Element * @param ctxNode
* contains any relative namespaces. * @throws CanonicalizationException
* * @see C14nHelper#assertNotRelativeNS(Attr)
* @param ctxNode */
* @throws CanonicalizationException public static void checkForRelativeNamespace(Element ctxNode)
* @see C14nHelper#assertNotRelativeNS(Attr) throws CanonicalizationException {
*/ if (ctxNode != null) {
public static void checkForRelativeNamespace(Element ctxNode) NamedNodeMap attributes = ctxNode.getAttributes();
throws CanonicalizationException {
for (int i = 0; i < attributes.getLength(); i++) {
if (ctxNode != null) { C14nHelper.assertNotRelativeNS((Attr) attributes.item(i));
NamedNodeMap attributes = ctxNode.getAttributes(); }
} else {
for (int i = 0; i < attributes.getLength(); i++) { throw new CanonicalizationException("Called checkForRelativeNamespace() on null");
C14nHelper.assertNotRelativeNS((Attr) attributes.item(i)); }
} }
} else {
throw new CanonicalizationException(
"Called checkForRelativeNamespace() on null");
}
}
} }
...@@ -2,21 +2,23 @@ ...@@ -2,21 +2,23 @@
* reserved comment block * reserved comment block
* DO NOT REMOVE OR ALTER! * DO NOT REMOVE OR ALTER!
*/ */
/* /**
* Copyright 2008 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one
* * or more contributor license agreements. See the NOTICE file
* Licensed under the Apache License, Version 2.0 (the "License"); * distributed with this work for additional information
* you may not use this file except in compliance with the License. * regarding copyright ownership. The ASF licenses this file
* You may obtain a copy of the License at * to you under the Apache License, Version 2.0 (the
* * "License"); you may not use this file except in compliance
* http://www.apache.org/licenses/LICENSE-2.0 * with the License. You may obtain a copy of the License at
* *
* Unless required by applicable law or agreed to in writing, software * http://www.apache.org/licenses/LICENSE-2.0
* 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.
* *
* 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.
*/ */
package com.sun.org.apache.xml.internal.security.c14n.implementations; package com.sun.org.apache.xml.internal.security.c14n.implementations;
......
...@@ -2,21 +2,23 @@ ...@@ -2,21 +2,23 @@
* reserved comment block * reserved comment block
* DO NOT REMOVE OR ALTER! * DO NOT REMOVE OR ALTER!
*/ */
/* /**
* Copyright 2008 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one
* * or more contributor license agreements. See the NOTICE file
* Licensed under the Apache License, Version 2.0 (the "License"); * distributed with this work for additional information
* you may not use this file except in compliance with the License. * regarding copyright ownership. The ASF licenses this file
* You may obtain a copy of the License at * to you under the Apache License, Version 2.0 (the
* * "License"); you may not use this file except in compliance
* http://www.apache.org/licenses/LICENSE-2.0 * with the License. You may obtain a copy of the License at
* *
* Unless required by applicable law or agreed to in writing, software * http://www.apache.org/licenses/LICENSE-2.0
* 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.
* *
* 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.
*/ */
package com.sun.org.apache.xml.internal.security.c14n.implementations; package com.sun.org.apache.xml.internal.security.c14n.implementations;
......
...@@ -2,48 +2,44 @@ ...@@ -2,48 +2,44 @@
* reserved comment block * reserved comment block
* DO NOT REMOVE OR ALTER! * DO NOT REMOVE OR ALTER!
*/ */
/* /**
* Copyright 1999-2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one
* * or more contributor license agreements. See the NOTICE file
* Licensed under the Apache License, Version 2.0 (the "License"); * distributed with this work for additional information
* you may not use this file except in compliance with the License. * regarding copyright ownership. The ASF licenses this file
* You may obtain a copy of the License at * to you under the Apache License, Version 2.0 (the
* * "License"); you may not use this file except in compliance
* http://www.apache.org/licenses/LICENSE-2.0 * with the License. You may obtain a copy of the License at
* *
* Unless required by applicable law or agreed to in writing, software * http://www.apache.org/licenses/LICENSE-2.0
* 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.
* *
* 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.
*/ */
package com.sun.org.apache.xml.internal.security.c14n.implementations; package com.sun.org.apache.xml.internal.security.c14n.implementations;
import com.sun.org.apache.xml.internal.security.c14n.Canonicalizer; import com.sun.org.apache.xml.internal.security.c14n.Canonicalizer;
/** public class Canonicalizer20010315ExclOmitComments extends Canonicalizer20010315Excl {
*
*
*/
public class Canonicalizer20010315ExclOmitComments
extends Canonicalizer20010315Excl {
/** /**
* *
*/ */
public Canonicalizer20010315ExclOmitComments() { public Canonicalizer20010315ExclOmitComments() {
super(false); super(false);
} }
/** @inheritDoc */ /** @inheritDoc */
public final String engineGetURI() { public final String engineGetURI() {
return Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS; return Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS;
} }
/** @inheritDoc */ /** @inheritDoc */
public final boolean engineGetIncludeComments() { public final boolean engineGetIncludeComments() {
return false; return false;
} }
} }
...@@ -2,52 +2,48 @@ ...@@ -2,52 +2,48 @@
* reserved comment block * reserved comment block
* DO NOT REMOVE OR ALTER! * DO NOT REMOVE OR ALTER!
*/ */
/* /**
* Copyright 1999-2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one
* * or more contributor license agreements. See the NOTICE file
* Licensed under the Apache License, Version 2.0 (the "License"); * distributed with this work for additional information
* you may not use this file except in compliance with the License. * regarding copyright ownership. The ASF licenses this file
* You may obtain a copy of the License at * to you under the Apache License, Version 2.0 (the
* * "License"); you may not use this file except in compliance
* http://www.apache.org/licenses/LICENSE-2.0 * with the License. You may obtain a copy of the License at
* *
* Unless required by applicable law or agreed to in writing, software * http://www.apache.org/licenses/LICENSE-2.0
* 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.
* *
* 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.
*/ */
package com.sun.org.apache.xml.internal.security.c14n.implementations; package com.sun.org.apache.xml.internal.security.c14n.implementations;
import com.sun.org.apache.xml.internal.security.c14n.Canonicalizer; import com.sun.org.apache.xml.internal.security.c14n.Canonicalizer;
/** /**
* Class Canonicalizer20010315ExclWithComments * Class Canonicalizer20010315ExclWithComments
*
* @version $Revision: 1.5 $
*/ */
public class Canonicalizer20010315ExclWithComments public class Canonicalizer20010315ExclWithComments extends Canonicalizer20010315Excl {
extends Canonicalizer20010315Excl {
/**
/** * Constructor Canonicalizer20010315ExclWithComments
* Constructor Canonicalizer20010315ExclWithComments *
* */
*/ public Canonicalizer20010315ExclWithComments() {
public Canonicalizer20010315ExclWithComments() { super(true);
super(true); }
}
/** @inheritDoc */
/** @inheritDoc */ public final String engineGetURI() {
public final String engineGetURI() { return Canonicalizer.ALGO_ID_C14N_EXCL_WITH_COMMENTS;
return Canonicalizer.ALGO_ID_C14N_EXCL_WITH_COMMENTS; }
}
/** @inheritDoc */
/** @inheritDoc */ public final boolean engineGetIncludeComments() {
public final boolean engineGetIncludeComments() { return true;
return true; }
}
} }
...@@ -2,50 +2,48 @@ ...@@ -2,50 +2,48 @@
* reserved comment block * reserved comment block
* DO NOT REMOVE OR ALTER! * DO NOT REMOVE OR ALTER!
*/ */
/* /**
* Copyright 1999-2004 The Apache Software Foundation. * Licensed to the Apache Software Foundation (ASF) under one
* * or more contributor license agreements. See the NOTICE file
* Licensed under the Apache License, Version 2.0 (the "License"); * distributed with this work for additional information
* you may not use this file except in compliance with the License. * regarding copyright ownership. The ASF licenses this file
* You may obtain a copy of the License at * to you under the Apache License, Version 2.0 (the
* * "License"); you may not use this file except in compliance
* http://www.apache.org/licenses/LICENSE-2.0 * with the License. You may obtain a copy of the License at
* *
* Unless required by applicable law or agreed to in writing, software * http://www.apache.org/licenses/LICENSE-2.0
* 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.
* *
* 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.
*/ */
package com.sun.org.apache.xml.internal.security.c14n.implementations; package com.sun.org.apache.xml.internal.security.c14n.implementations;
import com.sun.org.apache.xml.internal.security.c14n.Canonicalizer; import com.sun.org.apache.xml.internal.security.c14n.Canonicalizer;
/** /**
*
* @author Christian Geuer-Pollmann * @author Christian Geuer-Pollmann
*/ */
public class Canonicalizer20010315OmitComments extends Canonicalizer20010315 { public class Canonicalizer20010315OmitComments extends Canonicalizer20010315 {
/** /**
* Constructor Canonicalizer20010315WithXPathOmitComments * Constructor Canonicalizer20010315WithXPathOmitComments
* *
*/ */
public Canonicalizer20010315OmitComments() { public Canonicalizer20010315OmitComments() {
super(false); super(false);
} }
/** @inheritDoc */ /** @inheritDoc */
public final String engineGetURI() { public final String engineGetURI() {
return Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS; return Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS;
} }
/** @inheritDoc */ /** @inheritDoc */
public final boolean engineGetIncludeComments() { public final boolean engineGetIncludeComments() {
return false; return false;
} }
} }
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册