mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2025-12-06 09:29:38 +01:00
8319124: Update XML Security for Java to 3.0.3
Reviewed-by: mullan
This commit is contained in:
@@ -57,17 +57,22 @@ import org.w3c.dom.Node;
|
||||
*/
|
||||
public class Init {
|
||||
|
||||
/** The namespace for CONF file **/
|
||||
/**
|
||||
* The namespace for CONF file
|
||||
**/
|
||||
public static final String CONF_NS = "http://www.xmlsecurity.org/NS/#configuration";
|
||||
|
||||
private static final com.sun.org.slf4j.internal.Logger LOG =
|
||||
com.sun.org.slf4j.internal.LoggerFactory.getLogger(Init.class);
|
||||
com.sun.org.slf4j.internal.LoggerFactory.getLogger(Init.class);
|
||||
|
||||
/** Field alreadyInitialized */
|
||||
/**
|
||||
* Field alreadyInitialized
|
||||
*/
|
||||
private static boolean alreadyInitialized = false;
|
||||
|
||||
/**
|
||||
* Method isInitialized
|
||||
*
|
||||
* @return true if the library is already initialized.
|
||||
*/
|
||||
public static final synchronized boolean isInitialized() {
|
||||
@@ -76,35 +81,28 @@ public class Init {
|
||||
|
||||
/**
|
||||
* Method init
|
||||
*
|
||||
*/
|
||||
public static synchronized void init() {
|
||||
if (alreadyInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
InputStream is = //NOPMD
|
||||
AccessController.doPrivileged(
|
||||
(PrivilegedAction<InputStream>)
|
||||
() -> {
|
||||
String cfile =
|
||||
System.getProperty("com.sun.org.apache.xml.internal.security.resource.config");
|
||||
if (cfile == null) {
|
||||
return null;
|
||||
}
|
||||
return getResourceAsStream(cfile, Init.class);
|
||||
}
|
||||
);
|
||||
if (is == null) {
|
||||
dynamicInit();
|
||||
} else {
|
||||
fileInit(is);
|
||||
try {
|
||||
is.close();
|
||||
} catch (IOException ex) {
|
||||
LOG.warn(ex.getMessage());
|
||||
PrivilegedAction<InputStream> action = () -> {
|
||||
String cfile = System.getProperty("com.sun.org.apache.xml.internal.security.resource.config");
|
||||
if (cfile == null) {
|
||||
return null;
|
||||
}
|
||||
return getResourceAsStream(cfile, Init.class);
|
||||
};
|
||||
|
||||
try (@SuppressWarnings("removal")
|
||||
InputStream is = AccessController.doPrivileged(action)) {
|
||||
if (is == null) {
|
||||
dynamicInit();
|
||||
} else {
|
||||
fileInit(is);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
LOG.warn(ex.getMessage(), ex);
|
||||
}
|
||||
|
||||
alreadyInitialized = true;
|
||||
@@ -412,9 +410,11 @@ public class Init {
|
||||
}
|
||||
List<URL> ret = new ArrayList<>();
|
||||
Enumeration<URL> urls = new Enumeration<URL>() {
|
||||
@Override
|
||||
public boolean hasMoreElements() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public URL nextElement() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,9 @@ public class JCEMapper {
|
||||
|
||||
private static Map<String, Algorithm> algorithmsMap = new ConcurrentHashMap<>();
|
||||
|
||||
private static String providerName;
|
||||
private static String globalProviderName;
|
||||
|
||||
private static final ThreadLocal<String> threadSpecificProviderName = new ThreadLocal<>();
|
||||
|
||||
/**
|
||||
* Method register
|
||||
@@ -344,7 +346,10 @@ public class JCEMapper {
|
||||
* @return the default providerId.
|
||||
*/
|
||||
public static String getProviderId() {
|
||||
return providerName;
|
||||
if (threadSpecificProviderName.get() != null) {
|
||||
return threadSpecificProviderName.get();
|
||||
}
|
||||
return globalProviderName;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -355,7 +360,18 @@ public class JCEMapper {
|
||||
*/
|
||||
public static void setProviderId(String provider) {
|
||||
JavaUtils.checkRegisterPermission();
|
||||
providerName = provider;
|
||||
globalProviderName = provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default Provider for this thread to obtain the security algorithms
|
||||
* @param threadSpecificProviderName the default providerId.
|
||||
* @throws SecurityException if a security manager is installed and the
|
||||
* caller does not have permission to register the JCE algorithm
|
||||
*/
|
||||
public static void setThreadSpecificProviderName(String threadSpecificProviderName) {
|
||||
JavaUtils.checkRegisterPermission();
|
||||
JCEMapper.threadSpecificProviderName.set(threadSpecificProviderName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -256,11 +256,13 @@ public final class MessageDigestAlgorithm extends Algorithm {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String getBaseNamespace() {
|
||||
return Constants.SignatureSpecNS;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String getBaseLocalName() {
|
||||
return Constants._TAG_DIGESTMETHOD;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,11 @@ import java.security.spec.AlgorithmParameterSpec;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.algorithms.implementations.*;
|
||||
import com.sun.org.apache.xml.internal.security.algorithms.implementations.IntegrityHmac;
|
||||
import com.sun.org.apache.xml.internal.security.algorithms.implementations.SignatureBaseRSA;
|
||||
import com.sun.org.apache.xml.internal.security.algorithms.implementations.SignatureDSA;
|
||||
import com.sun.org.apache.xml.internal.security.algorithms.implementations.SignatureECDSA;
|
||||
import com.sun.org.apache.xml.internal.security.algorithms.implementations.SignatureEDDSA;
|
||||
import com.sun.org.apache.xml.internal.security.exceptions.AlgorithmAlreadyRegisteredException;
|
||||
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
|
||||
import com.sun.org.apache.xml.internal.security.signature.XMLSignature;
|
||||
@@ -524,6 +528,7 @@ public class SignatureAlgorithm extends Algorithm {
|
||||
*
|
||||
* @return URI of this element
|
||||
*/
|
||||
@Override
|
||||
public String getBaseNamespace() {
|
||||
return Constants.SignatureSpecNS;
|
||||
}
|
||||
@@ -533,6 +538,7 @@ public class SignatureAlgorithm extends Algorithm {
|
||||
*
|
||||
* @return Local name
|
||||
*/
|
||||
@Override
|
||||
public String getBaseLocalName() {
|
||||
return Constants._TAG_SIGNATUREMETHOD;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,12 @@
|
||||
*/
|
||||
package com.sun.org.apache.xml.internal.security.algorithms;
|
||||
|
||||
import java.security.*;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.Key;
|
||||
import java.security.PrivateKey;
|
||||
import java.security.PublicKey;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.Signature;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException;
|
||||
|
||||
@@ -28,7 +28,12 @@ package com.sun.org.apache.xml.internal.security.algorithms.implementations;
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
import java.security.interfaces.ECPublicKey;
|
||||
import java.security.spec.*;
|
||||
import java.security.spec.ECField;
|
||||
import java.security.spec.ECFieldF2m;
|
||||
import java.security.spec.ECFieldFp;
|
||||
import java.security.spec.ECParameterSpec;
|
||||
import java.security.spec.ECPoint;
|
||||
import java.security.spec.EllipticCurve;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -90,6 +90,7 @@ public abstract class IntegrityHmac extends SignatureAlgorithmSpi {
|
||||
* @param params
|
||||
* @throws XMLSignatureException
|
||||
*/
|
||||
@Override
|
||||
protected void engineSetParameter(AlgorithmParameterSpec params) throws XMLSignatureException {
|
||||
throw new XMLSignatureException("empty", new Object[]{"Incorrect method call"});
|
||||
}
|
||||
@@ -102,6 +103,7 @@ public abstract class IntegrityHmac extends SignatureAlgorithmSpi {
|
||||
* @return true if the signature is correct
|
||||
* @throws XMLSignatureException
|
||||
*/
|
||||
@Override
|
||||
protected boolean engineVerify(byte[] signature) throws XMLSignatureException {
|
||||
try {
|
||||
if (hmacOutputLength != null && hmacOutputLength.length < getDigestLength()) {
|
||||
@@ -124,6 +126,7 @@ public abstract class IntegrityHmac extends SignatureAlgorithmSpi {
|
||||
* @param secretKey
|
||||
* @throws XMLSignatureException
|
||||
*/
|
||||
@Override
|
||||
protected void engineInitVerify(Key secretKey) throws XMLSignatureException {
|
||||
if (!(secretKey instanceof SecretKey)) {
|
||||
String supplied = null;
|
||||
@@ -150,6 +153,7 @@ public abstract class IntegrityHmac extends SignatureAlgorithmSpi {
|
||||
* @return the result of the {@link java.security.Signature#sign()} method
|
||||
* @throws XMLSignatureException
|
||||
*/
|
||||
@Override
|
||||
protected byte[] engineSign() throws XMLSignatureException {
|
||||
try {
|
||||
if (hmacOutputLength != null && hmacOutputLength.length < getDigestLength()) {
|
||||
@@ -170,6 +174,7 @@ public abstract class IntegrityHmac extends SignatureAlgorithmSpi {
|
||||
* @param secretKey
|
||||
* @throws XMLSignatureException
|
||||
*/
|
||||
@Override
|
||||
protected void engineInitSign(Key secretKey) throws XMLSignatureException {
|
||||
engineInitSign(secretKey, (AlgorithmParameterSpec)null);
|
||||
}
|
||||
@@ -181,6 +186,7 @@ public abstract class IntegrityHmac extends SignatureAlgorithmSpi {
|
||||
* @param algorithmParameterSpec
|
||||
* @throws XMLSignatureException
|
||||
*/
|
||||
@Override
|
||||
protected void engineInitSign(
|
||||
Key secretKey, AlgorithmParameterSpec algorithmParameterSpec
|
||||
) throws XMLSignatureException {
|
||||
@@ -213,6 +219,7 @@ public abstract class IntegrityHmac extends SignatureAlgorithmSpi {
|
||||
* @param secureRandom
|
||||
* @throws XMLSignatureException
|
||||
*/
|
||||
@Override
|
||||
protected void engineInitSign(Key secretKey, SecureRandom secureRandom)
|
||||
throws XMLSignatureException {
|
||||
throw new XMLSignatureException("algorithms.CannotUseSecureRandomOnMAC");
|
||||
@@ -225,6 +232,7 @@ public abstract class IntegrityHmac extends SignatureAlgorithmSpi {
|
||||
* @param input
|
||||
* @throws XMLSignatureException
|
||||
*/
|
||||
@Override
|
||||
protected void engineUpdate(byte[] input) throws XMLSignatureException {
|
||||
try {
|
||||
this.macAlgorithm.update(input);
|
||||
@@ -240,6 +248,7 @@ public abstract class IntegrityHmac extends SignatureAlgorithmSpi {
|
||||
* @param input
|
||||
* @throws XMLSignatureException
|
||||
*/
|
||||
@Override
|
||||
protected void engineUpdate(byte input) throws XMLSignatureException {
|
||||
try {
|
||||
this.macAlgorithm.update(input);
|
||||
@@ -257,6 +266,7 @@ public abstract class IntegrityHmac extends SignatureAlgorithmSpi {
|
||||
* @param len
|
||||
* @throws XMLSignatureException
|
||||
*/
|
||||
@Override
|
||||
protected void engineUpdate(byte[] buf, int offset, int len) throws XMLSignatureException {
|
||||
try {
|
||||
this.macAlgorithm.update(buf, offset, len);
|
||||
@@ -270,6 +280,7 @@ public abstract class IntegrityHmac extends SignatureAlgorithmSpi {
|
||||
* {@inheritDoc}
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
protected String engineGetJCEAlgorithmString() {
|
||||
return this.macAlgorithm.getAlgorithm();
|
||||
}
|
||||
@@ -279,6 +290,7 @@ public abstract class IntegrityHmac extends SignatureAlgorithmSpi {
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected String engineGetJCEProviderName() {
|
||||
return this.macAlgorithm.getProvider().getName();
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@ import java.security.SecureRandom;
|
||||
import java.security.Signature;
|
||||
import java.security.SignatureException;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
import java.security.spec.MGF1ParameterSpec;
|
||||
import java.security.spec.PSSParameterSpec;
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.algorithms.JCEMapper;
|
||||
import com.sun.org.apache.xml.internal.security.algorithms.SignatureAlgorithmSpi;
|
||||
@@ -43,8 +45,6 @@ import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
import javax.xml.crypto.dsig.DigestMethod;
|
||||
import java.security.spec.MGF1ParameterSpec;
|
||||
import java.security.spec.PSSParameterSpec;
|
||||
|
||||
public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
|
||||
|
||||
@@ -65,20 +65,25 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
|
||||
|
||||
public SignatureBaseRSA(Provider provider) throws XMLSignatureException {
|
||||
String algorithmID = JCEMapper.translateURItoJCEID(this.engineGetURI());
|
||||
LOG.debug("Created SignatureRSA using {}", algorithmID);
|
||||
this.signatureAlgorithm = getSignature(provider, algorithmID);
|
||||
LOG.debug("Created SignatureRSA using {0} and provider {1}",
|
||||
algorithmID, signatureAlgorithm.getProvider());
|
||||
}
|
||||
|
||||
Signature getSignature(Provider provider, String algorithmID)
|
||||
throws XMLSignatureException {
|
||||
try {
|
||||
if (provider == null) {
|
||||
String providerId = JCEMapper.getProviderId();
|
||||
if (providerId == null) {
|
||||
this.signatureAlgorithm = Signature.getInstance(algorithmID);
|
||||
return Signature.getInstance(algorithmID);
|
||||
|
||||
} else {
|
||||
this.signatureAlgorithm = Signature.getInstance(algorithmID, providerId);
|
||||
return Signature.getInstance(algorithmID, providerId);
|
||||
}
|
||||
|
||||
} else {
|
||||
this.signatureAlgorithm = Signature.getInstance(algorithmID, provider);
|
||||
return Signature.getInstance(algorithmID, provider);
|
||||
}
|
||||
|
||||
} catch (NoSuchAlgorithmException | NoSuchProviderException ex) {
|
||||
@@ -88,6 +93,7 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void engineSetParameter(AlgorithmParameterSpec params)
|
||||
throws XMLSignatureException {
|
||||
try {
|
||||
@@ -98,6 +104,7 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected boolean engineVerify(byte[] signature) throws XMLSignatureException {
|
||||
try {
|
||||
return this.signatureAlgorithm.verify(signature);
|
||||
@@ -107,11 +114,13 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void engineInitVerify(Key publicKey) throws XMLSignatureException {
|
||||
engineInitVerify(publicKey, this.signatureAlgorithm);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected byte[] engineSign() throws XMLSignatureException {
|
||||
try {
|
||||
return this.signatureAlgorithm.sign();
|
||||
@@ -121,17 +130,20 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void engineInitSign(Key privateKey, SecureRandom secureRandom)
|
||||
throws XMLSignatureException {
|
||||
engineInitSign(privateKey, secureRandom, this.signatureAlgorithm);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void engineInitSign(Key privateKey) throws XMLSignatureException {
|
||||
engineInitSign(privateKey, (SecureRandom)null);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void engineUpdate(byte[] input) throws XMLSignatureException {
|
||||
try {
|
||||
this.signatureAlgorithm.update(input);
|
||||
@@ -141,6 +153,7 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void engineUpdate(byte input) throws XMLSignatureException {
|
||||
try {
|
||||
this.signatureAlgorithm.update(input);
|
||||
@@ -150,6 +163,7 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void engineUpdate(byte[] buf, int offset, int len) throws XMLSignatureException {
|
||||
try {
|
||||
this.signatureAlgorithm.update(buf, offset, len);
|
||||
@@ -159,22 +173,26 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected String engineGetJCEAlgorithmString() {
|
||||
return this.signatureAlgorithm.getAlgorithm();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected String engineGetJCEProviderName() {
|
||||
return this.signatureAlgorithm.getProvider().getName();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void engineSetHMACOutputLength(int HMACOutputLength)
|
||||
throws XMLSignatureException {
|
||||
throw new XMLSignatureException("algorithms.HMACOutputLengthOnlyForHMAC");
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void engineInitSign(
|
||||
Key signingKey, AlgorithmParameterSpec algorithmParameterSpec
|
||||
) throws XMLSignatureException {
|
||||
@@ -356,10 +374,53 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
|
||||
}
|
||||
}
|
||||
|
||||
public abstract static class SignatureBaseRSAPSS extends SignatureBaseRSA {
|
||||
|
||||
public SignatureBaseRSAPSS() throws XMLSignatureException {
|
||||
super();
|
||||
}
|
||||
|
||||
public SignatureBaseRSAPSS(Provider provider) throws XMLSignatureException {
|
||||
super(provider);
|
||||
}
|
||||
|
||||
@Override
|
||||
Signature getSignature(Provider provider, String algorithmID)
|
||||
throws XMLSignatureException {
|
||||
try {
|
||||
Signature sig;
|
||||
if (provider == null) {
|
||||
String providerId = JCEMapper.getProviderId();
|
||||
if (providerId == null) {
|
||||
sig = Signature.getInstance("RSASSA-PSS");
|
||||
} else {
|
||||
sig = Signature.getInstance("RSASSA-PSS", providerId);
|
||||
}
|
||||
} else {
|
||||
sig = Signature.getInstance("RSASSA-PSS", provider);
|
||||
}
|
||||
try {
|
||||
sig.setParameter(getPSSParameterSpec());
|
||||
} catch (InvalidAlgorithmParameterException e) {
|
||||
throw new NoSuchAlgorithmException("Should not happen", e);
|
||||
}
|
||||
return sig;
|
||||
} catch (NoSuchAlgorithmException | NoSuchProviderException e) {
|
||||
return super.getSignature(provider, algorithmID);
|
||||
}
|
||||
}
|
||||
|
||||
abstract PSSParameterSpec getPSSParameterSpec();
|
||||
}
|
||||
|
||||
/**
|
||||
* Class SignatureRSASHA1MGF1
|
||||
*/
|
||||
public static class SignatureRSASHA1MGF1 extends SignatureBaseRSA {
|
||||
public static class SignatureRSASHA1MGF1 extends SignatureBaseRSAPSS {
|
||||
|
||||
private static final PSSParameterSpec SHA1_MGF1_PARAMS
|
||||
= new PSSParameterSpec("SHA-1", "MGF1", MGF1ParameterSpec.SHA1,
|
||||
20, PSSParameterSpec.TRAILER_FIELD_BC);
|
||||
|
||||
/**
|
||||
* Constructor SignatureRSASHA1MGF1
|
||||
@@ -379,12 +440,21 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
|
||||
public String engineGetURI() {
|
||||
return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1_MGF1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PSSParameterSpec getPSSParameterSpec() {
|
||||
return SHA1_MGF1_PARAMS;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class SignatureRSASHA224MGF1
|
||||
*/
|
||||
public static class SignatureRSASHA224MGF1 extends SignatureBaseRSA {
|
||||
public static class SignatureRSASHA224MGF1 extends SignatureBaseRSAPSS {
|
||||
|
||||
private static final PSSParameterSpec SHA224_MGF1_PARAMS
|
||||
= new PSSParameterSpec("SHA-224", "MGF1", MGF1ParameterSpec.SHA224,
|
||||
28, PSSParameterSpec.TRAILER_FIELD_BC);
|
||||
|
||||
/**
|
||||
* Constructor SignatureRSASHA224MGF1
|
||||
@@ -404,12 +474,21 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
|
||||
public String engineGetURI() {
|
||||
return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA224_MGF1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PSSParameterSpec getPSSParameterSpec() {
|
||||
return SHA224_MGF1_PARAMS;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class SignatureRSASHA256MGF1
|
||||
*/
|
||||
public static class SignatureRSASHA256MGF1 extends SignatureBaseRSA {
|
||||
public static class SignatureRSASHA256MGF1 extends SignatureBaseRSAPSS {
|
||||
|
||||
private static final PSSParameterSpec SHA256_MGF1_PARAMS
|
||||
= new PSSParameterSpec("SHA-256", "MGF1", MGF1ParameterSpec.SHA256,
|
||||
32, PSSParameterSpec.TRAILER_FIELD_BC);
|
||||
|
||||
/**
|
||||
* Constructor SignatureRSASHA256MGF1
|
||||
@@ -429,12 +508,21 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
|
||||
public String engineGetURI() {
|
||||
return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256_MGF1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PSSParameterSpec getPSSParameterSpec() {
|
||||
return SHA256_MGF1_PARAMS;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class SignatureRSASHA384MGF1
|
||||
*/
|
||||
public static class SignatureRSASHA384MGF1 extends SignatureBaseRSA {
|
||||
public static class SignatureRSASHA384MGF1 extends SignatureBaseRSAPSS {
|
||||
|
||||
private static final PSSParameterSpec SHA384_MGF1_PARAMS
|
||||
= new PSSParameterSpec("SHA-384", "MGF1", MGF1ParameterSpec.SHA384,
|
||||
48, PSSParameterSpec.TRAILER_FIELD_BC);
|
||||
|
||||
/**
|
||||
* Constructor SignatureRSASHA384MGF1
|
||||
@@ -454,12 +542,21 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
|
||||
public String engineGetURI() {
|
||||
return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA384_MGF1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PSSParameterSpec getPSSParameterSpec() {
|
||||
return SHA384_MGF1_PARAMS;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class SignatureRSASHA512MGF1
|
||||
*/
|
||||
public static class SignatureRSASHA512MGF1 extends SignatureBaseRSA {
|
||||
public static class SignatureRSASHA512MGF1 extends SignatureBaseRSAPSS {
|
||||
|
||||
private static final PSSParameterSpec SHA512_MGF1_PARAMS
|
||||
= new PSSParameterSpec("SHA-512", "MGF1", MGF1ParameterSpec.SHA512,
|
||||
64, PSSParameterSpec.TRAILER_FIELD_BC);
|
||||
|
||||
/**
|
||||
* Constructor SignatureRSASHA512MGF1
|
||||
@@ -479,12 +576,22 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
|
||||
public String engineGetURI() {
|
||||
return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA512_MGF1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PSSParameterSpec getPSSParameterSpec() {
|
||||
return SHA512_MGF1_PARAMS;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class SignatureRSA3_SHA224MGF1
|
||||
*/
|
||||
public static class SignatureRSASHA3_224MGF1 extends SignatureBaseRSA {
|
||||
public static class SignatureRSASHA3_224MGF1 extends SignatureBaseRSAPSS {
|
||||
|
||||
private static final PSSParameterSpec SHA3_224_MGF1_PARAMS
|
||||
= new PSSParameterSpec("SHA3-224", "MGF1",
|
||||
new MGF1ParameterSpec("SHA3-224"),
|
||||
28, PSSParameterSpec.TRAILER_FIELD_BC);
|
||||
|
||||
/**
|
||||
* Constructor SignatureRSASHA3_224MGF1
|
||||
@@ -504,12 +611,22 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
|
||||
public String engineGetURI() {
|
||||
return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA3_224_MGF1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PSSParameterSpec getPSSParameterSpec() {
|
||||
return SHA3_224_MGF1_PARAMS;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class SignatureRSA3_SHA256MGF1
|
||||
*/
|
||||
public static class SignatureRSASHA3_256MGF1 extends SignatureBaseRSA {
|
||||
public static class SignatureRSASHA3_256MGF1 extends SignatureBaseRSAPSS {
|
||||
|
||||
private static final PSSParameterSpec SHA3_256_MGF1_PARAMS
|
||||
= new PSSParameterSpec("SHA3-256", "MGF1",
|
||||
new MGF1ParameterSpec("SHA3-256"),
|
||||
32, PSSParameterSpec.TRAILER_FIELD_BC);
|
||||
|
||||
/**
|
||||
* Constructor SignatureRSASHA3_256MGF1
|
||||
@@ -529,12 +646,22 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
|
||||
public String engineGetURI() {
|
||||
return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA3_256_MGF1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PSSParameterSpec getPSSParameterSpec() {
|
||||
return SHA3_256_MGF1_PARAMS;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class SignatureRSA3_SHA384MGF1
|
||||
*/
|
||||
public static class SignatureRSASHA3_384MGF1 extends SignatureBaseRSA {
|
||||
public static class SignatureRSASHA3_384MGF1 extends SignatureBaseRSAPSS {
|
||||
|
||||
private static final PSSParameterSpec SHA3_384_MGF1_PARAMS
|
||||
= new PSSParameterSpec("SHA3-384", "MGF1",
|
||||
new MGF1ParameterSpec("SHA3-384"),
|
||||
48, PSSParameterSpec.TRAILER_FIELD_BC);
|
||||
|
||||
/**
|
||||
* Constructor SignatureRSASHA3_384MGF1
|
||||
@@ -554,12 +681,22 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
|
||||
public String engineGetURI() {
|
||||
return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA3_384_MGF1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PSSParameterSpec getPSSParameterSpec() {
|
||||
return SHA3_384_MGF1_PARAMS;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class SignatureRSASHA3_512MGF1
|
||||
*/
|
||||
public static class SignatureRSASHA3_512MGF1 extends SignatureBaseRSA {
|
||||
public static class SignatureRSASHA3_512MGF1 extends SignatureBaseRSAPSS {
|
||||
|
||||
private static final PSSParameterSpec SHA3_512_MGF1_PARAMS
|
||||
= new PSSParameterSpec("SHA3-512", "MGF1",
|
||||
new MGF1ParameterSpec("SHA3-512"),
|
||||
64, PSSParameterSpec.TRAILER_FIELD_BC);
|
||||
|
||||
/**
|
||||
* Constructor SignatureRSASHA3_512MGF1
|
||||
@@ -579,10 +716,15 @@ public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
|
||||
public String engineGetURI() {
|
||||
return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA3_512_MGF1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PSSParameterSpec getPSSParameterSpec() {
|
||||
return SHA3_512_MGF1_PARAMS;
|
||||
}
|
||||
}
|
||||
|
||||
public static class SignatureRSASSAPSS extends SignatureBaseRSA {
|
||||
PSSParameterSpec pssParameterSpec;
|
||||
private PSSParameterSpec pssParameterSpec;
|
||||
|
||||
public enum DigestAlgorithm {
|
||||
SHA224("SHA-224", DigestMethod.SHA224, 28),
|
||||
|
||||
@@ -60,6 +60,7 @@ public class SignatureDSA extends SignatureAlgorithmSpi {
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected String engineGetURI() {
|
||||
return XMLSignature.ALGO_ID_SIGNATURE_DSA;
|
||||
}
|
||||
@@ -100,6 +101,7 @@ public class SignatureDSA extends SignatureAlgorithmSpi {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void engineSetParameter(AlgorithmParameterSpec params)
|
||||
throws XMLSignatureException {
|
||||
try {
|
||||
@@ -112,6 +114,7 @@ public class SignatureDSA extends SignatureAlgorithmSpi {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected boolean engineVerify(byte[] signature)
|
||||
throws XMLSignatureException {
|
||||
try {
|
||||
@@ -130,6 +133,7 @@ public class SignatureDSA extends SignatureAlgorithmSpi {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void engineInitVerify(Key publicKey) throws XMLSignatureException {
|
||||
engineInitVerify(publicKey, this.signatureAlgorithm);
|
||||
size = ((DSAKey)publicKey).getParams().getQ().bitLength();
|
||||
@@ -138,6 +142,7 @@ public class SignatureDSA extends SignatureAlgorithmSpi {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected byte[] engineSign() throws XMLSignatureException {
|
||||
try {
|
||||
byte[] jcebytes = this.signatureAlgorithm.sign();
|
||||
@@ -151,6 +156,7 @@ public class SignatureDSA extends SignatureAlgorithmSpi {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void engineInitSign(Key privateKey, SecureRandom secureRandom)
|
||||
throws XMLSignatureException {
|
||||
engineInitSign(privateKey, secureRandom, this.signatureAlgorithm);
|
||||
@@ -160,6 +166,7 @@ public class SignatureDSA extends SignatureAlgorithmSpi {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void engineInitSign(Key privateKey) throws XMLSignatureException {
|
||||
engineInitSign(privateKey, (SecureRandom)null);
|
||||
}
|
||||
@@ -167,6 +174,7 @@ public class SignatureDSA extends SignatureAlgorithmSpi {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void engineUpdate(byte[] input) throws XMLSignatureException {
|
||||
try {
|
||||
this.signatureAlgorithm.update(input);
|
||||
@@ -178,6 +186,7 @@ public class SignatureDSA extends SignatureAlgorithmSpi {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void engineUpdate(byte input) throws XMLSignatureException {
|
||||
try {
|
||||
this.signatureAlgorithm.update(input);
|
||||
@@ -189,6 +198,7 @@ public class SignatureDSA extends SignatureAlgorithmSpi {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected void engineUpdate(byte[] buf, int offset, int len) throws XMLSignatureException {
|
||||
try {
|
||||
this.signatureAlgorithm.update(buf, offset, len);
|
||||
@@ -202,6 +212,7 @@ public class SignatureDSA extends SignatureAlgorithmSpi {
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected String engineGetJCEAlgorithmString() {
|
||||
return this.signatureAlgorithm.getAlgorithm();
|
||||
}
|
||||
@@ -211,6 +222,7 @@ public class SignatureDSA extends SignatureAlgorithmSpi {
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected String engineGetJCEProviderName() {
|
||||
return this.signatureAlgorithm.getProvider().getName();
|
||||
}
|
||||
@@ -221,6 +233,7 @@ public class SignatureDSA extends SignatureAlgorithmSpi {
|
||||
* @param HMACOutputLength
|
||||
* @throws XMLSignatureException
|
||||
*/
|
||||
@Override
|
||||
protected void engineSetHMACOutputLength(int HMACOutputLength) throws XMLSignatureException {
|
||||
throw new XMLSignatureException("algorithms.HMACOutputLengthOnlyForHMAC");
|
||||
}
|
||||
@@ -232,6 +245,7 @@ public class SignatureDSA extends SignatureAlgorithmSpi {
|
||||
* @param algorithmParameterSpec
|
||||
* @throws XMLSignatureException
|
||||
*/
|
||||
@Override
|
||||
protected void engineInitSign(
|
||||
Key signingKey, AlgorithmParameterSpec algorithmParameterSpec
|
||||
) throws XMLSignatureException {
|
||||
|
||||
@@ -26,7 +26,14 @@
|
||||
package com.sun.org.apache.xml.internal.security.algorithms.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.*;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.Key;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.NoSuchProviderException;
|
||||
import java.security.Provider;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.Signature;
|
||||
import java.security.SignatureException;
|
||||
import java.security.interfaces.ECPrivateKey;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
|
||||
@@ -118,6 +125,7 @@ public abstract class SignatureECDSA extends SignatureAlgorithmSpi {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void engineSetParameter(AlgorithmParameterSpec params)
|
||||
throws XMLSignatureException {
|
||||
try {
|
||||
@@ -128,6 +136,7 @@ public abstract class SignatureECDSA extends SignatureAlgorithmSpi {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected boolean engineVerify(byte[] signature) throws XMLSignatureException {
|
||||
try {
|
||||
byte[] jcebytes = SignatureECDSA.convertXMLDSIGtoASN1(signature);
|
||||
@@ -143,11 +152,13 @@ public abstract class SignatureECDSA extends SignatureAlgorithmSpi {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void engineInitVerify(Key publicKey) throws XMLSignatureException {
|
||||
engineInitVerify(publicKey, signatureAlgorithm);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected byte[] engineSign() throws XMLSignatureException {
|
||||
try {
|
||||
byte[] jcebytes = this.signatureAlgorithm.sign();
|
||||
@@ -158,6 +169,7 @@ public abstract class SignatureECDSA extends SignatureAlgorithmSpi {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void engineInitSign(Key privateKey, SecureRandom secureRandom)
|
||||
throws XMLSignatureException {
|
||||
if (privateKey instanceof ECPrivateKey) {
|
||||
@@ -169,11 +181,13 @@ public abstract class SignatureECDSA extends SignatureAlgorithmSpi {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void engineInitSign(Key privateKey) throws XMLSignatureException {
|
||||
engineInitSign(privateKey, (SecureRandom)null);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void engineUpdate(byte[] input) throws XMLSignatureException {
|
||||
try {
|
||||
this.signatureAlgorithm.update(input);
|
||||
@@ -183,6 +197,7 @@ public abstract class SignatureECDSA extends SignatureAlgorithmSpi {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void engineUpdate(byte input) throws XMLSignatureException {
|
||||
try {
|
||||
this.signatureAlgorithm.update(input);
|
||||
@@ -192,6 +207,7 @@ public abstract class SignatureECDSA extends SignatureAlgorithmSpi {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void engineUpdate(byte[] buf, int offset, int len) throws XMLSignatureException {
|
||||
try {
|
||||
this.signatureAlgorithm.update(buf, offset, len);
|
||||
@@ -201,22 +217,26 @@ public abstract class SignatureECDSA extends SignatureAlgorithmSpi {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected String engineGetJCEAlgorithmString() {
|
||||
return this.signatureAlgorithm.getAlgorithm();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected String engineGetJCEProviderName() {
|
||||
return this.signatureAlgorithm.getProvider().getName();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void engineSetHMACOutputLength(int HMACOutputLength)
|
||||
throws XMLSignatureException {
|
||||
throw new XMLSignatureException("algorithms.HMACOutputLengthOnlyForHMAC");
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void engineInitSign(
|
||||
Key signingKey, AlgorithmParameterSpec algorithmParameterSpec
|
||||
) throws XMLSignatureException {
|
||||
|
||||
@@ -22,16 +22,22 @@
|
||||
*/
|
||||
package com.sun.org.apache.xml.internal.security.algorithms.implementations;
|
||||
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.Key;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.NoSuchProviderException;
|
||||
import java.security.Provider;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.Signature;
|
||||
import java.security.SignatureException;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.algorithms.JCEMapper;
|
||||
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.XMLSignatureException;
|
||||
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.*;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -77,6 +83,7 @@ public abstract class SignatureEDDSA extends SignatureAlgorithmSpi {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void engineSetParameter(AlgorithmParameterSpec params)
|
||||
throws XMLSignatureException {
|
||||
try {
|
||||
@@ -87,6 +94,7 @@ public abstract class SignatureEDDSA extends SignatureAlgorithmSpi {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected boolean engineVerify(byte[] signature) throws XMLSignatureException {
|
||||
try {
|
||||
|
||||
@@ -101,11 +109,13 @@ public abstract class SignatureEDDSA extends SignatureAlgorithmSpi {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void engineInitVerify(Key publicKey) throws XMLSignatureException {
|
||||
engineInitVerify(publicKey, signatureAlgorithm);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected byte[] engineSign() throws XMLSignatureException {
|
||||
try {
|
||||
return this.signatureAlgorithm.sign();
|
||||
@@ -115,6 +125,7 @@ public abstract class SignatureEDDSA extends SignatureAlgorithmSpi {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void engineInitSign(Key privateKey, SecureRandom secureRandom)
|
||||
throws XMLSignatureException {
|
||||
|
||||
@@ -122,11 +133,13 @@ public abstract class SignatureEDDSA extends SignatureAlgorithmSpi {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void engineInitSign(Key privateKey) throws XMLSignatureException {
|
||||
engineInitSign(privateKey, (SecureRandom)null);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void engineUpdate(byte[] input) throws XMLSignatureException {
|
||||
try {
|
||||
this.signatureAlgorithm.update(input);
|
||||
@@ -136,6 +149,7 @@ public abstract class SignatureEDDSA extends SignatureAlgorithmSpi {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void engineUpdate(byte input) throws XMLSignatureException {
|
||||
try {
|
||||
this.signatureAlgorithm.update(input);
|
||||
@@ -145,6 +159,7 @@ public abstract class SignatureEDDSA extends SignatureAlgorithmSpi {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void engineUpdate(byte[] buf, int offset, int len) throws XMLSignatureException {
|
||||
try {
|
||||
this.signatureAlgorithm.update(buf, offset, len);
|
||||
@@ -154,22 +169,26 @@ public abstract class SignatureEDDSA extends SignatureAlgorithmSpi {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected String engineGetJCEAlgorithmString() {
|
||||
return this.signatureAlgorithm.getAlgorithm();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected String engineGetJCEProviderName() {
|
||||
return this.signatureAlgorithm.getProvider().getName();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void engineSetHMACOutputLength(int HMACOutputLength)
|
||||
throws XMLSignatureException {
|
||||
throw new XMLSignatureException("algorithms.HMACOutputLengthOnlyForHMAC");
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected void engineInitSign(
|
||||
Key signingKey, AlgorithmParameterSpec algorithmParameterSpec
|
||||
) throws XMLSignatureException {
|
||||
|
||||
@@ -122,7 +122,7 @@ public final class Canonicalizer {
|
||||
* @return a Canonicalizer instance ready for the job
|
||||
* @throws InvalidCanonicalizerException
|
||||
*/
|
||||
public static final Canonicalizer getInstance(String algorithmURI)
|
||||
public static Canonicalizer getInstance(String algorithmURI)
|
||||
throws InvalidCanonicalizerException {
|
||||
return new Canonicalizer(algorithmURI);
|
||||
}
|
||||
|
||||
@@ -22,11 +22,12 @@
|
||||
*/
|
||||
package com.sun.org.apache.xml.internal.security.c14n.helper;
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.utils.Constants;
|
||||
import org.w3c.dom.Attr;
|
||||
import java.io.Serializable;
|
||||
import java.util.Comparator;
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.utils.Constants;
|
||||
import org.w3c.dom.Attr;
|
||||
|
||||
/**
|
||||
* Compares two attributes based on the C14n specification.
|
||||
*
|
||||
@@ -69,6 +70,7 @@ public class AttrCompare implements Comparator<Attr>, Serializable {
|
||||
* obj0 is less than, equal to, or greater than obj1
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public int compare(Attr attr0, Attr attr1) {
|
||||
String namespaceURI0 = attr0.getNamespaceURI();
|
||||
String namespaceURI1 = attr1.getNamespaceURI();
|
||||
|
||||
@@ -32,6 +32,7 @@ public class Canonicalizer11_OmitComments extends Canonicalizer20010315 {
|
||||
super(false, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String engineGetURI() {
|
||||
return Canonicalizer.ALGO_ID_C14N11_OMIT_COMMENTS;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ public class Canonicalizer11_WithComments extends Canonicalizer20010315 {
|
||||
super(true, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String engineGetURI() {
|
||||
return Canonicalizer.ALGO_ID_C14N11_WITH_COMMENTS;
|
||||
}
|
||||
|
||||
@@ -83,6 +83,7 @@ public abstract class Canonicalizer20010315 extends CanonicalizerBase {
|
||||
* @param writer OutputStream to write the canonicalization result
|
||||
* @throws CanonicalizationException always
|
||||
*/
|
||||
@Override
|
||||
public void engineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet, String inclusiveNamespaces, OutputStream writer)
|
||||
throws CanonicalizationException {
|
||||
|
||||
@@ -98,6 +99,7 @@ public abstract class Canonicalizer20010315 extends CanonicalizerBase {
|
||||
* @param writer OutputStream to write the canonicalization result
|
||||
* @throws CanonicalizationException
|
||||
*/
|
||||
@Override
|
||||
public void engineCanonicalizeSubTree(Node rootNode, String inclusiveNamespaces, OutputStream writer)
|
||||
throws CanonicalizationException {
|
||||
|
||||
@@ -113,6 +115,7 @@ public abstract class Canonicalizer20010315 extends CanonicalizerBase {
|
||||
* @param writer OutputStream to write the canonicalization result
|
||||
* @throws CanonicalizationException
|
||||
*/
|
||||
@Override
|
||||
public void engineCanonicalizeSubTree(
|
||||
Node rootNode, String inclusiveNamespaces, boolean propagateDefaultNamespace, OutputStream writer)
|
||||
throws CanonicalizationException {
|
||||
@@ -297,6 +300,7 @@ public abstract class Canonicalizer20010315 extends CanonicalizerBase {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void circumventBugIfNeeded(XMLSignatureInput input)
|
||||
throws XMLParserException, IOException {
|
||||
if (!input.isNeedsToBeExpanded()) {
|
||||
|
||||
@@ -82,6 +82,7 @@ public abstract class Canonicalizer20010315Excl extends CanonicalizerBase {
|
||||
* @param writer OutputStream to write the canonicalization result
|
||||
* @throws CanonicalizationException
|
||||
*/
|
||||
@Override
|
||||
public void engineCanonicalizeSubTree(Node rootNode, OutputStream writer)
|
||||
throws CanonicalizationException {
|
||||
engineCanonicalizeSubTree(rootNode, "", null, writer);
|
||||
@@ -95,6 +96,7 @@ public abstract class Canonicalizer20010315Excl extends CanonicalizerBase {
|
||||
* @param writer OutputStream to write the canonicalization result
|
||||
* @throws CanonicalizationException
|
||||
*/
|
||||
@Override
|
||||
public void engineCanonicalizeSubTree(
|
||||
Node rootNode, String inclusiveNamespaces, OutputStream writer
|
||||
) throws CanonicalizationException {
|
||||
@@ -110,6 +112,7 @@ public abstract class Canonicalizer20010315Excl extends CanonicalizerBase {
|
||||
* @param writer OutputStream to write the canonicalization result
|
||||
* @throws CanonicalizationException
|
||||
*/
|
||||
@Override
|
||||
public void engineCanonicalizeSubTree(
|
||||
Node rootNode, String inclusiveNamespaces, boolean propagateDefaultNamespace, OutputStream writer
|
||||
) throws CanonicalizationException {
|
||||
@@ -155,6 +158,7 @@ public abstract class Canonicalizer20010315Excl extends CanonicalizerBase {
|
||||
* @param writer OutputStream to write the canonicalization result
|
||||
* @throws CanonicalizationException
|
||||
*/
|
||||
@Override
|
||||
public void engineCanonicalizeXPathNodeSet(
|
||||
Set<Node> xpathNodeSet, String inclusiveNamespaces, OutputStream writer
|
||||
) throws CanonicalizationException {
|
||||
@@ -336,6 +340,7 @@ public abstract class Canonicalizer20010315Excl extends CanonicalizerBase {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void circumventBugIfNeeded(XMLSignatureInput input)
|
||||
throws XMLParserException, IOException {
|
||||
if (!input.isNeedsToBeExpanded() || inclusiveNSSet.isEmpty()) {
|
||||
|
||||
@@ -34,6 +34,7 @@ public class Canonicalizer20010315ExclOmitComments extends Canonicalizer20010315
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final String engineGetURI() {
|
||||
return Canonicalizer.ALGO_ID_C14N_EXCL_OMIT_COMMENTS;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ public class Canonicalizer20010315ExclWithComments extends Canonicalizer20010315
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final String engineGetURI() {
|
||||
return Canonicalizer.ALGO_ID_C14N_EXCL_WITH_COMMENTS;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ public class Canonicalizer20010315OmitComments extends Canonicalizer20010315 {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final String engineGetURI() {
|
||||
return Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS;
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ public class Canonicalizer20010315WithComments extends Canonicalizer20010315 {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final String engineGetURI() {
|
||||
return Canonicalizer.ALGO_ID_C14N_WITH_COMMENTS;
|
||||
}
|
||||
|
||||
@@ -107,6 +107,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
|
||||
* @param writer OutputStream to write the canonicalization result
|
||||
* @throws CanonicalizationException
|
||||
*/
|
||||
@Override
|
||||
public void engineCanonicalizeSubTree(Node rootNode, OutputStream writer)
|
||||
throws CanonicalizationException {
|
||||
engineCanonicalizeSubTree(rootNode, (Node)null, writer);
|
||||
@@ -119,6 +120,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
|
||||
* @param writer OutputStream to write the canonicalization result
|
||||
* @throws CanonicalizationException
|
||||
*/
|
||||
@Override
|
||||
public void engineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet, OutputStream writer)
|
||||
throws CanonicalizationException {
|
||||
this.xpathNodeSet = xpathNodeSet;
|
||||
@@ -457,8 +459,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
|
||||
} while(true);
|
||||
}
|
||||
|
||||
protected int isVisibleDO(Node currentNode, int level)
|
||||
throws CanonicalizationException {
|
||||
protected int isVisibleDO(Node currentNode, int level) throws CanonicalizationException {
|
||||
if (nodeFilter != null) {
|
||||
for (NodeFilter filter : nodeFilter) {
|
||||
try {
|
||||
@@ -477,8 +478,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
|
||||
return 1;
|
||||
}
|
||||
|
||||
protected int isVisibleInt(Node currentNode)
|
||||
throws CanonicalizationException {
|
||||
protected int isVisibleInt(Node currentNode) throws CanonicalizationException {
|
||||
if (nodeFilter != null) {
|
||||
for (NodeFilter filter : nodeFilter) {
|
||||
try {
|
||||
|
||||
@@ -68,6 +68,7 @@ public class CanonicalizerPhysical extends CanonicalizerBase {
|
||||
* @param writer OutputStream to write the canonicalization result
|
||||
* @throws CanonicalizationException always
|
||||
*/
|
||||
@Override
|
||||
public void engineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet, String inclusiveNamespaces, OutputStream writer)
|
||||
throws CanonicalizationException {
|
||||
|
||||
@@ -83,6 +84,7 @@ public class CanonicalizerPhysical extends CanonicalizerBase {
|
||||
* @param writer OutputStream to write the canonicalization result
|
||||
* @throws CanonicalizationException
|
||||
*/
|
||||
@Override
|
||||
public void engineCanonicalizeSubTree(Node rootNode, String inclusiveNamespaces, OutputStream writer)
|
||||
throws CanonicalizationException {
|
||||
|
||||
@@ -98,6 +100,7 @@ public class CanonicalizerPhysical extends CanonicalizerBase {
|
||||
* @param writer OutputStream to write the canonicalization result
|
||||
* @throws CanonicalizationException
|
||||
*/
|
||||
@Override
|
||||
public void engineCanonicalizeSubTree(
|
||||
Node rootNode, String inclusiveNamespaces, boolean propagateDefaultNamespace, OutputStream writer)
|
||||
throws CanonicalizationException {
|
||||
@@ -165,6 +168,7 @@ public class CanonicalizerPhysical extends CanonicalizerBase {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final String engineGetURI() {
|
||||
return Canonicalizer.ALGO_ID_C14N_PHYSICAL;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
@@ -74,16 +73,16 @@ public class NameSpaceSymbTable {
|
||||
* @param result the list where to fill the unrendered xmlns definitions.
|
||||
**/
|
||||
public void getUnrenderedNodes(Collection<Attr> result) {
|
||||
for (NameSpaceSymbEntry n : symb.entrySet()) {
|
||||
for (NameSpaceSymbEntry nsEntry : symb.entrySet()) {
|
||||
//put them rendered?
|
||||
if (!n.rendered && n.n != null) {
|
||||
n = n.clone();
|
||||
if (!nsEntry.rendered && nsEntry.n != null) {
|
||||
nsEntry = nsEntry.clone();
|
||||
needsClone();
|
||||
symb.put(n.prefix, n);
|
||||
n.lastrendered = n.uri;
|
||||
n.rendered = true;
|
||||
symb.put(nsEntry.prefix, nsEntry);
|
||||
nsEntry.lastrendered = nsEntry.uri;
|
||||
nsEntry.rendered = true;
|
||||
|
||||
result.add(n.n);
|
||||
result.add(nsEntry.n);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -311,6 +310,7 @@ class NameSpaceSymbEntry implements Cloneable {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public NameSpaceSymbEntry clone() { //NOPMD
|
||||
try {
|
||||
return (NameSpaceSymbEntry)super.clone();
|
||||
@@ -344,9 +344,9 @@ class SymbMap implements Cloneable {
|
||||
|
||||
List<NameSpaceSymbEntry> entrySet() {
|
||||
List<NameSpaceSymbEntry> a = new ArrayList<>();
|
||||
for (int i = 0;i < entries.length;i++) {
|
||||
if (entries[i] != null && entries[i].uri.length() != 0) {
|
||||
a.add(entries[i]);
|
||||
for (NameSpaceSymbEntry nsEntry : entries) {
|
||||
if (nsEntry != null && !nsEntry.uri.isEmpty()) {
|
||||
a.add(nsEntry);
|
||||
}
|
||||
}
|
||||
return a;
|
||||
|
||||
@@ -160,6 +160,7 @@ public class XMLSecurityException extends Exception {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String toString() {
|
||||
String s = this.getClass().getName();
|
||||
String message = super.getLocalizedMessage();
|
||||
@@ -181,6 +182,7 @@ public class XMLSecurityException extends Exception {
|
||||
* Method printStackTrace
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void printStackTrace() {
|
||||
synchronized (System.err) {
|
||||
super.printStackTrace(System.err);
|
||||
|
||||
@@ -1184,6 +1184,7 @@ public class KeyInfo extends SignatureElementProxy {
|
||||
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String getBaseLocalName() {
|
||||
return Constants._TAG_KEYINFO;
|
||||
}
|
||||
|
||||
@@ -98,6 +98,7 @@ public class DEREncodedKeyValue extends Signature11ElementProxy implements KeyIn
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String getBaseLocalName() {
|
||||
return Constants._TAG_DERENCODEDKEYVALUE;
|
||||
}
|
||||
|
||||
@@ -95,6 +95,7 @@ public class KeyInfoReference extends Signature11ElementProxy implements KeyInfo
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String getBaseLocalName() {
|
||||
return Constants._TAG_KEYINFOREFERENCE;
|
||||
}
|
||||
|
||||
@@ -65,6 +65,7 @@ public class KeyName extends SignatureElementProxy implements KeyInfoContent {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String getBaseLocalName() {
|
||||
return Constants._TAG_KEYNAME;
|
||||
}
|
||||
|
||||
@@ -160,6 +160,7 @@ public class KeyValue extends SignatureElementProxy implements KeyInfoContent {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String getBaseLocalName() {
|
||||
return Constants._TAG_KEYVALUE;
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ public class MgmtData extends SignatureElementProxy implements KeyInfoContent {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String getBaseLocalName() {
|
||||
return Constants._TAG_MGMTDATA;
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ public class PGPData extends SignatureElementProxy implements KeyInfoContent {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String getBaseLocalName() {
|
||||
return Constants._TAG_PGPDATA;
|
||||
}
|
||||
|
||||
@@ -129,6 +129,7 @@ public class RetrievalMethod extends SignatureElementProxy implements KeyInfoCon
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String getBaseLocalName() {
|
||||
return Constants._TAG_RETRIEVALMETHOD;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ public class SPKIData extends SignatureElementProxy implements KeyInfoContent {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String getBaseLocalName() {
|
||||
return Constants._TAG_SPKIDATA;
|
||||
}
|
||||
|
||||
@@ -528,6 +528,7 @@ public class X509Data extends SignatureElementProxy implements KeyInfoContent {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String getBaseLocalName() {
|
||||
return Constants._TAG_X509DATA;
|
||||
}
|
||||
|
||||
@@ -97,6 +97,7 @@ public class DSAKeyValue extends SignatureElementProxy implements KeyValueConten
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public PublicKey getPublicKey() throws XMLSecurityException {
|
||||
try {
|
||||
DSAPublicKeySpec pkspec =
|
||||
@@ -123,6 +124,7 @@ public class DSAKeyValue extends SignatureElementProxy implements KeyValueConten
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String getBaseLocalName() {
|
||||
return Constants._TAG_DSAKEYVALUE;
|
||||
}
|
||||
|
||||
@@ -40,16 +40,15 @@ import java.util.Arrays;
|
||||
|
||||
import javax.xml.crypto.MarshalException;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
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.I18n;
|
||||
import com.sun.org.apache.xml.internal.security.utils.Signature11ElementProxy;
|
||||
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
public class ECKeyValue extends Signature11ElementProxy implements KeyValueContent {
|
||||
|
||||
@@ -161,6 +160,7 @@ public class ECKeyValue extends Signature11ElementProxy implements KeyValueConte
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public PublicKey getPublicKey() throws XMLSecurityException {
|
||||
try {
|
||||
ECParameterSpec ecParams = null;
|
||||
@@ -210,6 +210,7 @@ public class ECKeyValue extends Signature11ElementProxy implements KeyValueConte
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String getBaseLocalName() {
|
||||
return Constants._TAG_ECKEYVALUE;
|
||||
}
|
||||
|
||||
@@ -93,6 +93,7 @@ public class RSAKeyValue extends SignatureElementProxy implements KeyValueConten
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public PublicKey getPublicKey() throws XMLSecurityException {
|
||||
try {
|
||||
KeyFactory rsaFactory = KeyFactory.getInstance("RSA");
|
||||
@@ -115,6 +116,7 @@ public class RSAKeyValue extends SignatureElementProxy implements KeyValueConten
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String getBaseLocalName() {
|
||||
return Constants._TAG_RSAKEYVALUE;
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ public class XMLX509CRL extends SignatureElementProxy implements XMLX509DataCont
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String getBaseLocalName() {
|
||||
return Constants._TAG_X509CRL;
|
||||
}
|
||||
|
||||
@@ -127,6 +127,7 @@ public class XMLX509Certificate extends SignatureElementProxy implements XMLX509
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof XMLX509Certificate)) {
|
||||
return false;
|
||||
@@ -139,12 +140,13 @@ public class XMLX509Certificate extends SignatureElementProxy implements XMLX509
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 17;
|
||||
try {
|
||||
byte[] bytes = getCertificateBytes();
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
result = 31 * result + bytes[i];
|
||||
for (byte element : bytes) {
|
||||
result = 31 * result + element;
|
||||
}
|
||||
} catch (XMLSecurityException e) {
|
||||
LOG.debug(e.getMessage(), e);
|
||||
@@ -153,6 +155,7 @@ public class XMLX509Certificate extends SignatureElementProxy implements XMLX509
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String getBaseLocalName() {
|
||||
return Constants._TAG_X509CERTIFICATE;
|
||||
}
|
||||
|
||||
@@ -132,6 +132,7 @@ public class XMLX509Digest extends Signature11ElementProxy implements XMLX509Dat
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String getBaseLocalName() {
|
||||
return Constants._TAG_X509DIGEST;
|
||||
}
|
||||
|
||||
@@ -132,6 +132,7 @@ public class XMLX509IssuerSerial extends SignatureElementProxy implements XMLX50
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof XMLX509IssuerSerial)) {
|
||||
return false;
|
||||
@@ -143,6 +144,7 @@ public class XMLX509IssuerSerial extends SignatureElementProxy implements XMLX50
|
||||
&& this.getIssuerName().equals(other.getIssuerName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 17;
|
||||
result = 31 * result + getSerialNumber().hashCode();
|
||||
@@ -151,6 +153,7 @@ public class XMLX509IssuerSerial extends SignatureElementProxy implements XMLX50
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String getBaseLocalName() {
|
||||
return Constants._TAG_X509ISSUERSERIAL;
|
||||
}
|
||||
|
||||
@@ -145,6 +145,7 @@ public class XMLX509SKI extends SignatureElementProxy implements XMLX509DataCont
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof XMLX509SKI)) {
|
||||
return false;
|
||||
@@ -159,12 +160,13 @@ public class XMLX509SKI extends SignatureElementProxy implements XMLX509DataCont
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 17;
|
||||
try {
|
||||
byte[] bytes = getSKIBytes();
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
result = 31 * result + bytes[i];
|
||||
for (byte element : bytes) {
|
||||
result = 31 * result + element;
|
||||
}
|
||||
} catch (XMLSecurityException e) {
|
||||
LOG.debug(e.getMessage(), e);
|
||||
@@ -174,6 +176,7 @@ public class XMLX509SKI extends SignatureElementProxy implements XMLX509DataCont
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String getBaseLocalName() {
|
||||
return Constants._TAG_X509SKI;
|
||||
}
|
||||
|
||||
@@ -80,6 +80,7 @@ public class XMLX509SubjectName extends SignatureElementProxy implements XMLX509
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof XMLX509SubjectName)) {
|
||||
return false;
|
||||
@@ -92,6 +93,7 @@ public class XMLX509SubjectName extends SignatureElementProxy implements XMLX509
|
||||
return thisSubject.equals(otherSubject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 17;
|
||||
result = 31 * result + this.getSubjectName().hashCode();
|
||||
@@ -99,6 +101,7 @@ public class XMLX509SubjectName extends SignatureElementProxy implements XMLX509
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String getBaseLocalName() {
|
||||
return Constants._TAG_X509SUBJECTNAME;
|
||||
}
|
||||
|
||||
@@ -31,9 +31,6 @@ import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations.DEREncodedKeyValueResolver;
|
||||
import com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations.DSAKeyValueResolver;
|
||||
import com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations.ECKeyValueResolver;
|
||||
@@ -47,6 +44,8 @@ import com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations
|
||||
import com.sun.org.apache.xml.internal.security.keys.keyresolver.implementations.X509SubjectNameResolver;
|
||||
import com.sun.org.apache.xml.internal.security.keys.storage.StorageResolver;
|
||||
import com.sun.org.apache.xml.internal.security.utils.JavaUtils;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/**
|
||||
* KeyResolver is factory class for subclass of KeyResolverSpi that
|
||||
@@ -295,10 +294,12 @@ public class KeyResolver {
|
||||
it = res.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return it.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyResolverSpi next() {
|
||||
KeyResolverSpi resolver = it.next();
|
||||
if (resolver == null) {
|
||||
@@ -308,6 +309,7 @@ public class KeyResolver {
|
||||
return resolver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException("Can't remove resolvers using the iterator");
|
||||
}
|
||||
|
||||
@@ -32,7 +32,9 @@ import java.security.cert.CertificateEncodingException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.Arrays;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import javax.crypto.SecretKey;
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
|
||||
import com.sun.org.apache.xml.internal.security.keys.content.X509Data;
|
||||
import com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509Certificate;
|
||||
|
||||
@@ -26,7 +26,6 @@ import java.security.PrivateKey;
|
||||
import java.security.PublicKey;
|
||||
import java.security.cert.X509Certificate;
|
||||
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
|
||||
import com.sun.org.apache.xml.internal.security.keys.content.keyvalues.RSAKeyValue;
|
||||
import com.sun.org.apache.xml.internal.security.keys.keyresolver.KeyResolverSpi;
|
||||
|
||||
@@ -27,7 +27,9 @@ import java.security.KeyStore;
|
||||
import java.security.PrivateKey;
|
||||
import java.security.PublicKey;
|
||||
import java.security.cert.X509Certificate;
|
||||
|
||||
import javax.crypto.SecretKey;
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.keys.keyresolver.KeyResolverException;
|
||||
import com.sun.org.apache.xml.internal.security.keys.keyresolver.KeyResolverSpi;
|
||||
import com.sun.org.apache.xml.internal.security.keys.storage.StorageResolver;
|
||||
|
||||
@@ -25,7 +25,9 @@ package com.sun.org.apache.xml.internal.security.keys.keyresolver.implementation
|
||||
import java.security.PrivateKey;
|
||||
import java.security.PublicKey;
|
||||
import java.security.cert.X509Certificate;
|
||||
|
||||
import javax.crypto.SecretKey;
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.keys.keyresolver.KeyResolverException;
|
||||
import com.sun.org.apache.xml.internal.security.keys.keyresolver.KeyResolverSpi;
|
||||
import com.sun.org.apache.xml.internal.security.keys.storage.StorageResolver;
|
||||
|
||||
@@ -86,8 +86,8 @@ public class X509CertificateResolver extends KeyResolverSpi {
|
||||
}
|
||||
|
||||
// populate Object array
|
||||
for (int i = 0; i < els.length; i++) {
|
||||
XMLX509Certificate xmlCert = new XMLX509Certificate(els[i], baseURI);
|
||||
for (Element el : els) {
|
||||
XMLX509Certificate xmlCert = new XMLX509Certificate(el, baseURI);
|
||||
X509Certificate cert = xmlCert.getX509Certificate();
|
||||
if (cert != null) {
|
||||
return cert;
|
||||
|
||||
@@ -134,8 +134,7 @@ public class X509DigestResolver extends KeyResolverSpi {
|
||||
while (storageIterator.hasNext()) {
|
||||
X509Certificate cert = (X509Certificate) storageIterator.next();
|
||||
|
||||
for (int i = 0; i < x509Digests.length; i++) {
|
||||
XMLX509Digest keyInfoDigest = x509Digests[i];
|
||||
for (XMLX509Digest keyInfoDigest : x509Digests) {
|
||||
byte[] certDigestBytes = XMLX509Digest.getDigestBytesFromCert(cert, keyInfoDigest.getAlgorithm());
|
||||
|
||||
if (Arrays.equals(keyInfoDigest.getDigestBytes(), certDigestBytes)) {
|
||||
|
||||
@@ -28,7 +28,6 @@ import java.security.cert.Certificate;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.Iterator;
|
||||
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
|
||||
import com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509SKI;
|
||||
import com.sun.org.apache.xml.internal.security.keys.keyresolver.KeyResolverException;
|
||||
@@ -95,20 +94,18 @@ public class X509SKIResolver extends KeyResolverSpi {
|
||||
}
|
||||
|
||||
XMLX509SKI[] x509childObject = new XMLX509SKI[x509childNodes.length];
|
||||
|
||||
for (int i = 0; i < x509childNodes.length; i++) {
|
||||
x509childObject[i] = new XMLX509SKI(x509childNodes[i], baseURI);
|
||||
}
|
||||
|
||||
Iterator<Certificate> storageIterator = storage.getIterator();
|
||||
while (storageIterator.hasNext()) {
|
||||
X509Certificate cert = (X509Certificate)storageIterator.next();
|
||||
X509Certificate cert = (X509Certificate) storageIterator.next();
|
||||
XMLX509SKI certSKI = new XMLX509SKI(element.getOwnerDocument(), cert);
|
||||
|
||||
for (int i = 0; i < x509childObject.length; i++) {
|
||||
if (certSKI.equals(x509childObject[i])) {
|
||||
for (XMLX509SKI childNodeSKI : x509childObject) {
|
||||
if (certSKI.equals(childNodeSKI)) {
|
||||
LOG.debug("Return PublicKey from {}", cert.getSubjectX500Principal().getName());
|
||||
|
||||
return cert;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ import java.security.cert.Certificate;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.Iterator;
|
||||
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
|
||||
import com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509SubjectName;
|
||||
import com.sun.org.apache.xml.internal.security.keys.keyresolver.KeyResolverException;
|
||||
@@ -101,18 +100,15 @@ public class X509SubjectNameResolver extends KeyResolverSpi {
|
||||
|
||||
Iterator<Certificate> storageIterator = storage.getIterator();
|
||||
while (storageIterator.hasNext()) {
|
||||
X509Certificate cert = (X509Certificate)storageIterator.next();
|
||||
XMLX509SubjectName certSN =
|
||||
new XMLX509SubjectName(element.getOwnerDocument(), cert);
|
||||
|
||||
X509Certificate cert = (X509Certificate) storageIterator.next();
|
||||
XMLX509SubjectName certSN = new XMLX509SubjectName(element.getOwnerDocument(), cert);
|
||||
LOG.debug("Found Certificate SN: {}", certSN.getSubjectName());
|
||||
|
||||
for (int i = 0; i < x509childObject.length; i++) {
|
||||
LOG.debug("Found Element SN: {}", x509childObject[i].getSubjectName());
|
||||
for (XMLX509SubjectName childSubject : x509childObject) {
|
||||
LOG.debug("Found Element SN: {}", childSubject.getSubjectName());
|
||||
|
||||
if (certSN.equals(x509childObject[i])) {
|
||||
if (certSN.equals(childSubject)) {
|
||||
LOG.debug("match !!! ");
|
||||
|
||||
return cert;
|
||||
}
|
||||
LOG.debug("no match...");
|
||||
@@ -122,7 +118,6 @@ public class X509SubjectNameResolver extends KeyResolverSpi {
|
||||
return null;
|
||||
} catch (XMLSecurityException ex) {
|
||||
LOG.debug("XMLSecurityException", ex);
|
||||
|
||||
throw new KeyResolverException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,6 +133,7 @@ public class StorageResolver {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
if (currentResolver == null) {
|
||||
return false;
|
||||
@@ -147,6 +148,7 @@ public class StorageResolver {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Certificate next() {
|
||||
if (hasNext()) {
|
||||
return currentResolver.next();
|
||||
@@ -158,6 +160,7 @@ public class StorageResolver {
|
||||
/**
|
||||
* Method remove
|
||||
*/
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException("Can't remove keys from KeyStore");
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ public class KeyStoreResolver extends StorageResolverSpi {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Iterator<Certificate> getIterator() {
|
||||
return new KeyStoreIterator(this.keyStore);
|
||||
}
|
||||
@@ -103,11 +104,13 @@ public class KeyStoreResolver extends StorageResolverSpi {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return this.i < this.certs.size();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Certificate next() {
|
||||
if (hasNext()) {
|
||||
return this.certs.get(this.i++);
|
||||
@@ -119,6 +122,7 @@ public class KeyStoreResolver extends StorageResolverSpi {
|
||||
/**
|
||||
* Method remove
|
||||
*/
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException("Can't remove keys from KeyStore");
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ public class SingleCertificateResolver extends StorageResolverSpi {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Iterator<Certificate> getIterator() {
|
||||
return new InternalIterator(this.certificate);
|
||||
}
|
||||
@@ -71,11 +72,13 @@ public class SingleCertificateResolver extends StorageResolverSpi {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return !this.alreadyReturned;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public Certificate next() {
|
||||
if (this.alreadyReturned) {
|
||||
throw new NoSuchElementException();
|
||||
@@ -87,6 +90,7 @@ public class SingleCertificateResolver extends StorageResolverSpi {
|
||||
/**
|
||||
* Method remove
|
||||
*/
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException("Can't remove keys from KeyStore");
|
||||
}
|
||||
|
||||
@@ -31,6 +31,15 @@ import org.w3c.dom.Document;
|
||||
*/
|
||||
public interface XMLParser {
|
||||
|
||||
/**
|
||||
* Parses a document from the input stream.
|
||||
* Caller is responsible for closing the stream.
|
||||
*
|
||||
* @param inputStream
|
||||
* @param disallowDocTypeDeclarations
|
||||
* @return {@link Document}
|
||||
* @throws XMLParserException
|
||||
*/
|
||||
Document parse(InputStream inputStream, boolean disallowDocTypeDeclarations) throws XMLParserException;
|
||||
|
||||
}
|
||||
@@ -51,10 +51,10 @@ public class XMLParserImpl implements XMLParser {
|
||||
(PrivilegedAction<Integer>) () -> Integer.getInteger("com.sun.org.apache.xml.internal.security.parser.pool-size", 20));
|
||||
|
||||
private static final Map<ClassLoader, Queue<DocumentBuilder>> DOCUMENT_BUILDERS =
|
||||
Collections.synchronizedMap(new WeakHashMap<ClassLoader, Queue<DocumentBuilder>>());
|
||||
Collections.synchronizedMap(new WeakHashMap<>());
|
||||
|
||||
private static final Map<ClassLoader, Queue<DocumentBuilder>> DOCUMENT_BUILDERS_DISALLOW_DOCTYPE =
|
||||
Collections.synchronizedMap(new WeakHashMap<ClassLoader, Queue<DocumentBuilder>>());
|
||||
Collections.synchronizedMap(new WeakHashMap<>());
|
||||
|
||||
@Override
|
||||
public Document parse(InputStream inputStream, boolean disallowDocTypeDeclarations) throws XMLParserException {
|
||||
@@ -119,6 +119,7 @@ public class XMLParserImpl implements XMLParser {
|
||||
final SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
|
||||
@Override
|
||||
public ClassLoader run() {
|
||||
return Thread.currentThread().getContextClassLoader();
|
||||
}
|
||||
@@ -132,6 +133,7 @@ public class XMLParserImpl implements XMLParser {
|
||||
final SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null) {
|
||||
return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
|
||||
@Override
|
||||
public ClassLoader run() {
|
||||
return clazz.getClassLoader();
|
||||
}
|
||||
|
||||
@@ -575,6 +575,7 @@ public class Manifest extends SignatureElementProxy {
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getBaseLocalName() {
|
||||
return Constants._TAG_MANIFEST;
|
||||
}
|
||||
|
||||
@@ -130,6 +130,7 @@ public class ObjectContainer extends SignatureElementProxy {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String getBaseLocalName() {
|
||||
return Constants._TAG_OBJECT;
|
||||
}
|
||||
|
||||
@@ -193,10 +193,12 @@ public class Reference extends SignatureElementProxy {
|
||||
|
||||
// Create DigestMethod Element without actually instantiating a MessageDigest Object
|
||||
Algorithm digestAlgorithm = new Algorithm(getDocument(), messageDigestAlgorithm) {
|
||||
@Override
|
||||
public String getBaseNamespace() {
|
||||
return Constants.SignatureSpecNS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBaseLocalName() {
|
||||
return Constants._TAG_DIGESTMETHOD;
|
||||
}
|
||||
@@ -612,6 +614,7 @@ public class Reference extends SignatureElementProxy {
|
||||
try {
|
||||
final Set<Node> s = input.getNodeSet();
|
||||
referenceData = new ReferenceNodeSetData() {
|
||||
@Override
|
||||
public Iterator<Node> iterator() {
|
||||
return new Iterator<Node>() {
|
||||
|
||||
@@ -808,6 +811,7 @@ public class Reference extends SignatureElementProxy {
|
||||
* Method getBaseLocalName
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String getBaseLocalName() {
|
||||
return Constants._TAG_REFERENCE;
|
||||
}
|
||||
|
||||
@@ -139,6 +139,7 @@ public class SignatureProperties extends SignatureElementProxy {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String getBaseLocalName() {
|
||||
return Constants._TAG_SIGNATUREPROPERTIES;
|
||||
}
|
||||
|
||||
@@ -126,6 +126,7 @@ public class SignatureProperty extends SignatureElementProxy {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String getBaseLocalName() {
|
||||
return Constants._TAG_SIGNATUREPROPERTY;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.security.Provider;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
@@ -38,7 +39,6 @@ import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
|
||||
import com.sun.org.apache.xml.internal.security.transforms.params.InclusiveNamespaces;
|
||||
import com.sun.org.apache.xml.internal.security.utils.Constants;
|
||||
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
@@ -401,6 +401,7 @@ public class SignedInfo extends Manifest {
|
||||
* {@inheritDoc}
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public String getBaseLocalName() {
|
||||
return Constants._TAG_SIGNEDINFO;
|
||||
}
|
||||
|
||||
@@ -1031,6 +1031,7 @@ public final class XMLSignature extends SignatureElementProxy {
|
||||
*
|
||||
* @return Constants._TAG_SIGNATURE
|
||||
*/
|
||||
@Override
|
||||
public String getBaseLocalName() {
|
||||
return Constants._TAG_SIGNATURE;
|
||||
}
|
||||
|
||||
@@ -391,6 +391,7 @@ public class XMLSignatureInput {
|
||||
* Method toString
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
if (isNodeSet()) {
|
||||
return "XMLSignatureInput/NodeSet/" + inputNodeSet.size()
|
||||
|
||||
@@ -30,6 +30,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
@@ -51,6 +52,7 @@ public class ReferenceSubTreeData implements ReferenceNodeSetData {
|
||||
this.excludeComments = excludeComments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Node> iterator() {
|
||||
return new DelayedNodeIterator(root, excludeComments);
|
||||
}
|
||||
@@ -78,6 +80,7 @@ public class ReferenceSubTreeData implements ReferenceNodeSetData {
|
||||
this.withComments = !excludeComments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
if (nodeSet == null) {
|
||||
nodeSet = dereferenceSameDocumentURI(root);
|
||||
@@ -86,6 +89,7 @@ public class ReferenceSubTreeData implements ReferenceNodeSetData {
|
||||
return li.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node next() {
|
||||
if (nodeSet == null) {
|
||||
nodeSet = dereferenceSameDocumentURI(root);
|
||||
@@ -98,6 +102,7 @@ public class ReferenceSubTreeData implements ReferenceNodeSetData {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ public final class Base64 {
|
||||
* @param bitlen {@code int} the desired length in bits of the representation
|
||||
* @return a byte array with {@code bitlen} bits of {@code big}
|
||||
*/
|
||||
static final byte[] getBytes(BigInteger big, int bitlen) {
|
||||
static byte[] getBytes(BigInteger big, int bitlen) {
|
||||
|
||||
//round bitlen
|
||||
bitlen = ((bitlen + 7) >> 3) << 3;
|
||||
@@ -148,7 +148,7 @@ public final class Base64 {
|
||||
* @param big
|
||||
* @return String with Base64 encoding
|
||||
*/
|
||||
public static final String encode(BigInteger big) {
|
||||
public static String encode(BigInteger big) {
|
||||
byte[] bytes = XMLUtils.getBytes(big, big.bitLength());
|
||||
return XMLUtils.encodeToString(bytes);
|
||||
}
|
||||
@@ -164,7 +164,7 @@ public final class Base64 {
|
||||
* @param bitlen {@code int} the desired length in bits of the representation
|
||||
* @return a byte array with {@code bitlen} bits of {@code big}
|
||||
*/
|
||||
public static final byte[] encode(BigInteger big, int bitlen) {
|
||||
public static byte[] encode(BigInteger big, int bitlen) {
|
||||
|
||||
//round bitlen
|
||||
bitlen = ((bitlen + 7) >> 3) << 3;
|
||||
@@ -205,7 +205,7 @@ public final class Base64 {
|
||||
* @return the biginteger obtained from the node
|
||||
* @throws Base64DecodingException
|
||||
*/
|
||||
public static final BigInteger decodeBigIntegerFromElement(Element element)
|
||||
public static BigInteger decodeBigIntegerFromElement(Element element)
|
||||
throws Base64DecodingException {
|
||||
return new BigInteger(1, Base64.decode(element));
|
||||
}
|
||||
@@ -216,7 +216,7 @@ public final class Base64 {
|
||||
* @return a decoded BigInteger
|
||||
* @throws Base64DecodingException
|
||||
*/
|
||||
public static final BigInteger decodeBigIntegerFromText(Text text)
|
||||
public static BigInteger decodeBigIntegerFromText(Text text)
|
||||
throws Base64DecodingException {
|
||||
return new BigInteger(1, Base64.decode(text.getData()));
|
||||
}
|
||||
@@ -228,7 +228,7 @@ public final class Base64 {
|
||||
* @param element
|
||||
* @param biginteger
|
||||
*/
|
||||
public static final void fillElementWithBigInteger(Element element, BigInteger biginteger) {
|
||||
public static void fillElementWithBigInteger(Element element, BigInteger biginteger) {
|
||||
|
||||
String encodedInt = encode(biginteger);
|
||||
|
||||
@@ -253,7 +253,7 @@ public final class Base64 {
|
||||
* $todo$ not tested yet
|
||||
* @throws Base64DecodingException
|
||||
*/
|
||||
public static final byte[] decode(Element element) throws Base64DecodingException {
|
||||
public static byte[] decode(Element element) throws Base64DecodingException {
|
||||
|
||||
Node sibling = element.getFirstChild();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
@@ -279,7 +279,7 @@ public final class Base64 {
|
||||
* @return an Element with the base64 encoded in the text.
|
||||
*
|
||||
*/
|
||||
public static final Element encodeToElement(Document doc, String localName, byte[] bytes) {
|
||||
public static Element encodeToElement(Document doc, String localName, byte[] bytes) {
|
||||
Element el = XMLUtils.createElementInSignatureSpace(doc, localName);
|
||||
Text text = doc.createTextNode(encode(bytes));
|
||||
|
||||
@@ -296,7 +296,7 @@ public final class Base64 {
|
||||
* @throws Base64DecodingException
|
||||
*
|
||||
*/
|
||||
public static final byte[] decode(byte[] base64) throws Base64DecodingException {
|
||||
public static byte[] decode(byte[] base64) throws Base64DecodingException {
|
||||
return decodeInternal(base64, -1);
|
||||
}
|
||||
|
||||
@@ -307,7 +307,7 @@ public final class Base64 {
|
||||
* @param binaryData {@code byte[]} to be base64 encoded
|
||||
* @return the {@code String} with encoded data
|
||||
*/
|
||||
public static final String encode(byte[] binaryData) {
|
||||
public static String encode(byte[] binaryData) {
|
||||
return XMLUtils.ignoreLineBreaks()
|
||||
? encode(binaryData, Integer.MAX_VALUE)
|
||||
: encode(binaryData, BASE64DEFAULTLENGTH);
|
||||
@@ -323,7 +323,7 @@ public final class Base64 {
|
||||
* @throws IOException
|
||||
* @throws Base64DecodingException
|
||||
*/
|
||||
public static final byte[] decode(BufferedReader reader)
|
||||
public static byte[] decode(BufferedReader reader)
|
||||
throws IOException, Base64DecodingException {
|
||||
|
||||
byte[] retBytes = null;
|
||||
@@ -342,11 +342,11 @@ public final class Base64 {
|
||||
return retBytes;
|
||||
}
|
||||
|
||||
protected static final boolean isWhiteSpace(byte octet) {
|
||||
protected static boolean isWhiteSpace(byte octet) {
|
||||
return octet == 0x20 || octet == 0xd || octet == 0xa || octet == 0x9;
|
||||
}
|
||||
|
||||
protected static final boolean isPad(byte octet) {
|
||||
protected static boolean isPad(byte octet) {
|
||||
return octet == PAD;
|
||||
}
|
||||
|
||||
@@ -364,7 +364,7 @@ public final class Base64 {
|
||||
* @param length {@code int} length of wrapped lines; No wrapping if less than 4.
|
||||
* @return a {@code String} with encoded data
|
||||
*/
|
||||
public static final String encode(byte[] binaryData, int length) {
|
||||
public static String encode(byte[] binaryData, int length) {
|
||||
if (length < 4) {
|
||||
length = Integer.MAX_VALUE;
|
||||
}
|
||||
@@ -474,7 +474,7 @@ public final class Base64 {
|
||||
* @return byte array containing the decoded data
|
||||
* @throws Base64DecodingException if there is a problem decoding the data
|
||||
*/
|
||||
public static final byte[] decode(String encoded) throws Base64DecodingException {
|
||||
public static byte[] decode(String encoded) throws Base64DecodingException {
|
||||
if (encoded == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -483,7 +483,7 @@ public final class Base64 {
|
||||
return decodeInternal(bytes, len);
|
||||
}
|
||||
|
||||
protected static final int getBytesInternal(String s, byte[] result) {
|
||||
protected static int getBytesInternal(String s, byte[] result) {
|
||||
int length = s.length();
|
||||
|
||||
int newSize = 0;
|
||||
@@ -496,7 +496,7 @@ public final class Base64 {
|
||||
return newSize;
|
||||
}
|
||||
|
||||
protected static final byte[] decodeInternal(byte[] base64Data, int len)
|
||||
protected static byte[] decodeInternal(byte[] base64Data, int len)
|
||||
throws Base64DecodingException {
|
||||
// remove white spaces
|
||||
if (len == -1) {
|
||||
@@ -591,7 +591,7 @@ public final class Base64 {
|
||||
* @throws IOException
|
||||
* @throws Base64DecodingException
|
||||
*/
|
||||
public static final void decode(String base64Data, OutputStream os)
|
||||
public static void decode(String base64Data, OutputStream os)
|
||||
throws Base64DecodingException, IOException {
|
||||
byte[] bytes = new byte[base64Data.length()];
|
||||
int len = getBytesInternal(base64Data, bytes);
|
||||
@@ -606,12 +606,12 @@ public final class Base64 {
|
||||
* @throws IOException
|
||||
* @throws Base64DecodingException
|
||||
*/
|
||||
public static final void decode(byte[] base64Data, OutputStream os)
|
||||
public static void decode(byte[] base64Data, OutputStream os)
|
||||
throws Base64DecodingException, IOException {
|
||||
decode(base64Data, os, -1);
|
||||
}
|
||||
|
||||
protected static final void decode(byte[] base64Data, OutputStream os, int len)
|
||||
protected static void decode(byte[] base64Data, OutputStream os, int len)
|
||||
throws Base64DecodingException, IOException {
|
||||
// remove white spaces
|
||||
if (len == -1) {
|
||||
@@ -694,7 +694,7 @@ public final class Base64 {
|
||||
* @throws IOException
|
||||
* @throws Base64DecodingException
|
||||
*/
|
||||
public static final void decode(InputStream is, OutputStream os)
|
||||
public static void decode(InputStream is, OutputStream os)
|
||||
throws Base64DecodingException, IOException {
|
||||
//byte[] decodedData = null;
|
||||
byte b1 = 0, b2 = 0, b3 = 0, b4 = 0;
|
||||
@@ -771,7 +771,7 @@ public final class Base64 {
|
||||
* @param data the byte array of base64 data (with WS)
|
||||
* @return the new length
|
||||
*/
|
||||
protected static final int removeWhiteSpace(byte[] data) {
|
||||
protected static int removeWhiteSpace(byte[] data) {
|
||||
if (data == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -84,6 +84,7 @@ public class DOMNamespaceContext implements NamespaceContext {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespaceURI(String prefix) {
|
||||
if (prefix == null) {
|
||||
throw new IllegalArgumentException("prefix is null");
|
||||
@@ -107,6 +108,7 @@ public class DOMNamespaceContext implements NamespaceContext {
|
||||
return NULL_NS_URI;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrefix(String namespaceURI) {
|
||||
if (namespaceURI == null) {
|
||||
throw new IllegalArgumentException("namespace URI is null");
|
||||
@@ -140,6 +142,7 @@ public class DOMNamespaceContext implements NamespaceContext {
|
||||
/**
|
||||
* Throws {@link UnsupportedOperationException}.
|
||||
*/
|
||||
@Override
|
||||
public Iterator<String> getPrefixes(String namespaceURI) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@@ -43,16 +43,19 @@ public class DigesterOutputStream extends ByteArrayOutputStream {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void write(byte[] arg0) {
|
||||
write(arg0, 0, arg0.length);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void write(int arg0) {
|
||||
@Override
|
||||
public synchronized void write(int arg0) {
|
||||
mda.update((byte)arg0);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void write(byte[] arg0, int arg1, int arg2) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Pre-digested input:");
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
package com.sun.org.apache.xml.internal.security.utils;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
|
||||
import org.w3c.dom.Attr;
|
||||
|
||||
@@ -57,6 +57,7 @@ public class HelperNodeList implements NodeList {
|
||||
* @param index
|
||||
* @return node with index i
|
||||
*/
|
||||
@Override
|
||||
public Node item(int index) {
|
||||
return nodes.get(index);
|
||||
}
|
||||
@@ -66,6 +67,7 @@ public class HelperNodeList implements NodeList {
|
||||
*
|
||||
* @return length of the list
|
||||
*/
|
||||
@Override
|
||||
public int getLength() {
|
||||
return nodes.size();
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ class JDKXPathAPI implements XPathAPI {
|
||||
*
|
||||
* @throws TransformerException
|
||||
*/
|
||||
@Override
|
||||
public NodeList selectNodeList(
|
||||
Node contextNode, Node xpathnode, String str, Node namespaceNode
|
||||
) throws TransformerException {
|
||||
@@ -92,6 +93,7 @@ class JDKXPathAPI implements XPathAPI {
|
||||
* @param str The XPath expression
|
||||
* @param namespaceNode The node from which prefixes in the XPath will be resolved to namespaces.
|
||||
*/
|
||||
@Override
|
||||
public boolean evaluate(Node contextNode, Node xpathnode, String str, Node namespaceNode)
|
||||
throws TransformerException {
|
||||
if (!str.equals(xpathStr) || xpathExpression == null) {
|
||||
@@ -122,6 +124,7 @@ class JDKXPathAPI implements XPathAPI {
|
||||
/**
|
||||
* Clear any context information from this object
|
||||
*/
|
||||
@Override
|
||||
public void clear() {
|
||||
xpathStr = null;
|
||||
xpathExpression = null;
|
||||
|
||||
@@ -31,6 +31,7 @@ public class JDKXPathFactory extends XPathFactory {
|
||||
/**
|
||||
* Get a new XPathAPI instance
|
||||
*/
|
||||
@Override
|
||||
public XPathAPI newXPathAPI() {
|
||||
return new JDKXPathAPI();
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public final class JavaUtils {
|
||||
|
||||
/**
|
||||
* This method reads all bytes from the given InputStream till EOF and
|
||||
* returns them as a byte array.
|
||||
* returns them as a byte array. The method doesn't close the input stream.
|
||||
*
|
||||
* @param inputStream
|
||||
* @return the bytes read from the stream
|
||||
|
||||
@@ -69,6 +69,7 @@ public abstract class Signature11ElementProxy extends ElementProxy {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String getBaseNamespace() {
|
||||
return Constants.SignatureSpec11NS;
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@ public abstract class SignatureElementProxy extends ElementProxy {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String getBaseNamespace() {
|
||||
return Constants.SignatureSpecNS;
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ public class SignerOutputStream extends ByteArrayOutputStream {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void write(byte[] arg0) {
|
||||
try {
|
||||
sa.update(arg0);
|
||||
@@ -53,6 +54,7 @@ public class SignerOutputStream extends ByteArrayOutputStream {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void write(int arg0) {
|
||||
try {
|
||||
sa.update((byte)arg0);
|
||||
@@ -62,6 +64,7 @@ public class SignerOutputStream extends ByteArrayOutputStream {
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void write(byte[] arg0, int arg1, int arg2) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Canonicalized SignedInfo:");
|
||||
|
||||
@@ -44,6 +44,7 @@ public class UnsyncByteArrayOutputStream extends OutputStream {
|
||||
buf = new byte[INITIAL_SIZE];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] arg0) {
|
||||
if ((VM_ARRAY_INDEX_MAX_VALUE - pos) < arg0.length) {
|
||||
throw new OutOfMemoryError("Required length exceeds implementation limit");
|
||||
@@ -56,6 +57,7 @@ public class UnsyncByteArrayOutputStream extends OutputStream {
|
||||
pos = newPos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] arg0, int arg1, int arg2) {
|
||||
if ((VM_ARRAY_INDEX_MAX_VALUE - pos) < arg2) {
|
||||
throw new OutOfMemoryError("Required length exceeds implementation limit");
|
||||
@@ -68,6 +70,7 @@ public class UnsyncByteArrayOutputStream extends OutputStream {
|
||||
pos = newPos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int arg0) {
|
||||
if (VM_ARRAY_INDEX_MAX_VALUE - pos == 0) {
|
||||
throw new OutOfMemoryError("Required length exceeds implementation limit");
|
||||
|
||||
@@ -22,11 +22,15 @@
|
||||
*/
|
||||
package com.sun.org.apache.xml.internal.security.utils;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.math.BigInteger;
|
||||
import java.nio.file.Files;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.ArrayList;
|
||||
@@ -42,6 +46,8 @@ import com.sun.org.apache.xml.internal.security.c14n.InvalidCanonicalizerExcepti
|
||||
import com.sun.org.apache.xml.internal.security.parser.XMLParser;
|
||||
import com.sun.org.apache.xml.internal.security.parser.XMLParserException;
|
||||
import com.sun.org.apache.xml.internal.security.parser.XMLParserImpl;
|
||||
import com.sun.org.slf4j.internal.Logger;
|
||||
import com.sun.org.slf4j.internal.LoggerFactory;
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
@@ -50,6 +56,8 @@ import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
/**
|
||||
* DOM and XML accessibility and comfort functions.
|
||||
*
|
||||
@@ -61,8 +69,7 @@ public final class XMLUtils {
|
||||
AccessController.doPrivileged(
|
||||
(PrivilegedAction<Boolean>) () -> Boolean.getBoolean("com.sun.org.apache.xml.internal.security.ignoreLineBreaks"));
|
||||
|
||||
private static final com.sun.org.slf4j.internal.Logger LOG =
|
||||
com.sun.org.slf4j.internal.LoggerFactory.getLogger(XMLUtils.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(XMLUtils.class);
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
private static XMLParser xmlParserImpl =
|
||||
@@ -74,7 +81,7 @@ public final class XMLUtils {
|
||||
return (XMLParser) JavaUtils.newInstanceWithEmptyConstructor(
|
||||
ClassLoaderUtils.loadClass(xmlParserClass, XMLUtils.class));
|
||||
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException | InvocationTargetException e) {
|
||||
LOG.error("Error instantiating XMLParser. Falling back to XMLParserImpl");
|
||||
LOG.error("Error instantiating XMLParser. Falling back to XMLParserImpl", e);
|
||||
}
|
||||
}
|
||||
return new XMLParserImpl();
|
||||
@@ -149,18 +156,18 @@ public final class XMLUtils {
|
||||
* @param rootNode
|
||||
* @param result
|
||||
* @param exclude
|
||||
* @param com whether comments or not
|
||||
* @param comments whether comments or not
|
||||
*/
|
||||
public static void getSet(Node rootNode, Set<Node> result, Node exclude, boolean com) {
|
||||
public static void getSet(Node rootNode, Set<Node> result, Node exclude, boolean comments) {
|
||||
if (exclude != null && isDescendantOrSelf(exclude, rootNode)) {
|
||||
return;
|
||||
}
|
||||
getSetRec(rootNode, result, exclude, com);
|
||||
getSetRec(rootNode, result, exclude, comments);
|
||||
}
|
||||
|
||||
@SuppressWarnings("fallthrough")
|
||||
private static void getSetRec(final Node rootNode, final Set<Node> result,
|
||||
final Node exclude, final boolean com) {
|
||||
final Node exclude, final boolean comments) {
|
||||
if (rootNode == exclude) {
|
||||
return;
|
||||
}
|
||||
@@ -187,11 +194,11 @@ public final class XMLUtils {
|
||||
return;
|
||||
}
|
||||
}
|
||||
getSetRec(r, result, exclude, com);
|
||||
getSetRec(r, result, exclude, comments);
|
||||
}
|
||||
break;
|
||||
case Node.COMMENT_NODE:
|
||||
if (com) {
|
||||
if (comments) {
|
||||
result.add(rootNode);
|
||||
}
|
||||
break;
|
||||
@@ -202,6 +209,18 @@ public final class XMLUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs a DOM tree to a {@link File}.
|
||||
*
|
||||
* @param contextNode root node of the DOM tree
|
||||
* @param outputFile the file to write to
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void outputDOM(Node contextNode, File outputFile) throws IOException {
|
||||
try (OutputStream os = new BufferedOutputStream(Files.newOutputStream(outputFile.toPath()), 8192)) {
|
||||
outputDOM(contextNode, os, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs a DOM tree to an {@link OutputStream}.
|
||||
@@ -210,7 +229,7 @@ public final class XMLUtils {
|
||||
* @param os the {@link OutputStream}
|
||||
*/
|
||||
public static void outputDOM(Node contextNode, OutputStream os) {
|
||||
XMLUtils.outputDOM(contextNode, os, false);
|
||||
outputDOM(contextNode, os, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -225,13 +244,12 @@ public final class XMLUtils {
|
||||
public static void outputDOM(Node contextNode, OutputStream os, boolean addPreamble) {
|
||||
try {
|
||||
if (addPreamble) {
|
||||
os.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n".getBytes(java.nio.charset.StandardCharsets.UTF_8));
|
||||
os.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n".getBytes(UTF_8));
|
||||
}
|
||||
|
||||
Canonicalizer.getInstance(
|
||||
Canonicalizer.ALGO_ID_C14N_PHYSICAL).canonicalizeSubtree(contextNode, os);
|
||||
} catch (IOException | InvalidCanonicalizerException | CanonicalizationException ex) {
|
||||
LOG.debug(ex.getMessage(), ex);
|
||||
LOG.error(ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,7 +271,7 @@ public final class XMLUtils {
|
||||
Canonicalizer.getInstance(
|
||||
Canonicalizer.ALGO_ID_C14N_WITH_COMMENTS).canonicalizeSubtree(contextNode, os);
|
||||
} catch (InvalidCanonicalizerException | CanonicalizationException ex) {
|
||||
LOG.debug(ex.getMessage(), ex);
|
||||
LOG.error(ex.getMessage(), ex);
|
||||
// throw new RuntimeException(ex.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -862,7 +880,7 @@ public final class XMLUtils {
|
||||
// Continue searching to find duplicates
|
||||
foundElement = attr.getOwnerElement();
|
||||
} else {
|
||||
LOG.debug("Multiple elements with the same 'Id' attribute value!");
|
||||
LOG.warn("Multiple elements with the same 'Id' attribute value!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -921,8 +939,8 @@ public final class XMLUtils {
|
||||
int length = attributes.getLength();
|
||||
for (int i = 0; i < length; i++) {
|
||||
Attr attr = (Attr)attributes.item(i);
|
||||
if (attr.isId() && id.equals(attr.getValue()) && se != knownElement) {
|
||||
LOG.debug("Multiple elements with the same 'Id' attribute value!");
|
||||
if (attr.isId() && id.equals(attr.getValue()) && !knownElement.isSameNode(se)) {
|
||||
LOG.warn("Multiple elements with the same 'Id' attribute value!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -952,6 +970,49 @@ public final class XMLUtils {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a document from the input stream.
|
||||
*
|
||||
* @param file
|
||||
* @param disallowDocTypeDeclarations
|
||||
* @return {@link Document}
|
||||
* @throws XMLParserException
|
||||
* @throws IOException
|
||||
*/
|
||||
public static Document read(File file, boolean disallowDocTypeDeclarations) throws XMLParserException, IOException {
|
||||
try (InputStream inputStream = new BufferedInputStream(Files.newInputStream(file.toPath()), 8192)) {
|
||||
return read(inputStream, disallowDocTypeDeclarations);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a document from the input stream and closes it.
|
||||
*
|
||||
* @param name - resource name to be opened by the class loader
|
||||
* @param loader
|
||||
* @param disallowDocTypeDeclarations
|
||||
* @return {@link Document}
|
||||
* @throws XMLParserException
|
||||
* @throws IOException inputStream.close() failed.
|
||||
*/
|
||||
public static Document readResource(String name, ClassLoader loader, boolean disallowDocTypeDeclarations)
|
||||
throws XMLParserException, IOException {
|
||||
// Delegate to XMLParser implementation
|
||||
try (InputStream inputStream = loader.getResourceAsStream(name)) {
|
||||
return read(inputStream, disallowDocTypeDeclarations);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a document from the input stream.
|
||||
* Caller is responsible for closing the stream.
|
||||
*
|
||||
* @param inputStream
|
||||
* @param disallowDocTypeDeclarations
|
||||
* @return {@link Document}
|
||||
* @throws XMLParserException
|
||||
*/
|
||||
public static Document read(InputStream inputStream, boolean disallowDocTypeDeclarations) throws XMLParserException {
|
||||
// Delegate to XMLParser implementation
|
||||
return xmlParserImpl.parse(inputStream, disallowDocTypeDeclarations);
|
||||
|
||||
@@ -27,8 +27,8 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Proxy;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -205,6 +205,7 @@ public class ResolverDirectHTTP extends ResourceResolverSpi {
|
||||
* @param context
|
||||
* @return true if can be resolved
|
||||
*/
|
||||
@Override
|
||||
public boolean engineCanResolveURI(ResourceResolverContext context) {
|
||||
if (context.uriToResolve == null) {
|
||||
LOG.debug("quick fail, uri == null");
|
||||
|
||||
@@ -110,6 +110,7 @@ public class ResolverFragment extends ResourceResolverSpi {
|
||||
* {@inheritDoc}
|
||||
* @param context
|
||||
*/
|
||||
@Override
|
||||
public boolean engineCanResolveURI(ResourceResolverContext context) {
|
||||
if (context.uriToResolve == null) {
|
||||
LOG.debug("Quick fail for null uri");
|
||||
|
||||
@@ -66,6 +66,7 @@ public class ResolverLocalFilesystem extends ResourceResolverSpi {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean engineCanResolveURI(ResourceResolverContext context) {
|
||||
if (context.uriToResolve == null) {
|
||||
return false;
|
||||
|
||||
@@ -104,6 +104,7 @@ public class ResolverXPointer extends ResourceResolverSpi {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean engineCanResolveURI(ResourceResolverContext context) {
|
||||
return isXPointerSlash(context.uriToResolve) || isXPointerId(context.uriToResolve);
|
||||
}
|
||||
|
||||
@@ -275,6 +275,43 @@ public interface SignatureMethod extends XMLStructure, AlgorithmMethod {
|
||||
*/
|
||||
String ED448 = "http://www.w3.org/2021/04/xmldsig-more#eddsa-ed448";
|
||||
|
||||
/**
|
||||
* The <a href="http://www.w3.org/2007/05/xmldsig-more#sha3-224-rsa-MGF1">
|
||||
* SHA3-224-RSA-MGF1</a> (PKCS #1) signature method algorithm URI.
|
||||
*
|
||||
* @since 22
|
||||
*/
|
||||
String SHA3_224_RSA_MGF1 =
|
||||
"http://www.w3.org/2007/05/xmldsig-more#sha3-224-rsa-MGF1";
|
||||
|
||||
/**
|
||||
* The <a href="http://www.w3.org/2007/05/xmldsig-more#sha3-256-rsa-MGF1">
|
||||
* SHA3-256-RSA-MGF1</a> (PKCS #1) signature method algorithm URI.
|
||||
*
|
||||
* @since 22
|
||||
*/
|
||||
String SHA3_256_RSA_MGF1 =
|
||||
"http://www.w3.org/2007/05/xmldsig-more#sha3-256-rsa-MGF1";
|
||||
|
||||
/**
|
||||
* The <a href="http://www.w3.org/2007/05/xmldsig-more#sha3-384-rsa-MGF1">
|
||||
* SHA3-384-RSA-MGF1</a> (PKCS #1) signature method algorithm URI.
|
||||
*
|
||||
* @since 22
|
||||
*/
|
||||
String SHA3_384_RSA_MGF1 =
|
||||
"http://www.w3.org/2007/05/xmldsig-more#sha3-384-rsa-MGF1";
|
||||
|
||||
/**
|
||||
* The <a href="http://www.w3.org/2007/05/xmldsig-more#sha3-512-rsa-MGF1">
|
||||
* SHA3-512-RSA-MGF1</a> (PKCS #1) signature method algorithm URI.
|
||||
*
|
||||
* @since 22
|
||||
*/
|
||||
String SHA3_512_RSA_MGF1 =
|
||||
"http://www.w3.org/2007/05/xmldsig-more#sha3-512-rsa-MGF1";
|
||||
|
||||
|
||||
/**
|
||||
* Returns the algorithm-specific input parameters of this
|
||||
* <code>SignatureMethod</code>.
|
||||
|
||||
@@ -71,6 +71,7 @@ public class DigesterOutputStream extends OutputStream {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int input) {
|
||||
if (buffer) {
|
||||
bos.write(input);
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
package org.jcp.xml.dsig.internal;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
import javax.crypto.Mac;
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,20 +23,22 @@
|
||||
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import java.security.Key;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.Key;
|
||||
import java.security.SignatureException;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
|
||||
import javax.xml.crypto.MarshalException;
|
||||
import javax.xml.crypto.dom.DOMCryptoContext;
|
||||
import javax.xml.crypto.dsig.SignatureMethod;
|
||||
import javax.xml.crypto.dsig.SignedInfo;
|
||||
import javax.xml.crypto.dsig.XMLSignContext;
|
||||
import javax.xml.crypto.dsig.XMLSignature;
|
||||
import javax.xml.crypto.dsig.XMLSignatureException;
|
||||
import javax.xml.crypto.dsig.XMLSignContext;
|
||||
import javax.xml.crypto.dsig.XMLValidateContext;
|
||||
import javax.xml.crypto.dsig.spec.SignatureMethodParameterSpec;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
@@ -28,11 +28,16 @@ package org.jcp.xml.dsig.internal.dom;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.crypto.*;
|
||||
import javax.xml.crypto.Data;
|
||||
import javax.xml.crypto.MarshalException;
|
||||
import javax.xml.crypto.NodeSetData;
|
||||
import javax.xml.crypto.OctetStreamData;
|
||||
import javax.xml.crypto.XMLCryptoContext;
|
||||
import javax.xml.crypto.XMLStructure;
|
||||
import javax.xml.crypto.dom.DOMCryptoContext;
|
||||
import javax.xml.crypto.dsig.TransformException;
|
||||
import javax.xml.crypto.dsig.TransformService;
|
||||
@@ -61,11 +66,13 @@ public abstract class ApacheCanonicalizer extends TransformService {
|
||||
protected Document ownerDoc;
|
||||
protected Element transformElem;
|
||||
|
||||
@Override
|
||||
public final AlgorithmParameterSpec getParameterSpec()
|
||||
{
|
||||
return params;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(XMLStructure parent, XMLCryptoContext context)
|
||||
throws InvalidAlgorithmParameterException
|
||||
{
|
||||
@@ -84,6 +91,7 @@ public abstract class ApacheCanonicalizer extends TransformService {
|
||||
ownerDoc = DOMUtils.getOwnerDocument(transformElem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshalParams(XMLStructure parent, XMLCryptoContext context)
|
||||
throws MarshalException
|
||||
{
|
||||
@@ -182,6 +190,7 @@ public abstract class ApacheCanonicalizer extends TransformService {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Data transform(Data data, XMLCryptoContext xc, OutputStream os)
|
||||
throws TransformException
|
||||
{
|
||||
@@ -249,6 +258,7 @@ public abstract class ApacheCanonicalizer extends TransformService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isFeatureSupported(String feature) {
|
||||
if (feature == null) {
|
||||
throw new NullPointerException();
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import javax.xml.crypto.Data;
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,13 +30,14 @@ import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.crypto.NodeSetData;
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.transforms.TransformationException;
|
||||
import org.w3c.dom.Node;
|
||||
import com.sun.org.apache.xml.internal.security.signature.NodeFilter;
|
||||
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
|
||||
import com.sun.org.apache.xml.internal.security.transforms.TransformationException;
|
||||
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
public class ApacheNodeSetData implements ApacheData, NodeSetData<Node> {
|
||||
|
||||
@@ -46,6 +47,7 @@ public class ApacheNodeSetData implements ApacheData, NodeSetData<Node> {
|
||||
this.xi = xi;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Node> iterator() {
|
||||
// If nodefilters are set, must execute them first to create node-set
|
||||
try {
|
||||
@@ -61,6 +63,7 @@ public class ApacheNodeSetData implements ApacheData, NodeSetData<Node> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public XMLSignatureInput getXMLSignatureInput() {
|
||||
return xi;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,9 @@
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.xml.crypto.OctetStreamData;
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
|
||||
|
||||
public class ApacheOctetStreamData extends OctetStreamData
|
||||
@@ -41,6 +43,7 @@ public class ApacheOctetStreamData extends OctetStreamData
|
||||
this.xi = xi;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XMLSignatureInput getXMLSignatureInput() {
|
||||
return xi;
|
||||
}
|
||||
|
||||
@@ -30,16 +30,25 @@ import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
import javax.xml.crypto.Data;
|
||||
import javax.xml.crypto.MarshalException;
|
||||
import javax.xml.crypto.NodeSetData;
|
||||
import javax.xml.crypto.OctetStreamData;
|
||||
import javax.xml.crypto.XMLCryptoContext;
|
||||
import javax.xml.crypto.XMLStructure;
|
||||
import javax.xml.crypto.dom.DOMCryptoContext;
|
||||
import javax.xml.crypto.dsig.TransformException;
|
||||
import javax.xml.crypto.dsig.TransformService;
|
||||
import javax.xml.crypto.dsig.spec.TransformParameterSpec;
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
|
||||
import com.sun.org.apache.xml.internal.security.transforms.Transform;
|
||||
import com.sun.org.apache.xml.internal.security.transforms.Transforms;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
|
||||
import com.sun.org.apache.xml.internal.security.transforms.Transform;
|
||||
|
||||
import javax.xml.crypto.*;
|
||||
import javax.xml.crypto.dom.DOMCryptoContext;
|
||||
import javax.xml.crypto.dsig.*;
|
||||
import javax.xml.crypto.dsig.spec.TransformParameterSpec;
|
||||
|
||||
/**
|
||||
* This is a wrapper/glue class which invokes the Apache XML-Security
|
||||
@@ -64,6 +73,7 @@ public abstract class ApacheTransform extends TransformService {
|
||||
return params;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(XMLStructure parent, XMLCryptoContext context)
|
||||
throws InvalidAlgorithmParameterException
|
||||
{
|
||||
@@ -82,6 +92,7 @@ public abstract class ApacheTransform extends TransformService {
|
||||
ownerDoc = DOMUtils.getOwnerDocument(transformElem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshalParams(XMLStructure parent, XMLCryptoContext context)
|
||||
throws MarshalException
|
||||
{
|
||||
@@ -100,6 +111,7 @@ public abstract class ApacheTransform extends TransformService {
|
||||
ownerDoc = DOMUtils.getOwnerDocument(transformElem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Data transform(Data data, XMLCryptoContext xc)
|
||||
throws TransformException
|
||||
{
|
||||
@@ -109,6 +121,7 @@ public abstract class ApacheTransform extends TransformService {
|
||||
return transformIt(data, xc, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Data transform(Data data, XMLCryptoContext xc, OutputStream os)
|
||||
throws TransformException
|
||||
{
|
||||
@@ -197,6 +210,7 @@ public abstract class ApacheTransform extends TransformService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isFeatureSupported(String feature) {
|
||||
if (feature == null) {
|
||||
throw new NullPointerException();
|
||||
|
||||
@@ -25,12 +25,13 @@
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import javax.xml.crypto.*;
|
||||
import javax.xml.crypto.dsig.*;
|
||||
import javax.xml.crypto.dsig.spec.TransformParameterSpec;
|
||||
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
|
||||
import javax.xml.crypto.Data;
|
||||
import javax.xml.crypto.XMLCryptoContext;
|
||||
import javax.xml.crypto.dsig.TransformException;
|
||||
import javax.xml.crypto.dsig.spec.TransformParameterSpec;
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.c14n.Canonicalizer;
|
||||
import com.sun.org.apache.xml.internal.security.c14n.InvalidCanonicalizerException;
|
||||
|
||||
@@ -45,6 +46,7 @@ public final class DOMCanonicalXMLC14N11Method extends ApacheCanonicalizer {
|
||||
public static final String C14N_11_WITH_COMMENTS
|
||||
= "http://www.w3.org/2006/12/xml-c14n11#WithComments";
|
||||
|
||||
@Override
|
||||
public void init(TransformParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
if (params != null) {
|
||||
@@ -53,6 +55,7 @@ public final class DOMCanonicalXMLC14N11Method extends ApacheCanonicalizer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Data transform(Data data, XMLCryptoContext xc)
|
||||
throws TransformException {
|
||||
|
||||
|
||||
@@ -25,12 +25,14 @@
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import javax.xml.crypto.*;
|
||||
import javax.xml.crypto.dsig.*;
|
||||
import javax.xml.crypto.dsig.spec.TransformParameterSpec;
|
||||
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
|
||||
import javax.xml.crypto.Data;
|
||||
import javax.xml.crypto.XMLCryptoContext;
|
||||
import javax.xml.crypto.dsig.CanonicalizationMethod;
|
||||
import javax.xml.crypto.dsig.TransformException;
|
||||
import javax.xml.crypto.dsig.spec.TransformParameterSpec;
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.c14n.Canonicalizer;
|
||||
import com.sun.org.apache.xml.internal.security.c14n.InvalidCanonicalizerException;
|
||||
|
||||
@@ -41,6 +43,7 @@ import com.sun.org.apache.xml.internal.security.c14n.InvalidCanonicalizerExcepti
|
||||
*/
|
||||
public final class DOMCanonicalXMLC14NMethod extends ApacheCanonicalizer {
|
||||
|
||||
@Override
|
||||
public void init(TransformParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
if (params != null) {
|
||||
@@ -49,6 +52,7 @@ public final class DOMCanonicalXMLC14NMethod extends ApacheCanonicalizer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Data transform(Data data, XMLCryptoContext xc)
|
||||
throws TransformException {
|
||||
|
||||
|
||||
@@ -33,10 +33,14 @@ import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
import javax.xml.crypto.Data;
|
||||
import javax.xml.crypto.MarshalException;
|
||||
import javax.xml.crypto.XMLCryptoContext;
|
||||
import javax.xml.crypto.dsig.CanonicalizationMethod;
|
||||
import javax.xml.crypto.dsig.TransformException;
|
||||
import javax.xml.crypto.dsig.TransformService;
|
||||
|
||||
import javax.xml.crypto.*;
|
||||
import javax.xml.crypto.dsig.*;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* DOM-based abstract implementation of CanonicalizationMethod.
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import javax.xml.crypto.*;
|
||||
|
||||
import javax.xml.crypto.MarshalException;
|
||||
import javax.xml.crypto.dom.DOMCryptoContext;
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
|
||||
|
||||
@@ -25,13 +25,15 @@
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import javax.xml.crypto.*;
|
||||
import javax.xml.crypto.dom.DOMCryptoContext;
|
||||
import javax.xml.crypto.dsig.*;
|
||||
import javax.xml.crypto.dsig.spec.DigestMethodParameterSpec;
|
||||
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
|
||||
import javax.xml.crypto.MarshalException;
|
||||
import javax.xml.crypto.dom.DOMCryptoContext;
|
||||
import javax.xml.crypto.dsig.DigestMethod;
|
||||
import javax.xml.crypto.dsig.XMLSignature;
|
||||
import javax.xml.crypto.dsig.spec.DigestMethodParameterSpec;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
@@ -147,6 +149,7 @@ public abstract class DOMDigestMethod extends DOMStructure
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final AlgorithmParameterSpec getParameterSpec() {
|
||||
return params;
|
||||
}
|
||||
@@ -251,9 +254,11 @@ public abstract class DOMDigestMethod extends DOMStructure
|
||||
SHA1(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
@Override
|
||||
public String getAlgorithm() {
|
||||
return DigestMethod.SHA1;
|
||||
}
|
||||
@Override
|
||||
String getMessageDigestAlgorithm() {
|
||||
return "SHA-1";
|
||||
}
|
||||
@@ -285,9 +290,11 @@ public abstract class DOMDigestMethod extends DOMStructure
|
||||
SHA256(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
@Override
|
||||
public String getAlgorithm() {
|
||||
return DigestMethod.SHA256;
|
||||
}
|
||||
@Override
|
||||
String getMessageDigestAlgorithm() {
|
||||
return "SHA-256";
|
||||
}
|
||||
@@ -301,9 +308,11 @@ public abstract class DOMDigestMethod extends DOMStructure
|
||||
SHA384(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
@Override
|
||||
public String getAlgorithm() {
|
||||
return SHA384;
|
||||
}
|
||||
@Override
|
||||
String getMessageDigestAlgorithm() {
|
||||
return "SHA-384";
|
||||
}
|
||||
@@ -317,9 +326,11 @@ public abstract class DOMDigestMethod extends DOMStructure
|
||||
SHA512(Element dmElem) throws MarshalException {
|
||||
super(dmElem);
|
||||
}
|
||||
@Override
|
||||
public String getAlgorithm() {
|
||||
return DigestMethod.SHA512;
|
||||
}
|
||||
@Override
|
||||
String getMessageDigestAlgorithm() {
|
||||
return "SHA-512";
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
|
||||
import javax.xml.crypto.dsig.spec.TransformParameterSpec;
|
||||
|
||||
/**
|
||||
@@ -35,6 +36,7 @@ import javax.xml.crypto.dsig.spec.TransformParameterSpec;
|
||||
*/
|
||||
public final class DOMEnvelopedTransform extends ApacheTransform {
|
||||
|
||||
@Override
|
||||
public void init(TransformParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException {
|
||||
if (params != null) {
|
||||
|
||||
@@ -25,19 +25,24 @@
|
||||
*/
|
||||
package org.jcp.xml.dsig.internal.dom;
|
||||
|
||||
import javax.xml.crypto.*;
|
||||
import javax.xml.crypto.dsig.*;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.crypto.Data;
|
||||
import javax.xml.crypto.MarshalException;
|
||||
import javax.xml.crypto.XMLCryptoContext;
|
||||
import javax.xml.crypto.XMLStructure;
|
||||
import javax.xml.crypto.dsig.CanonicalizationMethod;
|
||||
import javax.xml.crypto.dsig.TransformException;
|
||||
import javax.xml.crypto.dsig.spec.C14NMethodParameterSpec;
|
||||
import javax.xml.crypto.dsig.spec.ExcC14NParameterSpec;
|
||||
import javax.xml.crypto.dsig.spec.TransformParameterSpec;
|
||||
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
import java.util.*;
|
||||
|
||||
import org.w3c.dom.Element;
|
||||
import com.sun.org.apache.xml.internal.security.c14n.Canonicalizer;
|
||||
import com.sun.org.apache.xml.internal.security.c14n.InvalidCanonicalizerException;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* DOM-based implementation of CanonicalizationMethod for Exclusive
|
||||
@@ -47,6 +52,7 @@ import com.sun.org.apache.xml.internal.security.c14n.InvalidCanonicalizerExcepti
|
||||
*/
|
||||
public final class DOMExcC14NMethod extends ApacheCanonicalizer {
|
||||
|
||||
@Override
|
||||
public void init(TransformParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException
|
||||
{
|
||||
@@ -59,6 +65,7 @@ public final class DOMExcC14NMethod extends ApacheCanonicalizer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(XMLStructure parent, XMLCryptoContext context)
|
||||
throws InvalidAlgorithmParameterException
|
||||
{
|
||||
@@ -137,6 +144,7 @@ public final class DOMExcC14NMethod extends ApacheCanonicalizer {
|
||||
return CanonicalizationMethod.EXCLUSIVE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Data transform(Data data, XMLCryptoContext xc)
|
||||
throws TransformException
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user