feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
58
jdkSrc/jdk8/javax/xml/crypto/AlgorithmMethod.java
Normal file
58
jdkSrc/jdk8/javax/xml/crypto/AlgorithmMethod.java
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: AlgorithmMethod.java,v 1.4 2005/05/10 15:47:41 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto;
|
||||
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
|
||||
/**
|
||||
* An abstract representation of an algorithm defined in the XML Security
|
||||
* specifications. Subclasses represent specific types of XML security
|
||||
* algorithms, such as a {@link javax.xml.crypto.dsig.Transform}.
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface AlgorithmMethod {
|
||||
|
||||
/**
|
||||
* Returns the algorithm URI of this <code>AlgorithmMethod</code>.
|
||||
*
|
||||
* @return the algorithm URI of this <code>AlgorithmMethod</code>
|
||||
*/
|
||||
String getAlgorithm();
|
||||
|
||||
/**
|
||||
* Returns the algorithm parameters of this <code>AlgorithmMethod</code>.
|
||||
*
|
||||
* @return the algorithm parameters of this <code>AlgorithmMethod</code>.
|
||||
* Returns <code>null</code> if this <code>AlgorithmMethod</code> does
|
||||
* not require parameters and they are not specified.
|
||||
*/
|
||||
AlgorithmParameterSpec getParameterSpec();
|
||||
}
|
||||
42
jdkSrc/jdk8/javax/xml/crypto/Data.java
Normal file
42
jdkSrc/jdk8/javax/xml/crypto/Data.java
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: Data.java,v 1.4 2005/05/10 15:47:41 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto;
|
||||
|
||||
import javax.xml.crypto.dsig.Transform;
|
||||
|
||||
/**
|
||||
* An abstract representation of the result of dereferencing a
|
||||
* {@link URIReference} or the input/output of subsequent {@link Transform}s.
|
||||
* The primary purpose of this interface is to group and provide type safety
|
||||
* for all <code>Data</code> subtypes.
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface Data { }
|
||||
152
jdkSrc/jdk8/javax/xml/crypto/KeySelector.java
Normal file
152
jdkSrc/jdk8/javax/xml/crypto/KeySelector.java
Normal file
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: KeySelector.java,v 1.6 2005/05/10 15:47:42 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto;
|
||||
|
||||
import java.security.Key;
|
||||
import javax.xml.crypto.dsig.keyinfo.KeyInfo;
|
||||
import javax.xml.crypto.dsig.keyinfo.RetrievalMethod;
|
||||
|
||||
/**
|
||||
* A selector that finds and returns a key using the data contained in a
|
||||
* {@link KeyInfo} object. An example of an implementation of
|
||||
* this class is one that searches a {@link java.security.KeyStore} for
|
||||
* trusted keys that match information contained in a <code>KeyInfo</code>.
|
||||
*
|
||||
* <p>Whether or not the returned key is trusted and the mechanisms
|
||||
* used to determine that is implementation-specific.
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
*/
|
||||
public abstract class KeySelector {
|
||||
|
||||
/**
|
||||
* The purpose of the key that is to be selected.
|
||||
*/
|
||||
public static class Purpose {
|
||||
|
||||
private final String name;
|
||||
|
||||
private Purpose(String name) { this.name = name; }
|
||||
|
||||
/**
|
||||
* Returns a string representation of this purpose ("sign",
|
||||
* "verify", "encrypt", or "decrypt").
|
||||
*
|
||||
* @return a string representation of this purpose
|
||||
*/
|
||||
public String toString() { return name; }
|
||||
|
||||
/**
|
||||
* A key for signing.
|
||||
*/
|
||||
public static final Purpose SIGN = new Purpose("sign");
|
||||
/**
|
||||
* A key for verifying.
|
||||
*/
|
||||
public static final Purpose VERIFY = new Purpose("verify");
|
||||
/**
|
||||
* A key for encrypting.
|
||||
*/
|
||||
public static final Purpose ENCRYPT = new Purpose("encrypt");
|
||||
/**
|
||||
* A key for decrypting.
|
||||
*/
|
||||
public static final Purpose DECRYPT = new Purpose("decrypt");
|
||||
}
|
||||
|
||||
/**
|
||||
* Default no-args constructor; intended for invocation by subclasses only.
|
||||
*/
|
||||
protected KeySelector() {}
|
||||
|
||||
/**
|
||||
* Attempts to find a key that satisfies the specified constraints.
|
||||
*
|
||||
* @param keyInfo a <code>KeyInfo</code> (may be <code>null</code>)
|
||||
* @param purpose the key's purpose ({@link Purpose#SIGN},
|
||||
* {@link Purpose#VERIFY}, {@link Purpose#ENCRYPT}, or
|
||||
* {@link Purpose#DECRYPT})
|
||||
* @param method the algorithm method that this key is to be used for.
|
||||
* Only keys that are compatible with the algorithm and meet the
|
||||
* constraints of the specified algorithm should be returned.
|
||||
* @param context an <code>XMLCryptoContext</code> that may contain
|
||||
* useful information for finding an appropriate key. If this key
|
||||
* selector supports resolving {@link RetrievalMethod} types, the
|
||||
* context's <code>baseURI</code> and <code>dereferencer</code>
|
||||
* parameters (if specified) should be used by the selector to
|
||||
* resolve and dereference the URI.
|
||||
* @return the result of the key selector
|
||||
* @throws KeySelectorException if an exceptional condition occurs while
|
||||
* attempting to find a key. Note that an inability to find a key is not
|
||||
* considered an exception (<code>null</code> should be
|
||||
* returned in that case). However, an error condition (ex: network
|
||||
* communications failure) that prevented the <code>KeySelector</code>
|
||||
* from finding a potential key should be considered an exception.
|
||||
* @throws ClassCastException if the data type of <code>method</code>
|
||||
* is not supported by this key selector
|
||||
*/
|
||||
public abstract KeySelectorResult select(KeyInfo keyInfo, Purpose purpose,
|
||||
AlgorithmMethod method, XMLCryptoContext context)
|
||||
throws KeySelectorException;
|
||||
|
||||
/**
|
||||
* Returns a <code>KeySelector</code> that always selects the specified
|
||||
* key, regardless of the <code>KeyInfo</code> passed to it.
|
||||
*
|
||||
* @param key the sole key to be stored in the key selector
|
||||
* @return a key selector that always selects the specified key
|
||||
* @throws NullPointerException if <code>key</code> is <code>null</code>
|
||||
*/
|
||||
public static KeySelector singletonKeySelector(Key key) {
|
||||
return new SingletonKeySelector(key);
|
||||
}
|
||||
|
||||
private static class SingletonKeySelector extends KeySelector {
|
||||
private final Key key;
|
||||
|
||||
SingletonKeySelector(Key key) {
|
||||
if (key == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public KeySelectorResult select(KeyInfo keyInfo, Purpose purpose,
|
||||
AlgorithmMethod method, XMLCryptoContext context)
|
||||
throws KeySelectorException {
|
||||
|
||||
return new KeySelectorResult() {
|
||||
public Key getKey() {
|
||||
return key;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
148
jdkSrc/jdk8/javax/xml/crypto/KeySelectorException.java
Normal file
148
jdkSrc/jdk8/javax/xml/crypto/KeySelectorException.java
Normal file
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: KeySelectorException.java,v 1.3 2005/05/10 15:47:42 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
/**
|
||||
* Indicates an exceptional condition thrown by a {@link KeySelector}.
|
||||
*
|
||||
* <p>A {@code KeySelectorException} can contain a cause: another
|
||||
* throwable that caused this {@code KeySelectorException} to get thrown.
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
*/
|
||||
public class KeySelectorException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -7480033639322531109L;
|
||||
|
||||
/**
|
||||
* The throwable that caused this exception to get thrown, or
|
||||
* {@code null} if this exception was not caused by another throwable
|
||||
* or if the causative throwable is unknown.
|
||||
*
|
||||
* @serial
|
||||
*/
|
||||
private Throwable cause;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code KeySelectorException} with
|
||||
* {@code null} as its detail message.
|
||||
*/
|
||||
public KeySelectorException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@code KeySelectorException} with the specified
|
||||
* detail message.
|
||||
*
|
||||
* @param message the detail message
|
||||
*/
|
||||
public KeySelectorException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@code KeySelectorException} with the
|
||||
* specified detail message and cause.
|
||||
* <p>Note that the detail message associated with
|
||||
* {@code cause} is <i>not</i> automatically incorporated in
|
||||
* this exception's detail message.
|
||||
*
|
||||
* @param message the detail message
|
||||
* @param cause the cause (A {@code null} value is permitted, and
|
||||
* indicates that the cause is nonexistent or unknown.)
|
||||
*/
|
||||
public KeySelectorException(String message, Throwable cause) {
|
||||
super(message);
|
||||
this.cause = cause;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@code KeySelectorException} with the specified
|
||||
* cause and a detail message of
|
||||
* {@code (cause==null ? null : cause.toString())}
|
||||
* (which typically contains the class and detail message of
|
||||
* {@code cause}).
|
||||
*
|
||||
* @param cause the cause (A {@code null} value is permitted, and
|
||||
* indicates that the cause is nonexistent or unknown.)
|
||||
*/
|
||||
public KeySelectorException(Throwable cause) {
|
||||
super(cause==null ? null : cause.toString());
|
||||
this.cause = cause;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the cause of this {@code KeySelectorException} or
|
||||
* {@code null} if the cause is nonexistent or unknown. (The
|
||||
* cause is the throwable that caused this
|
||||
* {@code KeySelectorException} to get thrown.)
|
||||
*
|
||||
* @return the cause of this {@code KeySelectorException} or
|
||||
* {@code null} if the cause is nonexistent or unknown.
|
||||
*/
|
||||
public Throwable getCause() {
|
||||
return cause;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints this {@code KeySelectorException}, its backtrace and
|
||||
* the cause's backtrace to the standard error stream.
|
||||
*/
|
||||
public void printStackTrace() {
|
||||
super.printStackTrace();
|
||||
//XXX print backtrace of cause
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints this {@code KeySelectorException}, its backtrace and
|
||||
* the cause's backtrace to the specified print stream.
|
||||
*
|
||||
* @param s {@code PrintStream} to use for output
|
||||
*/
|
||||
public void printStackTrace(PrintStream s) {
|
||||
super.printStackTrace(s);
|
||||
//XXX print backtrace of cause
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints this {@code KeySelectorException}, its backtrace and
|
||||
* the cause's backtrace to the specified print writer.
|
||||
*
|
||||
* @param s {@code PrintWriter} to use for output
|
||||
*/
|
||||
public void printStackTrace(PrintWriter s) {
|
||||
super.printStackTrace(s);
|
||||
//XXX print backtrace of cause
|
||||
}
|
||||
}
|
||||
54
jdkSrc/jdk8/javax/xml/crypto/KeySelectorResult.java
Normal file
54
jdkSrc/jdk8/javax/xml/crypto/KeySelectorResult.java
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: KeySelectorResult.java,v 1.3 2005/05/10 15:47:42 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto;
|
||||
|
||||
import java.security.Key;
|
||||
|
||||
/**
|
||||
* The result returned by the {@link KeySelector#select KeySelector.select}
|
||||
* method.
|
||||
* <p>
|
||||
* At a minimum, a <code>KeySelectorResult</code> contains the <code>Key</code>
|
||||
* selected by the <code>KeySelector</code>. Implementations of this interface
|
||||
* may add methods to return implementation or algorithm specific information,
|
||||
* such as a chain of certificates or debugging information.
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
* @see KeySelector
|
||||
*/
|
||||
public interface KeySelectorResult {
|
||||
|
||||
/**
|
||||
* Returns the selected key.
|
||||
*
|
||||
* @return the selected key, or <code>null</code> if none can be found
|
||||
*/
|
||||
Key getKey();
|
||||
}
|
||||
155
jdkSrc/jdk8/javax/xml/crypto/MarshalException.java
Normal file
155
jdkSrc/jdk8/javax/xml/crypto/MarshalException.java
Normal file
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: MarshalException.java,v 1.5 2005/05/10 15:47:42 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
import javax.xml.crypto.dsig.Manifest;
|
||||
import javax.xml.crypto.dsig.XMLSignature;
|
||||
import javax.xml.crypto.dsig.XMLSignatureFactory;
|
||||
import javax.xml.crypto.dsig.keyinfo.KeyInfo;
|
||||
import javax.xml.crypto.dsig.keyinfo.KeyInfoFactory;
|
||||
|
||||
/**
|
||||
* Indicates an exceptional condition that occurred during the XML
|
||||
* marshalling or unmarshalling process.
|
||||
*
|
||||
* <p>A {@code MarshalException} can contain a cause: another
|
||||
* throwable that caused this {@code MarshalException} to get thrown.
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
* @see XMLSignature#sign(XMLSignContext)
|
||||
* @see XMLSignatureFactory#unmarshalXMLSignature(XMLValidateContext)
|
||||
*/
|
||||
public class MarshalException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -863185580332643547L;
|
||||
|
||||
/**
|
||||
* The throwable that caused this exception to get thrown, or null if this
|
||||
* exception was not caused by another throwable or if the causative
|
||||
* throwable is unknown.
|
||||
*
|
||||
* @serial
|
||||
*/
|
||||
private Throwable cause;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code MarshalException} with
|
||||
* {@code null} as its detail message.
|
||||
*/
|
||||
public MarshalException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@code MarshalException} with the specified
|
||||
* detail message.
|
||||
*
|
||||
* @param message the detail message
|
||||
*/
|
||||
public MarshalException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@code MarshalException} with the
|
||||
* specified detail message and cause.
|
||||
* <p>Note that the detail message associated with
|
||||
* {@code cause} is <i>not</i> automatically incorporated in
|
||||
* this exception's detail message.
|
||||
*
|
||||
* @param message the detail message
|
||||
* @param cause the cause (A {@code null} value is permitted, and
|
||||
* indicates that the cause is nonexistent or unknown.)
|
||||
*/
|
||||
public MarshalException(String message, Throwable cause) {
|
||||
super(message);
|
||||
this.cause = cause;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@code MarshalException} with the specified cause
|
||||
* and a detail message of {@code (cause==null ? null : cause.toString())
|
||||
* } (which typically contains the class and detail message of
|
||||
* {@code cause}).
|
||||
*
|
||||
* @param cause the cause (A {@code null} value is permitted, and
|
||||
* indicates that the cause is nonexistent or unknown.)
|
||||
*/
|
||||
public MarshalException(Throwable cause) {
|
||||
super(cause==null ? null : cause.toString());
|
||||
this.cause = cause;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the cause of this {@code MarshalException} or
|
||||
* {@code null} if the cause is nonexistent or unknown. (The
|
||||
* cause is the throwable that caused this
|
||||
* {@code MarshalException} to get thrown.)
|
||||
*
|
||||
* @return the cause of this {@code MarshalException} or
|
||||
* {@code null} if the cause is nonexistent or unknown.
|
||||
*/
|
||||
public Throwable getCause() {
|
||||
return cause;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints this {@code MarshalException}, its backtrace and
|
||||
* the cause's backtrace to the standard error stream.
|
||||
*/
|
||||
public void printStackTrace() {
|
||||
super.printStackTrace();
|
||||
//XXX print backtrace of cause
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints this {@code MarshalException}, its backtrace and
|
||||
* the cause's backtrace to the specified print stream.
|
||||
*
|
||||
* @param s {@code PrintStream} to use for output
|
||||
*/
|
||||
public void printStackTrace(PrintStream s) {
|
||||
super.printStackTrace(s);
|
||||
//XXX print backtrace of cause
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints this {@code MarshalException}, its backtrace and
|
||||
* the cause's backtrace to the specified print writer.
|
||||
*
|
||||
* @param s {@code PrintWriter} to use for output
|
||||
*/
|
||||
public void printStackTrace(PrintWriter s) {
|
||||
super.printStackTrace(s);
|
||||
//XXX print backtrace of cause
|
||||
}
|
||||
}
|
||||
156
jdkSrc/jdk8/javax/xml/crypto/NoSuchMechanismException.java
Normal file
156
jdkSrc/jdk8/javax/xml/crypto/NoSuchMechanismException.java
Normal file
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: NoSuchMechanismException.java,v 1.4 2005/05/10 15:47:42 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
import javax.xml.crypto.dsig.Manifest;
|
||||
import javax.xml.crypto.dsig.XMLSignature;
|
||||
import javax.xml.crypto.dsig.XMLSignatureFactory;
|
||||
import javax.xml.crypto.dsig.keyinfo.KeyInfo;
|
||||
import javax.xml.crypto.dsig.keyinfo.KeyInfoFactory;
|
||||
|
||||
/**
|
||||
* This exception is thrown when a particular XML mechanism is requested but
|
||||
* is not available in the environment.
|
||||
*
|
||||
* <p>A {@code NoSuchMechanismException} can contain a cause: another
|
||||
* throwable that caused this {@code NoSuchMechanismException} to get
|
||||
* thrown.
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
* @see XMLSignatureFactory#getInstance XMLSignatureFactory.getInstance
|
||||
* @see KeyInfoFactory#getInstance KeyInfoFactory.getInstance
|
||||
*/
|
||||
public class NoSuchMechanismException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 4189669069570660166L;
|
||||
|
||||
/**
|
||||
* The throwable that caused this exception to get thrown, or null if this
|
||||
* exception was not caused by another throwable or if the causative
|
||||
* throwable is unknown.
|
||||
*
|
||||
* @serial
|
||||
*/
|
||||
private Throwable cause;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code NoSuchMechanismException} with
|
||||
* {@code null} as its detail message.
|
||||
*/
|
||||
public NoSuchMechanismException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@code NoSuchMechanismException} with the
|
||||
* specified detail message.
|
||||
*
|
||||
* @param message the detail message
|
||||
*/
|
||||
public NoSuchMechanismException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@code NoSuchMechanismException} with the
|
||||
* specified detail message and cause.
|
||||
* <p>Note that the detail message associated with
|
||||
* {@code cause} is <i>not</i> automatically incorporated in
|
||||
* this exception's detail message.
|
||||
*
|
||||
* @param message the detail message
|
||||
* @param cause the cause (A {@code null} value is permitted, and
|
||||
* indicates that the cause is nonexistent or unknown.)
|
||||
*/
|
||||
public NoSuchMechanismException(String message, Throwable cause) {
|
||||
super(message);
|
||||
this.cause = cause;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@code NoSuchMechanismException} with the
|
||||
* specified cause and a detail message of
|
||||
* {@code (cause==null ? null : cause.toString())} (which typically
|
||||
* contains the class and detail message of {@code cause}).
|
||||
*
|
||||
* @param cause the cause (A {@code null} value is permitted, and
|
||||
* indicates that the cause is nonexistent or unknown.)
|
||||
*/
|
||||
public NoSuchMechanismException(Throwable cause) {
|
||||
super(cause==null ? null : cause.toString());
|
||||
this.cause = cause;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the cause of this {@code NoSuchMechanismException} or
|
||||
* {@code null} if the cause is nonexistent or unknown. (The
|
||||
* cause is the throwable that caused this
|
||||
* {@code NoSuchMechanismException} to get thrown.)
|
||||
*
|
||||
* @return the cause of this {@code NoSuchMechanismException} or
|
||||
* {@code null} if the cause is nonexistent or unknown.
|
||||
*/
|
||||
public Throwable getCause() {
|
||||
return cause;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints this {@code NoSuchMechanismException}, its backtrace and
|
||||
* the cause's backtrace to the standard error stream.
|
||||
*/
|
||||
public void printStackTrace() {
|
||||
super.printStackTrace();
|
||||
//XXX print backtrace of cause
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints this {@code NoSuchMechanismException}, its backtrace and
|
||||
* the cause's backtrace to the specified print stream.
|
||||
*
|
||||
* @param s {@code PrintStream} to use for output
|
||||
*/
|
||||
public void printStackTrace(PrintStream s) {
|
||||
super.printStackTrace(s);
|
||||
//XXX print backtrace of cause
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints this {@code NoSuchMechanismException}, its backtrace and
|
||||
* the cause's backtrace to the specified print writer.
|
||||
*
|
||||
* @param s {@code PrintWriter} to use for output
|
||||
*/
|
||||
public void printStackTrace(PrintWriter s) {
|
||||
super.printStackTrace(s);
|
||||
//XXX print backtrace of cause
|
||||
}
|
||||
}
|
||||
57
jdkSrc/jdk8/javax/xml/crypto/NodeSetData.java
Normal file
57
jdkSrc/jdk8/javax/xml/crypto/NodeSetData.java
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: NodeSetData.java,v 1.5 2005/05/10 15:47:42 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* An abstract representation of a <code>Data</code> type containing a
|
||||
* node-set. The type (class) and ordering of the nodes contained in the set
|
||||
* are not defined by this class; instead that behavior should be
|
||||
* defined by <code>NodeSetData</code> subclasses.
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface NodeSetData extends Data {
|
||||
|
||||
/**
|
||||
* Returns a read-only iterator over the nodes contained in this
|
||||
* <code>NodeSetData</code> in
|
||||
* <a href="http://www.w3.org/TR/1999/REC-xpath-19991116#dt-document-order">
|
||||
* document order</a>. Attempts to modify the returned iterator
|
||||
* via the <code>remove</code> method throw
|
||||
* <code>UnsupportedOperationException</code>.
|
||||
*
|
||||
* @return an <code>Iterator</code> over the nodes in this
|
||||
* <code>NodeSetData</code> in document order
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
Iterator iterator();
|
||||
}
|
||||
106
jdkSrc/jdk8/javax/xml/crypto/OctetStreamData.java
Normal file
106
jdkSrc/jdk8/javax/xml/crypto/OctetStreamData.java
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: OctetStreamData.java,v 1.3 2005/05/10 15:47:42 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* A representation of a <code>Data</code> type containing an octet stream.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public class OctetStreamData implements Data {
|
||||
|
||||
private InputStream octetStream;
|
||||
private String uri;
|
||||
private String mimeType;
|
||||
|
||||
/**
|
||||
* Creates a new <code>OctetStreamData</code>.
|
||||
*
|
||||
* @param octetStream the input stream containing the octets
|
||||
* @throws NullPointerException if <code>octetStream</code> is
|
||||
* <code>null</code>
|
||||
*/
|
||||
public OctetStreamData(InputStream octetStream) {
|
||||
if (octetStream == null) {
|
||||
throw new NullPointerException("octetStream is null");
|
||||
}
|
||||
this.octetStream = octetStream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new <code>OctetStreamData</code>.
|
||||
*
|
||||
* @param octetStream the input stream containing the octets
|
||||
* @param uri the URI String identifying the data object (may be
|
||||
* <code>null</code>)
|
||||
* @param mimeType the MIME type associated with the data object (may be
|
||||
* <code>null</code>)
|
||||
* @throws NullPointerException if <code>octetStream</code> is
|
||||
* <code>null</code>
|
||||
*/
|
||||
public OctetStreamData(InputStream octetStream, String uri,
|
||||
String mimeType) {
|
||||
if (octetStream == null) {
|
||||
throw new NullPointerException("octetStream is null");
|
||||
}
|
||||
this.octetStream = octetStream;
|
||||
this.uri = uri;
|
||||
this.mimeType = mimeType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the input stream of this <code>OctetStreamData</code>.
|
||||
*
|
||||
* @return the input stream of this <code>OctetStreamData</code>.
|
||||
*/
|
||||
public InputStream getOctetStream() {
|
||||
return octetStream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the URI String identifying the data object represented by this
|
||||
* <code>OctetStreamData</code>.
|
||||
*
|
||||
* @return the URI String or <code>null</code> if not applicable
|
||||
*/
|
||||
public String getURI() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the MIME type associated with the data object represented by this
|
||||
* <code>OctetStreamData</code>.
|
||||
*
|
||||
* @return the MIME type or <code>null</code> if not applicable
|
||||
*/
|
||||
public String getMimeType() {
|
||||
return mimeType;
|
||||
}
|
||||
}
|
||||
75
jdkSrc/jdk8/javax/xml/crypto/URIDereferencer.java
Normal file
75
jdkSrc/jdk8/javax/xml/crypto/URIDereferencer.java
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* ===========================================================================
|
||||
*
|
||||
* (C) Copyright IBM Corp. 2003 All Rights Reserved.
|
||||
*
|
||||
* ===========================================================================
|
||||
*/
|
||||
/*
|
||||
* $Id: URIDereferencer.java,v 1.5 2005/05/10 15:47:42 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto;
|
||||
|
||||
/**
|
||||
* A dereferencer of {@link URIReference}s.
|
||||
* <p>
|
||||
* The result of dereferencing a <code>URIReference</code> is either an
|
||||
* instance of {@link OctetStreamData} or {@link NodeSetData}. Unless the
|
||||
* <code>URIReference</code> is a <i>same-document reference</i> as defined
|
||||
* in section 4.2 of the W3C Recommendation for XML-Signature Syntax and
|
||||
* Processing, the result of dereferencing the <code>URIReference</code>
|
||||
* MUST be an <code>OctetStreamData</code>.
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author Joyce Leung
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
* @see XMLCryptoContext#setURIDereferencer(URIDereferencer)
|
||||
* @see XMLCryptoContext#getURIDereferencer
|
||||
*/
|
||||
public interface URIDereferencer {
|
||||
|
||||
/**
|
||||
* Dereferences the specified <code>URIReference</code> and returns the
|
||||
* dereferenced data.
|
||||
*
|
||||
* @param uriReference the <code>URIReference</code>
|
||||
* @param context an <code>XMLCryptoContext</code> that may
|
||||
* contain additional useful information for dereferencing the URI. This
|
||||
* implementation should dereference the specified
|
||||
* <code>URIReference</code> against the context's <code>baseURI</code>
|
||||
* parameter, if specified.
|
||||
* @return the dereferenced data
|
||||
* @throws NullPointerException if <code>uriReference</code> or
|
||||
* <code>context</code> are <code>null</code>
|
||||
* @throws URIReferenceException if an exception occurs while
|
||||
* dereferencing the specified <code>uriReference</code>
|
||||
*/
|
||||
Data dereference(URIReference uriReference, XMLCryptoContext context)
|
||||
throws URIReferenceException;
|
||||
}
|
||||
60
jdkSrc/jdk8/javax/xml/crypto/URIReference.java
Normal file
60
jdkSrc/jdk8/javax/xml/crypto/URIReference.java
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: URIReference.java,v 1.4 2005/05/10 15:47:42 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto;
|
||||
|
||||
/**
|
||||
* Identifies a data object via a URI-Reference, as specified by
|
||||
* <a href="http://www.ietf.org/rfc/rfc2396.txt">RFC 2396</a>.
|
||||
*
|
||||
* <p>Note that some subclasses may not have a <code>type</code> attribute
|
||||
* and for objects of those types, the {@link #getType} method always returns
|
||||
* <code>null</code>.
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
* @see URIDereferencer
|
||||
*/
|
||||
public interface URIReference {
|
||||
|
||||
/**
|
||||
* Returns the URI of the referenced data object.
|
||||
*
|
||||
* @return the URI of the data object in RFC 2396 format (may be
|
||||
* <code>null</code> if not specified)
|
||||
*/
|
||||
String getURI();
|
||||
|
||||
/**
|
||||
* Returns the type of data referenced by this URI.
|
||||
*
|
||||
* @return the type (a URI) of the data object (may be <code>null</code>
|
||||
* if not specified)
|
||||
*/
|
||||
String getType();
|
||||
}
|
||||
188
jdkSrc/jdk8/javax/xml/crypto/URIReferenceException.java
Normal file
188
jdkSrc/jdk8/javax/xml/crypto/URIReferenceException.java
Normal file
@@ -0,0 +1,188 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: URIReferenceException.java,v 1.4 2005/05/10 15:47:42 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
import javax.xml.crypto.dsig.keyinfo.RetrievalMethod;
|
||||
|
||||
/**
|
||||
* Indicates an exceptional condition thrown while dereferencing a
|
||||
* {@link URIReference}.
|
||||
*
|
||||
* <p>A {@code URIReferenceException} can contain a cause: another
|
||||
* throwable that caused this {@code URIReferenceException} to get thrown.
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
* @see URIDereferencer#dereference(URIReference, XMLCryptoContext)
|
||||
* @see RetrievalMethod#dereference(XMLCryptoContext)
|
||||
*/
|
||||
public class URIReferenceException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 7173469703932561419L;
|
||||
|
||||
/**
|
||||
* The throwable that caused this exception to get thrown, or null if this
|
||||
* exception was not caused by another throwable or if the causative
|
||||
* throwable is unknown.
|
||||
*
|
||||
* @serial
|
||||
*/
|
||||
private Throwable cause;
|
||||
|
||||
private URIReference uriReference;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code URIReferenceException} with
|
||||
* {@code null} as its detail message.
|
||||
*/
|
||||
public URIReferenceException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@code URIReferenceException} with the specified
|
||||
* detail message.
|
||||
*
|
||||
* @param message the detail message
|
||||
*/
|
||||
public URIReferenceException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@code URIReferenceException} with the
|
||||
* specified detail message and cause.
|
||||
* <p>Note that the detail message associated with
|
||||
* {@code cause} is <i>not</i> automatically incorporated in
|
||||
* this exception's detail message.
|
||||
*
|
||||
* @param message the detail message
|
||||
* @param cause the cause (A {@code null} value is permitted, and
|
||||
* indicates that the cause is nonexistent or unknown.)
|
||||
*/
|
||||
public URIReferenceException(String message, Throwable cause) {
|
||||
super(message);
|
||||
this.cause = cause;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@code URIReferenceException} with the
|
||||
* specified detail message, cause and {@code URIReference}.
|
||||
* <p>Note that the detail message associated with
|
||||
* {@code cause} is <i>not</i> automatically incorporated in
|
||||
* this exception's detail message.
|
||||
*
|
||||
* @param message the detail message
|
||||
* @param cause the cause (A {@code null} value is permitted, and
|
||||
* indicates that the cause is nonexistent or unknown.)
|
||||
* @param uriReference the {@code URIReference} that was being
|
||||
* dereferenced when the error was encountered
|
||||
* @throws NullPointerException if {@code uriReference} is
|
||||
* {@code null}
|
||||
*/
|
||||
public URIReferenceException(String message, Throwable cause,
|
||||
URIReference uriReference) {
|
||||
this(message, cause);
|
||||
if (uriReference == null) {
|
||||
throw new NullPointerException("uriReference cannot be null");
|
||||
}
|
||||
this.uriReference = uriReference;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@code URIReferenceException} with the specified
|
||||
* cause and a detail message of {@code (cause==null ? null :
|
||||
* cause.toString())} (which typically contains the class and detail
|
||||
* message of {@code cause}).
|
||||
*
|
||||
* @param cause the cause (A {@code null} value is permitted, and
|
||||
* indicates that the cause is nonexistent or unknown.)
|
||||
*/
|
||||
public URIReferenceException(Throwable cause) {
|
||||
super(cause==null ? null : cause.toString());
|
||||
this.cause = cause;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@code URIReference} that was being dereferenced
|
||||
* when the exception was thrown.
|
||||
*
|
||||
* @return the {@code URIReference} that was being dereferenced
|
||||
* when the exception was thrown, or {@code null} if not specified
|
||||
*/
|
||||
public URIReference getURIReference() {
|
||||
return uriReference;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the cause of this {@code URIReferenceException} or
|
||||
* {@code null} if the cause is nonexistent or unknown. (The
|
||||
* cause is the throwable that caused this
|
||||
* {@code URIReferenceException} to get thrown.)
|
||||
*
|
||||
* @return the cause of this {@code URIReferenceException} or
|
||||
* {@code null} if the cause is nonexistent or unknown.
|
||||
*/
|
||||
public Throwable getCause() {
|
||||
return cause;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints this {@code URIReferenceException}, its backtrace and
|
||||
* the cause's backtrace to the standard error stream.
|
||||
*/
|
||||
public void printStackTrace() {
|
||||
super.printStackTrace();
|
||||
//XXX print backtrace of cause
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints this {@code URIReferenceException}, its backtrace and
|
||||
* the cause's backtrace to the specified print stream.
|
||||
*
|
||||
* @param s {@code PrintStream} to use for output
|
||||
*/
|
||||
public void printStackTrace(PrintStream s) {
|
||||
super.printStackTrace(s);
|
||||
//XXX print backtrace of cause
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints this {@code URIReferenceException}, its backtrace and
|
||||
* the cause's backtrace to the specified print writer.
|
||||
*
|
||||
* @param s {@code PrintWriter} to use for output
|
||||
*/
|
||||
public void printStackTrace(PrintWriter s) {
|
||||
super.printStackTrace(s);
|
||||
//XXX print backtrace of cause
|
||||
}
|
||||
}
|
||||
226
jdkSrc/jdk8/javax/xml/crypto/XMLCryptoContext.java
Normal file
226
jdkSrc/jdk8/javax/xml/crypto/XMLCryptoContext.java
Normal file
@@ -0,0 +1,226 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: XMLCryptoContext.java,v 1.6 2005/05/10 15:47:42 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto;
|
||||
|
||||
/**
|
||||
* Contains common context information for XML cryptographic operations.
|
||||
*
|
||||
* <p>This interface contains methods for setting and retrieving properties
|
||||
* that affect the processing of XML signatures or XML encrypted structures.
|
||||
*
|
||||
* <p>Note that <code>XMLCryptoContext</code> instances can contain information
|
||||
* and state specific to the XML cryptographic structure it is used with.
|
||||
* The results are unpredictable if an <code>XMLCryptoContext</code> is
|
||||
* used with multiple structures (for example, you should not use the same
|
||||
* {@link javax.xml.crypto.dsig.XMLValidateContext} instance to validate two
|
||||
* different {@link javax.xml.crypto.dsig.XMLSignature} objects).
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface XMLCryptoContext {
|
||||
|
||||
/**
|
||||
* Returns the base URI.
|
||||
*
|
||||
* @return the base URI, or <code>null</code> if not specified
|
||||
* @see #setBaseURI(String)
|
||||
*/
|
||||
String getBaseURI();
|
||||
|
||||
/**
|
||||
* Sets the base URI.
|
||||
*
|
||||
* @param baseURI the base URI, or <code>null</code> to remove current
|
||||
* value
|
||||
* @throws IllegalArgumentException if <code>baseURI</code> is not RFC
|
||||
* 2396 compliant
|
||||
* @see #getBaseURI
|
||||
*/
|
||||
void setBaseURI(String baseURI);
|
||||
|
||||
/**
|
||||
* Returns the key selector for finding a key.
|
||||
*
|
||||
* @return the key selector, or <code>null</code> if not specified
|
||||
* @see #setKeySelector(KeySelector)
|
||||
*/
|
||||
KeySelector getKeySelector();
|
||||
|
||||
/**
|
||||
* Sets the key selector for finding a key.
|
||||
*
|
||||
* @param ks the key selector, or <code>null</code> to remove the current
|
||||
* setting
|
||||
* @see #getKeySelector
|
||||
*/
|
||||
void setKeySelector(KeySelector ks);
|
||||
|
||||
/**
|
||||
* Returns a <code>URIDereferencer</code> that is used to dereference
|
||||
* {@link URIReference}s.
|
||||
*
|
||||
* @return the <code>URIDereferencer</code>, or <code>null</code> if not
|
||||
* specified
|
||||
* @see #setURIDereferencer(URIDereferencer)
|
||||
*/
|
||||
URIDereferencer getURIDereferencer();
|
||||
|
||||
/**
|
||||
* Sets a <code>URIDereferencer</code> that is used to dereference
|
||||
* {@link URIReference}s. The specified <code>URIDereferencer</code>
|
||||
* is used in place of an implementation's default
|
||||
* <code>URIDereferencer</code>.
|
||||
*
|
||||
* @param dereferencer the <code>URIDereferencer</code>, or
|
||||
* <code>null</code> to remove any current setting
|
||||
* @see #getURIDereferencer
|
||||
*/
|
||||
void setURIDereferencer(URIDereferencer dereferencer);
|
||||
|
||||
/**
|
||||
* Returns the namespace prefix that the specified namespace URI is
|
||||
* associated with. Returns the specified default prefix if the specified
|
||||
* namespace URI has not been bound to a prefix. To bind a namespace URI
|
||||
* to a prefix, call the {@link #putNamespacePrefix putNamespacePrefix}
|
||||
* method.
|
||||
*
|
||||
* @param namespaceURI a namespace URI
|
||||
* @param defaultPrefix the prefix to be returned in the event that the
|
||||
* the specified namespace URI has not been bound to a prefix.
|
||||
* @return the prefix that is associated with the specified namespace URI,
|
||||
* or <code>defaultPrefix</code> if the URI is not registered. If
|
||||
* the namespace URI is registered but has no prefix, an empty string
|
||||
* (<code>""</code>) is returned.
|
||||
* @throws NullPointerException if <code>namespaceURI</code> is
|
||||
* <code>null</code>
|
||||
* @see #putNamespacePrefix(String, String)
|
||||
*/
|
||||
String getNamespacePrefix(String namespaceURI, String defaultPrefix);
|
||||
|
||||
/**
|
||||
* Maps the specified namespace URI to the specified prefix. If there is
|
||||
* already a prefix associated with the specified namespace URI, the old
|
||||
* prefix is replaced by the specified prefix.
|
||||
*
|
||||
* @param namespaceURI a namespace URI
|
||||
* @param prefix a namespace prefix (or <code>null</code> to remove any
|
||||
* existing mapping). Specifying the empty string (<code>""</code>)
|
||||
* binds no prefix to the namespace URI.
|
||||
* @return the previous prefix associated with the specified namespace
|
||||
* URI, or <code>null</code> if there was none
|
||||
* @throws NullPointerException if <code>namespaceURI</code> is
|
||||
* <code>null</code>
|
||||
* @see #getNamespacePrefix(String, String)
|
||||
*/
|
||||
String putNamespacePrefix(String namespaceURI, String prefix);
|
||||
|
||||
/**
|
||||
* Returns the default namespace prefix. The default namespace prefix
|
||||
* is the prefix for all namespace URIs not explicitly set by the
|
||||
* {@link #putNamespacePrefix putNamespacePrefix} method.
|
||||
*
|
||||
* @return the default namespace prefix, or <code>null</code> if none has
|
||||
* been set.
|
||||
* @see #setDefaultNamespacePrefix(String)
|
||||
*/
|
||||
String getDefaultNamespacePrefix();
|
||||
|
||||
/**
|
||||
* Sets the default namespace prefix. This sets the namespace prefix for
|
||||
* all namespace URIs not explicitly set by the {@link #putNamespacePrefix
|
||||
* putNamespacePrefix} method.
|
||||
*
|
||||
* @param defaultPrefix the default namespace prefix, or <code>null</code>
|
||||
* to remove the current setting. Specify the empty string
|
||||
* (<code>""</code>) to bind no prefix.
|
||||
* @see #getDefaultNamespacePrefix
|
||||
*/
|
||||
void setDefaultNamespacePrefix(String defaultPrefix);
|
||||
|
||||
/**
|
||||
* Sets the specified property.
|
||||
*
|
||||
* @param name the name of the property
|
||||
* @param value the value of the property to be set
|
||||
* @return the previous value of the specified property, or
|
||||
* <code>null</code> if it did not have a value
|
||||
* @throws NullPointerException if <code>name</code> is <code>null</code>
|
||||
* @see #getProperty(String)
|
||||
*/
|
||||
Object setProperty(String name, Object value);
|
||||
|
||||
/**
|
||||
* Returns the value of the specified property.
|
||||
*
|
||||
* @param name the name of the property
|
||||
* @return the current value of the specified property, or
|
||||
* <code>null</code> if it does not have a value
|
||||
* @throws NullPointerException if <code>name</code> is <code>null</code>
|
||||
* @see #setProperty(String, Object)
|
||||
*/
|
||||
Object getProperty(String name);
|
||||
|
||||
/**
|
||||
* Returns the value to which this context maps the specified key.
|
||||
*
|
||||
* <p>More formally, if this context contains a mapping from a key
|
||||
* <code>k</code> to a value <code>v</code> such that
|
||||
* <code>(key==null ? k==null : key.equals(k))</code>, then this method
|
||||
* returns <code>v</code>; otherwise it returns <code>null</code>. (There
|
||||
* can be at most one such mapping.)
|
||||
*
|
||||
* <p>This method is useful for retrieving arbitrary information that is
|
||||
* specific to the cryptographic operation that this context is used for.
|
||||
*
|
||||
* @param key the key whose associated value is to be returned
|
||||
* @return the value to which this context maps the specified key, or
|
||||
* <code>null</code> if there is no mapping for the key
|
||||
* @see #put(Object, Object)
|
||||
*/
|
||||
Object get(Object key);
|
||||
|
||||
/**
|
||||
* Associates the specified value with the specified key in this context.
|
||||
* If the context previously contained a mapping for this key, the old
|
||||
* value is replaced by the specified value.
|
||||
*
|
||||
* <p>This method is useful for storing arbitrary information that is
|
||||
* specific to the cryptographic operation that this context is used for.
|
||||
*
|
||||
* @param key key with which the specified value is to be associated with
|
||||
* @param value value to be associated with the specified key
|
||||
* @return the previous value associated with the key, or <code>null</code>
|
||||
* if there was no mapping for the key
|
||||
* @throws IllegalArgumentException if some aspect of this key or value
|
||||
* prevents it from being stored in this context
|
||||
* @see #get(Object)
|
||||
*/
|
||||
Object put(Object key, Object value);
|
||||
}
|
||||
50
jdkSrc/jdk8/javax/xml/crypto/XMLStructure.java
Normal file
50
jdkSrc/jdk8/javax/xml/crypto/XMLStructure.java
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: XMLStructure.java,v 1.3 2005/05/10 15:47:42 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto;
|
||||
|
||||
/**
|
||||
* A representation of an XML structure from any namespace. The purpose of
|
||||
* this interface is to group (and provide type safety for) all
|
||||
* representations of XML structures.
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface XMLStructure {
|
||||
|
||||
/**
|
||||
* Indicates whether a specified feature is supported.
|
||||
*
|
||||
* @param feature the feature name (as an absolute URI)
|
||||
* @return <code>true</code> if the specified feature is supported,
|
||||
* <code>false</code> otherwise
|
||||
* @throws NullPointerException if <code>feature</code> is <code>null</code>
|
||||
*/
|
||||
boolean isFeatureSupported(String feature);
|
||||
}
|
||||
244
jdkSrc/jdk8/javax/xml/crypto/dom/DOMCryptoContext.java
Normal file
244
jdkSrc/jdk8/javax/xml/crypto/dom/DOMCryptoContext.java
Normal file
@@ -0,0 +1,244 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: DOMCryptoContext.java,v 1.3 2005/05/09 18:33:26 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dom;
|
||||
|
||||
import javax.xml.crypto.KeySelector;
|
||||
import javax.xml.crypto.URIDereferencer;
|
||||
import javax.xml.crypto.XMLCryptoContext;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* This class provides a DOM-specific implementation of the
|
||||
* {@link XMLCryptoContext} interface. It also includes additional
|
||||
* methods that are specific to a DOM-based implementation for registering
|
||||
* and retrieving elements that contain attributes of type ID.
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
*/
|
||||
public class DOMCryptoContext implements XMLCryptoContext {
|
||||
|
||||
private HashMap<String,String> nsMap = new HashMap<>();
|
||||
private HashMap<String,Element> idMap = new HashMap<>();
|
||||
private HashMap<Object,Object> objMap = new HashMap<>();
|
||||
private String baseURI;
|
||||
private KeySelector ks;
|
||||
private URIDereferencer dereferencer;
|
||||
private HashMap<String,Object> propMap = new HashMap<>();
|
||||
private String defaultPrefix;
|
||||
|
||||
/**
|
||||
* Default constructor. (For invocation by subclass constructors).
|
||||
*/
|
||||
protected DOMCryptoContext() {}
|
||||
|
||||
/**
|
||||
* This implementation uses an internal {@link HashMap} to get the prefix
|
||||
* that the specified URI maps to. It returns the <code>defaultPrefix</code>
|
||||
* if it maps to <code>null</code>.
|
||||
*
|
||||
* @throws NullPointerException {@inheritDoc}
|
||||
*/
|
||||
public String getNamespacePrefix(String namespaceURI,
|
||||
String defaultPrefix) {
|
||||
if (namespaceURI == null) {
|
||||
throw new NullPointerException("namespaceURI cannot be null");
|
||||
}
|
||||
String prefix = nsMap.get(namespaceURI);
|
||||
return (prefix != null ? prefix : defaultPrefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* This implementation uses an internal {@link HashMap} to map the URI
|
||||
* to the specified prefix.
|
||||
*
|
||||
* @throws NullPointerException {@inheritDoc}
|
||||
*/
|
||||
public String putNamespacePrefix(String namespaceURI, String prefix) {
|
||||
if (namespaceURI == null) {
|
||||
throw new NullPointerException("namespaceURI is null");
|
||||
}
|
||||
return nsMap.put(namespaceURI, prefix);
|
||||
}
|
||||
|
||||
public String getDefaultNamespacePrefix() {
|
||||
return defaultPrefix;
|
||||
}
|
||||
|
||||
public void setDefaultNamespacePrefix(String defaultPrefix) {
|
||||
this.defaultPrefix = defaultPrefix;
|
||||
}
|
||||
|
||||
public String getBaseURI() {
|
||||
return baseURI;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws IllegalArgumentException {@inheritDoc}
|
||||
*/
|
||||
public void setBaseURI(String baseURI) {
|
||||
if (baseURI != null) {
|
||||
java.net.URI.create(baseURI);
|
||||
}
|
||||
this.baseURI = baseURI;
|
||||
}
|
||||
|
||||
public URIDereferencer getURIDereferencer() {
|
||||
return dereferencer;
|
||||
}
|
||||
|
||||
public void setURIDereferencer(URIDereferencer dereferencer) {
|
||||
this.dereferencer = dereferencer;
|
||||
}
|
||||
|
||||
/**
|
||||
* This implementation uses an internal {@link HashMap} to get the object
|
||||
* that the specified name maps to.
|
||||
*
|
||||
* @throws NullPointerException {@inheritDoc}
|
||||
*/
|
||||
public Object getProperty(String name) {
|
||||
if (name == null) {
|
||||
throw new NullPointerException("name is null");
|
||||
}
|
||||
return propMap.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* This implementation uses an internal {@link HashMap} to map the name
|
||||
* to the specified object.
|
||||
*
|
||||
* @throws NullPointerException {@inheritDoc}
|
||||
*/
|
||||
public Object setProperty(String name, Object value) {
|
||||
if (name == null) {
|
||||
throw new NullPointerException("name is null");
|
||||
}
|
||||
return propMap.put(name, value);
|
||||
}
|
||||
|
||||
public KeySelector getKeySelector() {
|
||||
return ks;
|
||||
}
|
||||
|
||||
public void setKeySelector(KeySelector ks) {
|
||||
this.ks = ks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <code>Element</code> with the specified ID attribute value.
|
||||
*
|
||||
* <p>This implementation uses an internal {@link HashMap} to get the
|
||||
* element that the specified attribute value maps to.
|
||||
*
|
||||
* @param idValue the value of the ID
|
||||
* @return the <code>Element</code> with the specified ID attribute value,
|
||||
* or <code>null</code> if none.
|
||||
* @throws NullPointerException if <code>idValue</code> is <code>null</code>
|
||||
* @see #setIdAttributeNS
|
||||
*/
|
||||
public Element getElementById(String idValue) {
|
||||
if (idValue == null) {
|
||||
throw new NullPointerException("idValue is null");
|
||||
}
|
||||
return idMap.get(idValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the element's attribute specified by the namespace URI and
|
||||
* local name to be of type ID. The attribute must have a non-empty value.
|
||||
*
|
||||
* <p>This implementation uses an internal {@link HashMap} to map the
|
||||
* attribute's value to the specified element.
|
||||
*
|
||||
* @param element the element
|
||||
* @param namespaceURI the namespace URI of the attribute (specify
|
||||
* <code>null</code> if not applicable)
|
||||
* @param localName the local name of the attribute
|
||||
* @throws IllegalArgumentException if <code>localName</code> is not an
|
||||
* attribute of the specified element or it does not contain a specific
|
||||
* value
|
||||
* @throws NullPointerException if <code>element</code> or
|
||||
* <code>localName</code> is <code>null</code>
|
||||
* @see #getElementById
|
||||
*/
|
||||
public void setIdAttributeNS(Element element, String namespaceURI,
|
||||
String localName) {
|
||||
if (element == null) {
|
||||
throw new NullPointerException("element is null");
|
||||
}
|
||||
if (localName == null) {
|
||||
throw new NullPointerException("localName is null");
|
||||
}
|
||||
String idValue = element.getAttributeNS(namespaceURI, localName);
|
||||
if (idValue == null || idValue.length() == 0) {
|
||||
throw new IllegalArgumentException(localName + " is not an " +
|
||||
"attribute");
|
||||
}
|
||||
idMap.put(idValue, element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a read-only iterator over the set of Id/Element mappings of
|
||||
* this <code>DOMCryptoContext</code>. Attempts to modify the set via the
|
||||
* {@link Iterator#remove} method throw an
|
||||
* <code>UnsupportedOperationException</code>. The mappings are returned
|
||||
* in no particular order. Each element in the iteration is represented as a
|
||||
* {@link java.util.Map.Entry}. If the <code>DOMCryptoContext</code> is
|
||||
* modified while an iteration is in progress, the results of the
|
||||
* iteration are undefined.
|
||||
*
|
||||
* @return a read-only iterator over the set of mappings
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Iterator iterator() {
|
||||
return Collections.unmodifiableMap(idMap).entrySet().iterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* This implementation uses an internal {@link HashMap} to get the object
|
||||
* that the specified key maps to.
|
||||
*/
|
||||
public Object get(Object key) {
|
||||
return objMap.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* This implementation uses an internal {@link HashMap} to map the key
|
||||
* to the specified object.
|
||||
*
|
||||
* @throws IllegalArgumentException {@inheritDoc}
|
||||
*/
|
||||
public Object put(Object key, Object value) {
|
||||
return objMap.put(key, value);
|
||||
}
|
||||
}
|
||||
88
jdkSrc/jdk8/javax/xml/crypto/dom/DOMStructure.java
Normal file
88
jdkSrc/jdk8/javax/xml/crypto/dom/DOMStructure.java
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: DOMStructure.java,v 1.6 2005/05/09 18:33:26 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dom;
|
||||
|
||||
import org.w3c.dom.Node;
|
||||
import javax.xml.crypto.XMLStructure;
|
||||
import javax.xml.crypto.dsig.XMLSignature;
|
||||
|
||||
/**
|
||||
* A DOM-specific {@link XMLStructure}. The purpose of this class is to
|
||||
* allow a DOM node to be used to represent extensible content (any elements
|
||||
* or mixed content) in XML Signature structures.
|
||||
*
|
||||
* <p>If a sequence of nodes is needed, the node contained in the
|
||||
* <code>DOMStructure</code> is the first node of the sequence and successive
|
||||
* nodes can be accessed by invoking {@link Node#getNextSibling}.
|
||||
*
|
||||
* <p>If the owner document of the <code>DOMStructure</code> is different than
|
||||
* the target document of an <code>XMLSignature</code>, the
|
||||
* {@link XMLSignature#sign(XMLSignContext)} method imports the node into the
|
||||
* target document before generating the signature.
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
*/
|
||||
public class DOMStructure implements XMLStructure {
|
||||
|
||||
private final Node node;
|
||||
|
||||
/**
|
||||
* Creates a <code>DOMStructure</code> containing the specified node.
|
||||
*
|
||||
* @param node the node
|
||||
* @throws NullPointerException if <code>node</code> is <code>null</code>
|
||||
*/
|
||||
public DOMStructure(Node node) {
|
||||
if (node == null) {
|
||||
throw new NullPointerException("node cannot be null");
|
||||
}
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the node contained in this <code>DOMStructure</code>.
|
||||
*
|
||||
* @return the node
|
||||
*/
|
||||
public Node getNode() {
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws NullPointerException {@inheritDoc}
|
||||
*/
|
||||
public boolean isFeatureSupported(String feature) {
|
||||
if (feature == null) {
|
||||
throw new NullPointerException();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
51
jdkSrc/jdk8/javax/xml/crypto/dom/DOMURIReference.java
Normal file
51
jdkSrc/jdk8/javax/xml/crypto/dom/DOMURIReference.java
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: DOMURIReference.java,v 1.5 2005/05/09 18:33:26 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dom;
|
||||
|
||||
import javax.xml.crypto.URIReference;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/**
|
||||
* A DOM-specific {@link URIReference}. The purpose of this class is to
|
||||
* provide additional context necessary for resolving XPointer URIs or
|
||||
* same-document references.
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface DOMURIReference extends URIReference {
|
||||
|
||||
/**
|
||||
* Returns the here node.
|
||||
*
|
||||
* @return the attribute or processing instruction node or the
|
||||
* parent element of the text node that directly contains the URI
|
||||
*/
|
||||
Node getHere();
|
||||
}
|
||||
104
jdkSrc/jdk8/javax/xml/crypto/dsig/CanonicalizationMethod.java
Normal file
104
jdkSrc/jdk8/javax/xml/crypto/dsig/CanonicalizationMethod.java
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: CanonicalizationMethod.java,v 1.6 2005/05/10 16:03:45 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig;
|
||||
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
import javax.xml.crypto.dsig.spec.C14NMethodParameterSpec;
|
||||
|
||||
/**
|
||||
* A representation of the XML <code>CanonicalizationMethod</code>
|
||||
* element as defined in the
|
||||
* <a href="http://www.w3.org/TR/xmldsig-core/">
|
||||
* W3C Recommendation for XML-Signature Syntax and Processing</a>. The XML
|
||||
* Schema Definition is defined as:
|
||||
* <p>
|
||||
* <pre>
|
||||
* <element name="CanonicalizationMethod" type="ds:CanonicalizationMethodType"/>
|
||||
* <complexType name="CanonicalizationMethodType" mixed="true">
|
||||
* <sequence>
|
||||
* <any namespace="##any" minOccurs="0" maxOccurs="unbounded"/>
|
||||
* <!-- (0,unbounded) elements from (1,1) namespace -->
|
||||
* </sequence>
|
||||
* <attribute name="Algorithm" type="anyURI" use="required"/>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
* A <code>CanonicalizationMethod</code> instance may be created by invoking
|
||||
* the {@link XMLSignatureFactory#newCanonicalizationMethod
|
||||
* newCanonicalizationMethod} method of the {@link XMLSignatureFactory} class.
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
* @see XMLSignatureFactory#newCanonicalizationMethod(String, C14NMethodParameterSpec)
|
||||
*/
|
||||
public interface CanonicalizationMethod extends Transform {
|
||||
|
||||
/**
|
||||
* The <a href="http://www.w3.org/TR/2001/REC-xml-c14n-20010315">Canonical
|
||||
* XML (without comments)</a> canonicalization method algorithm URI.
|
||||
*/
|
||||
final static String INCLUSIVE =
|
||||
"http://www.w3.org/TR/2001/REC-xml-c14n-20010315";
|
||||
|
||||
/**
|
||||
* The
|
||||
* <a href="http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments">
|
||||
* Canonical XML with comments</a> canonicalization method algorithm URI.
|
||||
*/
|
||||
final static String INCLUSIVE_WITH_COMMENTS =
|
||||
"http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments";
|
||||
|
||||
/**
|
||||
* The <a href="http://www.w3.org/2001/10/xml-exc-c14n#">Exclusive
|
||||
* Canonical XML (without comments)</a> canonicalization method algorithm
|
||||
* URI.
|
||||
*/
|
||||
final static String EXCLUSIVE =
|
||||
"http://www.w3.org/2001/10/xml-exc-c14n#";
|
||||
|
||||
/**
|
||||
* The <a href="http://www.w3.org/2001/10/xml-exc-c14n#WithComments">
|
||||
* Exclusive Canonical XML with comments</a> canonicalization method
|
||||
* algorithm URI.
|
||||
*/
|
||||
final static String EXCLUSIVE_WITH_COMMENTS =
|
||||
"http://www.w3.org/2001/10/xml-exc-c14n#WithComments";
|
||||
|
||||
/**
|
||||
* Returns the algorithm-specific input parameters associated with this
|
||||
* <code>CanonicalizationMethod</code>.
|
||||
*
|
||||
* <p>The returned parameters can be typecast to a
|
||||
* {@link C14NMethodParameterSpec} object.
|
||||
*
|
||||
* @return the algorithm-specific input parameters (may be
|
||||
* <code>null</code> if not specified)
|
||||
*/
|
||||
AlgorithmParameterSpec getParameterSpec();
|
||||
}
|
||||
100
jdkSrc/jdk8/javax/xml/crypto/dsig/DigestMethod.java
Normal file
100
jdkSrc/jdk8/javax/xml/crypto/dsig/DigestMethod.java
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: DigestMethod.java,v 1.6 2005/05/10 16:03:46 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig;
|
||||
|
||||
import javax.xml.crypto.AlgorithmMethod;
|
||||
import javax.xml.crypto.XMLStructure;
|
||||
import javax.xml.crypto.dsig.spec.DigestMethodParameterSpec;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
|
||||
/**
|
||||
* A representation of the XML <code>DigestMethod</code> element as
|
||||
* defined in the <a href="http://www.w3.org/TR/xmldsig-core/">
|
||||
* W3C Recommendation for XML-Signature Syntax and Processing</a>.
|
||||
* The XML Schema Definition is defined as:
|
||||
* <p>
|
||||
* <pre>
|
||||
* <element name="DigestMethod" type="ds:DigestMethodType"/>
|
||||
* <complexType name="DigestMethodType" mixed="true">
|
||||
* <sequence>
|
||||
* <any namespace="##any" minOccurs="0" maxOccurs="unbounded"/>
|
||||
* <!-- (0,unbounded) elements from (1,1) namespace -->
|
||||
* </sequence>
|
||||
* <attribute name="Algorithm" type="anyURI" use="required"/>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
* A <code>DigestMethod</code> instance may be created by invoking the
|
||||
* {@link XMLSignatureFactory#newDigestMethod newDigestMethod} method
|
||||
* of the {@link XMLSignatureFactory} class.
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
* @see XMLSignatureFactory#newDigestMethod(String, DigestMethodParameterSpec)
|
||||
*/
|
||||
public interface DigestMethod extends XMLStructure, AlgorithmMethod {
|
||||
|
||||
// All methods can be found in RFC 6931.
|
||||
|
||||
/**
|
||||
* The <a href="http://www.w3.org/2000/09/xmldsig#sha1">
|
||||
* SHA1</a> digest method algorithm URI.
|
||||
*/
|
||||
String SHA1 = "http://www.w3.org/2000/09/xmldsig#sha1";
|
||||
|
||||
/**
|
||||
* The <a href="http://www.w3.org/2001/04/xmlenc#sha256">
|
||||
* SHA256</a> digest method algorithm URI.
|
||||
*/
|
||||
String SHA256 = "http://www.w3.org/2001/04/xmlenc#sha256";
|
||||
|
||||
/**
|
||||
* The <a href="http://www.w3.org/2001/04/xmlenc#sha512">
|
||||
* SHA512</a> digest method algorithm URI.
|
||||
*/
|
||||
String SHA512 = "http://www.w3.org/2001/04/xmlenc#sha512";
|
||||
|
||||
/**
|
||||
* The <a href="http://www.w3.org/2001/04/xmlenc#ripemd160">
|
||||
* RIPEMD-160</a> digest method algorithm URI.
|
||||
*/
|
||||
String RIPEMD160 = "http://www.w3.org/2001/04/xmlenc#ripemd160";
|
||||
|
||||
/**
|
||||
* Returns the algorithm-specific input parameters associated with this
|
||||
* <code>DigestMethod</code>.
|
||||
*
|
||||
* <p>The returned parameters can be typecast to a {@link
|
||||
* DigestMethodParameterSpec} object.
|
||||
*
|
||||
* @return the algorithm-specific parameters (may be <code>null</code> if
|
||||
* not specified)
|
||||
*/
|
||||
AlgorithmParameterSpec getParameterSpec();
|
||||
}
|
||||
91
jdkSrc/jdk8/javax/xml/crypto/dsig/Manifest.java
Normal file
91
jdkSrc/jdk8/javax/xml/crypto/dsig/Manifest.java
Normal file
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: Manifest.java,v 1.7 2005/05/10 16:03:46 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig;
|
||||
|
||||
import javax.xml.crypto.XMLStructure;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A representation of the XML <code>Manifest</code> element as defined in
|
||||
* the <a href="http://www.w3.org/TR/xmldsig-core/">
|
||||
* W3C Recommendation for XML-Signature Syntax and Processing</a>.
|
||||
* The XML Schema Definition is defined as:
|
||||
* <pre>{@code
|
||||
* <element name="Manifest" type="ds:ManifestType"/>
|
||||
* <complexType name="ManifestType">
|
||||
* <sequence>
|
||||
* <element ref="ds:Reference" maxOccurs="unbounded"/>
|
||||
* </sequence>
|
||||
* <attribute name="Id" type="ID" use="optional"/>
|
||||
* </complexType>
|
||||
* }</pre>
|
||||
*
|
||||
* A <code>Manifest</code> instance may be created by invoking
|
||||
* one of the {@link XMLSignatureFactory#newManifest newManifest}
|
||||
* methods of the {@link XMLSignatureFactory} class; for example:
|
||||
*
|
||||
* <pre>
|
||||
* XMLSignatureFactory factory = XMLSignatureFactory.getInstance("DOM");
|
||||
* List references = Collections.singletonList(factory.newReference
|
||||
* ("#reference-1", DigestMethod.SHA1));
|
||||
* Manifest manifest = factory.newManifest(references, "manifest-1");
|
||||
* </pre>
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
* @see XMLSignatureFactory#newManifest(List)
|
||||
* @see XMLSignatureFactory#newManifest(List, String)
|
||||
*/
|
||||
public interface Manifest extends XMLStructure {
|
||||
|
||||
/**
|
||||
* URI that identifies the <code>Manifest</code> element (this can be
|
||||
* specified as the value of the <code>type</code> parameter of the
|
||||
* {@link Reference} class to identify the referent's type).
|
||||
*/
|
||||
final static String TYPE = "http://www.w3.org/2000/09/xmldsig#Manifest";
|
||||
|
||||
/**
|
||||
* Returns the Id of this <code>Manifest</code>.
|
||||
*
|
||||
* @return the Id of this <code>Manifest</code> (or <code>null</code>
|
||||
* if not specified)
|
||||
*/
|
||||
String getId();
|
||||
|
||||
/**
|
||||
* Returns an {@link java.util.Collections#unmodifiableList unmodifiable
|
||||
* list} of one or more {@link Reference}s that are contained in this
|
||||
* <code>Manifest</code>.
|
||||
*
|
||||
* @return an unmodifiable list of one or more <code>Reference</code>s
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
List getReferences();
|
||||
}
|
||||
169
jdkSrc/jdk8/javax/xml/crypto/dsig/Reference.java
Normal file
169
jdkSrc/jdk8/javax/xml/crypto/dsig/Reference.java
Normal file
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: Reference.java,v 1.9 2005/05/10 16:03:46 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig;
|
||||
|
||||
import javax.xml.crypto.Data;
|
||||
import javax.xml.crypto.URIReference;
|
||||
import javax.xml.crypto.XMLStructure;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A representation of the <code>Reference</code> element as defined in the
|
||||
* <a href="http://www.w3.org/TR/xmldsig-core/">
|
||||
* W3C Recommendation for XML-Signature Syntax and Processing</a>.
|
||||
* The XML schema is defined as:
|
||||
* <code><pre>
|
||||
* <element name="Reference" type="ds:ReferenceType"/>
|
||||
* <complexType name="ReferenceType">
|
||||
* <sequence>
|
||||
* <element ref="ds:Transforms" minOccurs="0"/>
|
||||
* <element ref="ds:DigestMethod"/>
|
||||
* <element ref="ds:DigestValue"/>
|
||||
* </sequence>
|
||||
* <attribute name="Id" type="ID" use="optional"/>
|
||||
* <attribute name="URI" type="anyURI" use="optional"/>
|
||||
* <attribute name="Type" type="anyURI" use="optional"/>
|
||||
* </complexType>
|
||||
*
|
||||
* <element name="DigestValue" type="ds:DigestValueType"/>
|
||||
* <simpleType name="DigestValueType">
|
||||
* <restriction base="base64Binary"/>
|
||||
* </simpleType>
|
||||
* </pre></code>
|
||||
*
|
||||
* <p>A <code>Reference</code> instance may be created by invoking one of the
|
||||
* {@link XMLSignatureFactory#newReference newReference} methods of the
|
||||
* {@link XMLSignatureFactory} class; for example:
|
||||
*
|
||||
* <pre>
|
||||
* XMLSignatureFactory factory = XMLSignatureFactory.getInstance("DOM");
|
||||
* Reference ref = factory.newReference
|
||||
* ("http://www.ietf.org/rfc/rfc3275.txt",
|
||||
* factory.newDigestMethod(DigestMethod.SHA1, null));
|
||||
* </pre>
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author Erwin van der Koogh
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
* @see XMLSignatureFactory#newReference(String, DigestMethod)
|
||||
* @see XMLSignatureFactory#newReference(String, DigestMethod, List, String, String)
|
||||
*/
|
||||
public interface Reference extends URIReference, XMLStructure {
|
||||
|
||||
/**
|
||||
* Returns an {@link java.util.Collections#unmodifiableList unmodifiable
|
||||
* list} of {@link Transform}s that are contained in this
|
||||
* <code>Reference</code>.
|
||||
*
|
||||
* @return an unmodifiable list of <code>Transform</code>s
|
||||
* (may be empty but never <code>null</code>)
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
List getTransforms();
|
||||
|
||||
/**
|
||||
* Returns the digest method of this <code>Reference</code>.
|
||||
*
|
||||
* @return the digest method
|
||||
*/
|
||||
DigestMethod getDigestMethod();
|
||||
|
||||
/**
|
||||
* Returns the optional <code>Id</code> attribute of this
|
||||
* <code>Reference</code>, which permits this reference to be
|
||||
* referenced from elsewhere.
|
||||
*
|
||||
* @return the <code>Id</code> attribute (may be <code>null</code> if not
|
||||
* specified)
|
||||
*/
|
||||
String getId();
|
||||
|
||||
/**
|
||||
* Returns the digest value of this <code>Reference</code>.
|
||||
*
|
||||
* @return the raw digest value, or <code>null</code> if this reference has
|
||||
* not been digested yet. Each invocation of this method returns a new
|
||||
* clone to protect against subsequent modification.
|
||||
*/
|
||||
byte[] getDigestValue();
|
||||
|
||||
/**
|
||||
* Returns the calculated digest value of this <code>Reference</code>
|
||||
* after a validation operation. This method is useful for debugging if
|
||||
* the reference fails to validate.
|
||||
*
|
||||
* @return the calculated digest value, or <code>null</code> if this
|
||||
* reference has not been validated yet. Each invocation of this method
|
||||
* returns a new clone to protect against subsequent modification.
|
||||
*/
|
||||
byte[] getCalculatedDigestValue();
|
||||
|
||||
/**
|
||||
* Validates this reference. This method verifies the digest of this
|
||||
* reference.
|
||||
*
|
||||
* <p>This method only validates the reference the first time it is
|
||||
* invoked. On subsequent invocations, it returns a cached result.
|
||||
*
|
||||
* @return <code>true</code> if this reference was validated successfully;
|
||||
* <code>false</code> otherwise
|
||||
* @param validateContext the validating context
|
||||
* @throws NullPointerException if <code>validateContext</code> is
|
||||
* <code>null</code>
|
||||
* @throws XMLSignatureException if an unexpected exception occurs while
|
||||
* validating the reference
|
||||
*/
|
||||
boolean validate(XMLValidateContext validateContext)
|
||||
throws XMLSignatureException;
|
||||
|
||||
/**
|
||||
* Returns the dereferenced data, if
|
||||
* <a href="XMLSignContext.html#Supported Properties">reference caching</a>
|
||||
* is enabled. This is the result of dereferencing the URI of this
|
||||
* reference during a validation or generation operation.
|
||||
*
|
||||
* @return the dereferenced data, or <code>null</code> if reference
|
||||
* caching is not enabled or this reference has not been generated or
|
||||
* validated
|
||||
*/
|
||||
Data getDereferencedData();
|
||||
|
||||
/**
|
||||
* Returns the pre-digested input stream, if
|
||||
* <a href="XMLSignContext.html#Supported Properties">reference caching</a>
|
||||
* is enabled. This is the input to the digest operation during a
|
||||
* validation or signing operation.
|
||||
*
|
||||
* @return an input stream containing the pre-digested input, or
|
||||
* <code>null</code> if reference caching is not enabled or this
|
||||
* reference has not been generated or validated
|
||||
*/
|
||||
InputStream getDigestInputStream();
|
||||
}
|
||||
99
jdkSrc/jdk8/javax/xml/crypto/dsig/SignatureMethod.java
Normal file
99
jdkSrc/jdk8/javax/xml/crypto/dsig/SignatureMethod.java
Normal file
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: SignatureMethod.java,v 1.5 2005/05/10 16:03:46 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig;
|
||||
|
||||
import javax.xml.crypto.AlgorithmMethod;
|
||||
import javax.xml.crypto.XMLStructure;
|
||||
import javax.xml.crypto.dsig.spec.SignatureMethodParameterSpec;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
|
||||
/**
|
||||
* A representation of the XML <code>SignatureMethod</code> element
|
||||
* as defined in the <a href="http://www.w3.org/TR/xmldsig-core/">
|
||||
* W3C Recommendation for XML-Signature Syntax and Processing</a>.
|
||||
* The XML Schema Definition is defined as:
|
||||
* <p>
|
||||
* <pre>
|
||||
* <element name="SignatureMethod" type="ds:SignatureMethodType"/>
|
||||
* <complexType name="SignatureMethodType" mixed="true">
|
||||
* <sequence>
|
||||
* <element name="HMACOutputLength" minOccurs="0" type="ds:HMACOutputLengthType"/>
|
||||
* <any namespace="##any" minOccurs="0" maxOccurs="unbounded"/>
|
||||
* <!-- (0,unbounded) elements from (1,1) namespace -->
|
||||
* </sequence>
|
||||
* <attribute name="Algorithm" type="anyURI" use="required"/>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
* A <code>SignatureMethod</code> instance may be created by invoking the
|
||||
* {@link XMLSignatureFactory#newSignatureMethod newSignatureMethod} method
|
||||
* of the {@link XMLSignatureFactory} class.
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
* @see XMLSignatureFactory#newSignatureMethod(String, SignatureMethodParameterSpec)
|
||||
*/
|
||||
public interface SignatureMethod extends XMLStructure, AlgorithmMethod {
|
||||
|
||||
// All methods can be found in RFC 6931.
|
||||
|
||||
/**
|
||||
* The <a href="http://www.w3.org/2000/09/xmldsig#dsa-sha1">DSA-SHA1</a>
|
||||
* (DSS) signature method algorithm URI.
|
||||
*/
|
||||
String DSA_SHA1 =
|
||||
"http://www.w3.org/2000/09/xmldsig#dsa-sha1";
|
||||
|
||||
/**
|
||||
* The <a href="http://www.w3.org/2000/09/xmldsig#rsa-sha1">RSA-SHA1</a>
|
||||
* (PKCS #1) signature method algorithm URI.
|
||||
*/
|
||||
String RSA_SHA1 =
|
||||
"http://www.w3.org/2000/09/xmldsig#rsa-sha1";
|
||||
|
||||
/**
|
||||
* The <a href="http://www.w3.org/2000/09/xmldsig#hmac-sha1">HMAC-SHA1</a>
|
||||
* MAC signature method algorithm URI
|
||||
*/
|
||||
String HMAC_SHA1 =
|
||||
"http://www.w3.org/2000/09/xmldsig#hmac-sha1";
|
||||
|
||||
/**
|
||||
* Returns the algorithm-specific input parameters of this
|
||||
* <code>SignatureMethod</code>.
|
||||
*
|
||||
* <p>The returned parameters can be typecast to a {@link
|
||||
* SignatureMethodParameterSpec} object.
|
||||
*
|
||||
* @return the algorithm-specific input parameters of this
|
||||
* <code>SignatureMethod</code> (may be <code>null</code> if not
|
||||
* specified)
|
||||
*/
|
||||
AlgorithmParameterSpec getParameterSpec();
|
||||
}
|
||||
92
jdkSrc/jdk8/javax/xml/crypto/dsig/SignatureProperties.java
Normal file
92
jdkSrc/jdk8/javax/xml/crypto/dsig/SignatureProperties.java
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: SignatureProperties.java,v 1.4 2005/05/10 16:03:46 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig;
|
||||
|
||||
import javax.xml.crypto.XMLStructure;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A representation of the XML <code>SignatureProperties</code> element as
|
||||
* defined in the <a href="http://www.w3.org/TR/xmldsig-core/">
|
||||
* W3C Recommendation for XML-Signature Syntax and Processing</a>.
|
||||
* The XML Schema Definition is defined as:
|
||||
* <pre><code>
|
||||
*<element name="SignatureProperties" type="ds:SignaturePropertiesType"/>
|
||||
* <complexType name="SignaturePropertiesType">
|
||||
* <sequence>
|
||||
* <element ref="ds:SignatureProperty" maxOccurs="unbounded"/>
|
||||
* </sequence>
|
||||
* <attribute name="Id" type="ID" use="optional"/>
|
||||
* </complexType>
|
||||
* </code></pre>
|
||||
*
|
||||
* A <code>SignatureProperties</code> instance may be created by invoking the
|
||||
* {@link XMLSignatureFactory#newSignatureProperties newSignatureProperties}
|
||||
* method of the {@link XMLSignatureFactory} class; for example:
|
||||
*
|
||||
* <pre>
|
||||
* XMLSignatureFactory factory = XMLSignatureFactory.getInstance("DOM");
|
||||
* SignatureProperties properties =
|
||||
* factory.newSignatureProperties(props, "signature-properties-1");
|
||||
* </pre>
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
* @see XMLSignatureFactory#newSignatureProperties(List, String)
|
||||
* @see SignatureProperty
|
||||
*/
|
||||
public interface SignatureProperties extends XMLStructure {
|
||||
|
||||
/**
|
||||
* URI that identifies the <code>SignatureProperties</code> element (this
|
||||
* can be specified as the value of the <code>type</code> parameter of the
|
||||
* {@link Reference} class to identify the referent's type).
|
||||
*/
|
||||
final static String TYPE =
|
||||
"http://www.w3.org/2000/09/xmldsig#SignatureProperties";
|
||||
|
||||
/**
|
||||
* Returns the Id of this <code>SignatureProperties</code>.
|
||||
*
|
||||
* @return the Id of this <code>SignatureProperties</code> (or
|
||||
* <code>null</code> if not specified)
|
||||
*/
|
||||
String getId();
|
||||
|
||||
/**
|
||||
* Returns an {@link java.util.Collections#unmodifiableList unmodifiable
|
||||
* list} of one or more {@link SignatureProperty}s that are contained in
|
||||
* this <code>SignatureProperties</code>.
|
||||
*
|
||||
* @return an unmodifiable list of one or more
|
||||
* <code>SignatureProperty</code>s
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
List getProperties();
|
||||
}
|
||||
96
jdkSrc/jdk8/javax/xml/crypto/dsig/SignatureProperty.java
Normal file
96
jdkSrc/jdk8/javax/xml/crypto/dsig/SignatureProperty.java
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: SignatureProperty.java,v 1.4 2005/05/10 16:03:46 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig;
|
||||
|
||||
import javax.xml.crypto.XMLStructure;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A representation of the XML <code>SignatureProperty</code> element as
|
||||
* defined in the <a href="http://www.w3.org/TR/xmldsig-core/">
|
||||
* W3C Recommendation for XML-Signature Syntax and Processing</a>.
|
||||
* The XML Schema Definition is defined as:
|
||||
* <pre><code>
|
||||
*<element name="SignatureProperty" type="ds:SignaturePropertyType"/>
|
||||
* <complexType name="SignaturePropertyType" mixed="true">
|
||||
* <choice maxOccurs="unbounded">
|
||||
* <any namespace="##other" processContents="lax"/>
|
||||
* <!-- (1,1) elements from (1, unbounded) namespaces -->
|
||||
* </choice>
|
||||
* <attribute name="Target" type="anyURI" use="required"/>
|
||||
* <attribute name="Id" type="ID" use="optional"/>
|
||||
* </complexType>
|
||||
* </code></pre>
|
||||
*
|
||||
* A <code>SignatureProperty</code> instance may be created by invoking the
|
||||
* {@link XMLSignatureFactory#newSignatureProperty newSignatureProperty}
|
||||
* method of the {@link XMLSignatureFactory} class; for example:
|
||||
*
|
||||
* <pre>
|
||||
* XMLSignatureFactory factory = XMLSignatureFactory.getInstance("DOM");
|
||||
* SignatureProperty property = factory.newSignatureProperty
|
||||
* (Collections.singletonList(content), "#Signature-1", "TimeStamp");
|
||||
* </pre>
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
* @see XMLSignatureFactory#newSignatureProperty(List, String, String)
|
||||
* @see SignatureProperties
|
||||
*/
|
||||
public interface SignatureProperty extends XMLStructure {
|
||||
|
||||
/**
|
||||
* Returns the target URI of this <code>SignatureProperty</code>.
|
||||
*
|
||||
* @return the target URI of this <code>SignatureProperty</code> (never
|
||||
* <code>null</code>)
|
||||
*/
|
||||
String getTarget();
|
||||
|
||||
/**
|
||||
* Returns the Id of this <code>SignatureProperty</code>.
|
||||
*
|
||||
* @return the Id of this <code>SignatureProperty</code> (or
|
||||
* <code>null</code> if not specified)
|
||||
*/
|
||||
String getId();
|
||||
|
||||
/**
|
||||
* Returns an {@link java.util.Collections#unmodifiableList unmodifiable
|
||||
* list} of one or more {@link XMLStructure}s that are contained in
|
||||
* this <code>SignatureProperty</code>. These represent additional
|
||||
* information items concerning the generation of the {@link XMLSignature}
|
||||
* (i.e. date/time stamp or serial numbers of cryptographic hardware used
|
||||
* in signature generation).
|
||||
*
|
||||
* @return an unmodifiable list of one or more <code>XMLStructure</code>s
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
List getContent();
|
||||
}
|
||||
103
jdkSrc/jdk8/javax/xml/crypto/dsig/SignedInfo.java
Normal file
103
jdkSrc/jdk8/javax/xml/crypto/dsig/SignedInfo.java
Normal file
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: SignedInfo.java,v 1.7 2005/05/10 16:03:47 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig;
|
||||
|
||||
import javax.xml.crypto.XMLStructure;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* An representation of the XML <code>SignedInfo</code> element as
|
||||
* defined in the <a href="http://www.w3.org/TR/xmldsig-core/">
|
||||
* W3C Recommendation for XML-Signature Syntax and Processing</a>.
|
||||
* The XML Schema Definition is defined as:
|
||||
* <pre><code>
|
||||
* <element name="SignedInfo" type="ds:SignedInfoType"/>
|
||||
* <complexType name="SignedInfoType">
|
||||
* <sequence>
|
||||
* <element ref="ds:CanonicalizationMethod"/>
|
||||
* <element ref="ds:SignatureMethod"/>
|
||||
* <element ref="ds:Reference" maxOccurs="unbounded"/>
|
||||
* </sequence>
|
||||
* <attribute name="Id" type="ID" use="optional"/>
|
||||
* </complexType>
|
||||
* </code></pre>
|
||||
*
|
||||
* A <code>SignedInfo</code> instance may be created by invoking one of the
|
||||
* {@link XMLSignatureFactory#newSignedInfo newSignedInfo} methods of the
|
||||
* {@link XMLSignatureFactory} class.
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
* @see XMLSignatureFactory#newSignedInfo(CanonicalizationMethod, SignatureMethod, List)
|
||||
* @see XMLSignatureFactory#newSignedInfo(CanonicalizationMethod, SignatureMethod, List, String)
|
||||
*/
|
||||
public interface SignedInfo extends XMLStructure {
|
||||
|
||||
/**
|
||||
* Returns the canonicalization method of this <code>SignedInfo</code>.
|
||||
*
|
||||
* @return the canonicalization method
|
||||
*/
|
||||
CanonicalizationMethod getCanonicalizationMethod();
|
||||
|
||||
/**
|
||||
* Returns the signature method of this <code>SignedInfo</code>.
|
||||
*
|
||||
* @return the signature method
|
||||
*/
|
||||
SignatureMethod getSignatureMethod();
|
||||
|
||||
/**
|
||||
* Returns an {@link java.util.Collections#unmodifiableList
|
||||
* unmodifiable list} of one or more {@link Reference}s.
|
||||
*
|
||||
* @return an unmodifiable list of one or more {@link Reference}s
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
List getReferences();
|
||||
|
||||
/**
|
||||
* Returns the optional <code>Id</code> attribute of this
|
||||
* <code>SignedInfo</code>.
|
||||
*
|
||||
* @return the id (may be <code>null</code> if not specified)
|
||||
*/
|
||||
String getId();
|
||||
|
||||
/**
|
||||
* Returns the canonicalized signed info bytes after a signing or
|
||||
* validation operation. This method is useful for debugging.
|
||||
*
|
||||
* @return an <code>InputStream</code> containing the canonicalized bytes,
|
||||
* or <code>null</code> if this <code>SignedInfo</code> has not been
|
||||
* signed or validated yet
|
||||
*/
|
||||
InputStream getCanonicalizedData();
|
||||
}
|
||||
148
jdkSrc/jdk8/javax/xml/crypto/dsig/Transform.java
Normal file
148
jdkSrc/jdk8/javax/xml/crypto/dsig/Transform.java
Normal file
@@ -0,0 +1,148 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: Transform.java,v 1.5 2005/05/10 16:03:48 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
import javax.xml.crypto.AlgorithmMethod;
|
||||
import javax.xml.crypto.Data;
|
||||
import javax.xml.crypto.OctetStreamData;
|
||||
import javax.xml.crypto.XMLCryptoContext;
|
||||
import javax.xml.crypto.XMLStructure;
|
||||
import javax.xml.crypto.dsig.spec.TransformParameterSpec;
|
||||
|
||||
/**
|
||||
* A representation of the XML <code>Transform</code> element as
|
||||
* defined in the <a href="http://www.w3.org/TR/xmldsig-core/">
|
||||
* W3C Recommendation for XML-Signature Syntax and Processing</a>.
|
||||
* The XML Schema Definition is defined as:
|
||||
*
|
||||
* <pre>
|
||||
* <element name="Transform" type="ds:TransformType"/>
|
||||
* <complexType name="TransformType" mixed="true">
|
||||
* <choice minOccurs="0" maxOccurs="unbounded">
|
||||
* <any namespace="##other" processContents="lax"/>
|
||||
* <!-- (1,1) elements from (0,unbounded) namespaces -->
|
||||
* <element name="XPath" type="string"/>
|
||||
* </choice>
|
||||
* <attribute name="Algorithm" type="anyURI" use="required"/>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
* A <code>Transform</code> instance may be created by invoking the
|
||||
* {@link XMLSignatureFactory#newTransform newTransform} method
|
||||
* of the {@link XMLSignatureFactory} class.
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
* @see XMLSignatureFactory#newTransform(String, TransformParameterSpec)
|
||||
*/
|
||||
public interface Transform extends XMLStructure, AlgorithmMethod {
|
||||
|
||||
/**
|
||||
* The <a href="http://www.w3.org/2000/09/xmldsig#base64">Base64</a>
|
||||
* transform algorithm URI.
|
||||
*/
|
||||
final static String BASE64 = "http://www.w3.org/2000/09/xmldsig#base64";
|
||||
|
||||
/**
|
||||
* The <a href="http://www.w3.org/2000/09/xmldsig#enveloped-signature">
|
||||
* Enveloped Signature</a> transform algorithm URI.
|
||||
*/
|
||||
final static String ENVELOPED =
|
||||
"http://www.w3.org/2000/09/xmldsig#enveloped-signature";
|
||||
|
||||
/**
|
||||
* The <a href="http://www.w3.org/TR/1999/REC-xpath-19991116">XPath</a>
|
||||
* transform algorithm URI.
|
||||
*/
|
||||
final static String XPATH = "http://www.w3.org/TR/1999/REC-xpath-19991116";
|
||||
|
||||
/**
|
||||
* The <a href="http://www.w3.org/2002/06/xmldsig-filter2">
|
||||
* XPath Filter 2</a> transform algorithm URI.
|
||||
*/
|
||||
final static String XPATH2 = "http://www.w3.org/2002/06/xmldsig-filter2";
|
||||
|
||||
/**
|
||||
* The <a href="http://www.w3.org/TR/1999/REC-xslt-19991116">XSLT</a>
|
||||
* transform algorithm URI.
|
||||
*/
|
||||
final static String XSLT = "http://www.w3.org/TR/1999/REC-xslt-19991116";
|
||||
|
||||
/**
|
||||
* Returns the algorithm-specific input parameters associated with this
|
||||
* <code>Transform</code>.
|
||||
* <p>
|
||||
* The returned parameters can be typecast to a
|
||||
* {@link TransformParameterSpec} object.
|
||||
*
|
||||
* @return the algorithm-specific input parameters (may be <code>null</code>
|
||||
* if not specified)
|
||||
*/
|
||||
AlgorithmParameterSpec getParameterSpec();
|
||||
|
||||
/**
|
||||
* Transforms the specified data using the underlying transform algorithm.
|
||||
*
|
||||
* @param data the data to be transformed
|
||||
* @param context the <code>XMLCryptoContext</code> containing
|
||||
* additional context (may be <code>null</code> if not applicable)
|
||||
* @return the transformed data
|
||||
* @throws NullPointerException if <code>data</code> is <code>null</code>
|
||||
* @throws TransformException if an error occurs while executing the
|
||||
* transform
|
||||
*/
|
||||
public abstract Data transform(Data data, XMLCryptoContext context)
|
||||
throws TransformException;
|
||||
|
||||
/**
|
||||
* Transforms the specified data using the underlying transform algorithm.
|
||||
* If the output of this transform is an <code>OctetStreamData</code>, then
|
||||
* this method returns <code>null</code> and the bytes are written to the
|
||||
* specified <code>OutputStream</code>. Otherwise, the
|
||||
* <code>OutputStream</code> is ignored and the method behaves as if
|
||||
* {@link #transform(Data, XMLCryptoContext)} were invoked.
|
||||
*
|
||||
* @param data the data to be transformed
|
||||
* @param context the <code>XMLCryptoContext</code> containing
|
||||
* additional context (may be <code>null</code> if not applicable)
|
||||
* @param os the <code>OutputStream</code> that should be used to write
|
||||
* the transformed data to
|
||||
* @return the transformed data (or <code>null</code> if the data was
|
||||
* written to the <code>OutputStream</code> parameter)
|
||||
* @throws NullPointerException if <code>data</code> or <code>os</code>
|
||||
* is <code>null</code>
|
||||
* @throws TransformException if an error occurs while executing the
|
||||
* transform
|
||||
*/
|
||||
public abstract Data transform
|
||||
(Data data, XMLCryptoContext context, OutputStream os)
|
||||
throws TransformException;
|
||||
}
|
||||
156
jdkSrc/jdk8/javax/xml/crypto/dsig/TransformException.java
Normal file
156
jdkSrc/jdk8/javax/xml/crypto/dsig/TransformException.java
Normal file
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: TransformException.java,v 1.3 2005/05/10 16:03:48 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
/**
|
||||
* Indicates an exceptional condition that occurred while executing a
|
||||
* transform algorithm.
|
||||
*
|
||||
* <p>A {@code TransformException} can contain a cause: another
|
||||
* throwable that caused this {@code TransformException} to get thrown.
|
||||
*
|
||||
* @see Transform#transform
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
*/
|
||||
public class TransformException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 5082634801360427800L;
|
||||
|
||||
/**
|
||||
* The throwable that caused this exception to get thrown, or null if this
|
||||
* exception was not caused by another throwable or if the causative
|
||||
* throwable is unknown.
|
||||
*
|
||||
* @serial
|
||||
*/
|
||||
private Throwable cause;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code TransformException} with
|
||||
* {@code null} as its detail message.
|
||||
*/
|
||||
public TransformException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@code TransformException} with the specified
|
||||
* detail message.
|
||||
*
|
||||
* @param message the detail message
|
||||
*/
|
||||
public TransformException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@code TransformException} with the
|
||||
* specified detail message and cause.
|
||||
* <p>Note that the detail message associated with
|
||||
* {@code cause} is <i>not</i> automatically incorporated in
|
||||
* this exception's detail message.
|
||||
*
|
||||
* @param message the detail message
|
||||
* @param cause the cause (A {@code null} value is permitted, and
|
||||
* indicates that the cause is nonexistent or unknown.)
|
||||
*/
|
||||
public TransformException(String message, Throwable cause) {
|
||||
super(message);
|
||||
this.cause = cause;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@code TransformException} with the specified
|
||||
* cause and a detail message of
|
||||
* {@code (cause==null ? null : cause.toString())}
|
||||
* (which typically contains the class and detail message of
|
||||
* {@code cause}).
|
||||
*
|
||||
* @param cause the cause (A {@code null} value is permitted, and
|
||||
* indicates that the cause is nonexistent or unknown.)
|
||||
*/
|
||||
public TransformException(Throwable cause) {
|
||||
super(cause==null ? null : cause.toString());
|
||||
this.cause = cause;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the cause of this {@code TransformException} or
|
||||
* {@code null} if the cause is nonexistent or unknown. (The
|
||||
* cause is the throwable that caused this
|
||||
* {@code TransformException} to get thrown.)
|
||||
*
|
||||
* @return the cause of this {@code TransformException} or
|
||||
* {@code null} if the cause is nonexistent or unknown.
|
||||
*/
|
||||
public Throwable getCause() {
|
||||
return cause;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints this {@code TransformException}, its backtrace and
|
||||
* the cause's backtrace to the standard error stream.
|
||||
*/
|
||||
public void printStackTrace() {
|
||||
super.printStackTrace();
|
||||
if (cause != null) {
|
||||
cause.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints this {@code TransformException}, its backtrace and
|
||||
* the cause's backtrace to the specified print stream.
|
||||
*
|
||||
* @param s {@code PrintStream} to use for output
|
||||
*/
|
||||
public void printStackTrace(PrintStream s) {
|
||||
super.printStackTrace(s);
|
||||
if (cause != null) {
|
||||
cause.printStackTrace(s);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints this {@code TransformException}, its backtrace and
|
||||
* the cause's backtrace to the specified print writer.
|
||||
*
|
||||
* @param s {@code PrintWriter} to use for output
|
||||
*/
|
||||
public void printStackTrace(PrintWriter s) {
|
||||
super.printStackTrace(s);
|
||||
if (cause != null) {
|
||||
cause.printStackTrace(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
393
jdkSrc/jdk8/javax/xml/crypto/dsig/TransformService.java
Normal file
393
jdkSrc/jdk8/javax/xml/crypto/dsig/TransformService.java
Normal file
@@ -0,0 +1,393 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: TransformService.java,v 1.6.4.1 2005/09/15 12:42:11 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig;
|
||||
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.NoSuchProviderException;
|
||||
import java.security.Provider;
|
||||
import java.security.Provider.Service;
|
||||
import java.security.Security;
|
||||
import java.util.*;
|
||||
import javax.xml.crypto.MarshalException;
|
||||
import javax.xml.crypto.XMLStructure;
|
||||
import javax.xml.crypto.XMLCryptoContext;
|
||||
import javax.xml.crypto.dsig.spec.TransformParameterSpec;
|
||||
|
||||
import sun.security.jca.*;
|
||||
import sun.security.jca.GetInstance.Instance;
|
||||
|
||||
/**
|
||||
* A Service Provider Interface for transform and canonicalization algorithms.
|
||||
*
|
||||
* <p>Each instance of <code>TransformService</code> supports a specific
|
||||
* transform or canonicalization algorithm and XML mechanism type. To create a
|
||||
* <code>TransformService</code>, call one of the static
|
||||
* {@link #getInstance getInstance} methods, passing in the algorithm URI and
|
||||
* XML mechanism type desired, for example:
|
||||
*
|
||||
* <blockquote><code>
|
||||
* TransformService ts = TransformService.getInstance(Transform.XPATH2, "DOM");
|
||||
* </code></blockquote>
|
||||
*
|
||||
* <p><code>TransformService</code> implementations are registered and loaded
|
||||
* using the {@link java.security.Provider} mechanism. Each
|
||||
* <code>TransformService</code> service provider implementation should include
|
||||
* a <code>MechanismType</code> service attribute that identifies the XML
|
||||
* mechanism type that it supports. If the attribute is not specified,
|
||||
* "DOM" is assumed. For example, a service provider that supports the
|
||||
* XPath Filter 2 Transform and DOM mechanism would be specified in the
|
||||
* <code>Provider</code> subclass as:
|
||||
* <pre>
|
||||
* put("TransformService." + Transform.XPATH2,
|
||||
* "org.example.XPath2TransformService");
|
||||
* put("TransformService." + Transform.XPATH2 + " MechanismType", "DOM");
|
||||
* </pre>
|
||||
* <code>TransformService</code> implementations that support the DOM
|
||||
* mechanism type must abide by the DOM interoperability requirements defined
|
||||
* in the
|
||||
* <a href="../../../../../technotes/guides/security/xmldsig/overview.html#DOM Mechanism Requirements">
|
||||
* DOM Mechanism Requirements</a> section of the API overview. See the
|
||||
* <a href="../../../../../technotes/guides/security/xmldsig/overview.html#Service Provider">
|
||||
* Service Providers</a> section of the API overview for a list of standard
|
||||
* mechanism types.
|
||||
* <p>
|
||||
* Once a <code>TransformService</code> has been created, it can be used
|
||||
* to process <code>Transform</code> or <code>CanonicalizationMethod</code>
|
||||
* objects. If the <code>Transform</code> or <code>CanonicalizationMethod</code>
|
||||
* exists in XML form (for example, when validating an existing
|
||||
* <code>XMLSignature</code>), the {@link #init(XMLStructure, XMLCryptoContext)}
|
||||
* method must be first called to initialize the transform and provide document
|
||||
* context (even if there are no parameters). Alternatively, if the
|
||||
* <code>Transform</code> or <code>CanonicalizationMethod</code> is being
|
||||
* created from scratch, the {@link #init(TransformParameterSpec)} method
|
||||
* is called to initialize the transform with parameters and the
|
||||
* {@link #marshalParams marshalParams} method is called to marshal the
|
||||
* parameters to XML and provide the transform with document context. Finally,
|
||||
* the {@link #transform transform} method is called to perform the
|
||||
* transformation.
|
||||
* <p>
|
||||
* <b>Concurrent Access</b>
|
||||
* <p>The static methods of this class are guaranteed to be thread-safe.
|
||||
* Multiple threads may concurrently invoke the static methods defined in this
|
||||
* class with no ill effects.
|
||||
*
|
||||
* <p>However, this is not true for the non-static methods defined by this
|
||||
* class. Unless otherwise documented by a specific provider, threads that
|
||||
* need to access a single <code>TransformService</code> instance
|
||||
* concurrently should synchronize amongst themselves and provide the
|
||||
* necessary locking. Multiple threads each manipulating a different
|
||||
* <code>TransformService</code> instance need not synchronize.
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
*/
|
||||
public abstract class TransformService implements Transform {
|
||||
|
||||
private String algorithm;
|
||||
private String mechanism;
|
||||
private Provider provider;
|
||||
|
||||
/**
|
||||
* Default constructor, for invocation by subclasses.
|
||||
*/
|
||||
protected TransformService() {}
|
||||
|
||||
/**
|
||||
* Returns a <code>TransformService</code> that supports the specified
|
||||
* algorithm URI (ex: {@link Transform#XPATH2}) and mechanism type
|
||||
* (ex: DOM).
|
||||
*
|
||||
* <p>This method uses the standard JCA provider lookup mechanism to
|
||||
* locate and instantiate a <code>TransformService</code> implementation
|
||||
* of the desired algorithm and <code>MechanismType</code> service
|
||||
* attribute. It traverses the list of registered security
|
||||
* <code>Provider</code>s, starting with the most preferred
|
||||
* <code>Provider</code>. A new <code>TransformService</code> object
|
||||
* from the first <code>Provider</code> that supports the specified
|
||||
* algorithm and mechanism type is returned.
|
||||
*
|
||||
* <p> Note that the list of registered providers may be retrieved via
|
||||
* the {@link Security#getProviders() Security.getProviders()} method.
|
||||
*
|
||||
* @param algorithm the URI of the algorithm
|
||||
* @param mechanismType the type of the XML processing mechanism and
|
||||
* representation
|
||||
* @return a new <code>TransformService</code>
|
||||
* @throws NullPointerException if <code>algorithm</code> or
|
||||
* <code>mechanismType</code> is <code>null</code>
|
||||
* @throws NoSuchAlgorithmException if no <code>Provider</code> supports a
|
||||
* <code>TransformService</code> implementation for the specified
|
||||
* algorithm and mechanism type
|
||||
* @see Provider
|
||||
*/
|
||||
public static TransformService getInstance
|
||||
(String algorithm, String mechanismType)
|
||||
throws NoSuchAlgorithmException {
|
||||
if (mechanismType == null || algorithm == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
boolean dom = false;
|
||||
if (mechanismType.equals("DOM")) {
|
||||
dom = true;
|
||||
}
|
||||
List<Service> services = GetInstance.getServices("TransformService", algorithm);
|
||||
for (Iterator<Service> t = services.iterator(); t.hasNext(); ) {
|
||||
Service s = t.next();
|
||||
String value = s.getAttribute("MechanismType");
|
||||
if ((value == null && dom) ||
|
||||
(value != null && value.equals(mechanismType))) {
|
||||
Instance instance = GetInstance.getInstance(s, null);
|
||||
TransformService ts = (TransformService) instance.impl;
|
||||
ts.algorithm = algorithm;
|
||||
ts.mechanism = mechanismType;
|
||||
ts.provider = instance.provider;
|
||||
return ts;
|
||||
}
|
||||
}
|
||||
throw new NoSuchAlgorithmException
|
||||
(algorithm + " algorithm and " + mechanismType
|
||||
+ " mechanism not available");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a <code>TransformService</code> that supports the specified
|
||||
* algorithm URI (ex: {@link Transform#XPATH2}) and mechanism type
|
||||
* (ex: DOM) as supplied by the specified provider. Note that the specified
|
||||
* <code>Provider</code> object does not have to be registered in the
|
||||
* provider list.
|
||||
*
|
||||
* @param algorithm the URI of the algorithm
|
||||
* @param mechanismType the type of the XML processing mechanism and
|
||||
* representation
|
||||
* @param provider the <code>Provider</code> object
|
||||
* @return a new <code>TransformService</code>
|
||||
* @throws NullPointerException if <code>provider</code>,
|
||||
* <code>algorithm</code>, or <code>mechanismType</code> is
|
||||
* <code>null</code>
|
||||
* @throws NoSuchAlgorithmException if a <code>TransformService</code>
|
||||
* implementation for the specified algorithm and mechanism type is not
|
||||
* available from the specified <code>Provider</code> object
|
||||
* @see Provider
|
||||
*/
|
||||
public static TransformService getInstance
|
||||
(String algorithm, String mechanismType, Provider provider)
|
||||
throws NoSuchAlgorithmException {
|
||||
if (mechanismType == null || algorithm == null || provider == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
boolean dom = false;
|
||||
if (mechanismType.equals("DOM")) {
|
||||
dom = true;
|
||||
}
|
||||
Service s = GetInstance.getService
|
||||
("TransformService", algorithm, provider);
|
||||
String value = s.getAttribute("MechanismType");
|
||||
if ((value == null && dom) ||
|
||||
(value != null && value.equals(mechanismType))) {
|
||||
Instance instance = GetInstance.getInstance(s, null);
|
||||
TransformService ts = (TransformService) instance.impl;
|
||||
ts.algorithm = algorithm;
|
||||
ts.mechanism = mechanismType;
|
||||
ts.provider = instance.provider;
|
||||
return ts;
|
||||
}
|
||||
throw new NoSuchAlgorithmException
|
||||
(algorithm + " algorithm and " + mechanismType
|
||||
+ " mechanism not available");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a <code>TransformService</code> that supports the specified
|
||||
* algorithm URI (ex: {@link Transform#XPATH2}) and mechanism type
|
||||
* (ex: DOM) as supplied by the specified provider. The specified provider
|
||||
* must be registered in the security provider list.
|
||||
*
|
||||
* <p>Note that the list of registered providers may be retrieved via
|
||||
* the {@link Security#getProviders() Security.getProviders()} method.
|
||||
*
|
||||
* @param algorithm the URI of the algorithm
|
||||
* @param mechanismType the type of the XML processing mechanism and
|
||||
* representation
|
||||
* @param provider the string name of the provider
|
||||
* @return a new <code>TransformService</code>
|
||||
* @throws NoSuchProviderException if the specified provider is not
|
||||
* registered in the security provider list
|
||||
* @throws NullPointerException if <code>provider</code>,
|
||||
* <code>mechanismType</code>, or <code>algorithm</code> is
|
||||
* <code>null</code>
|
||||
* @throws NoSuchAlgorithmException if a <code>TransformService</code>
|
||||
* implementation for the specified algorithm and mechanism type is not
|
||||
* available from the specified provider
|
||||
* @see Provider
|
||||
*/
|
||||
public static TransformService getInstance
|
||||
(String algorithm, String mechanismType, String provider)
|
||||
throws NoSuchAlgorithmException, NoSuchProviderException {
|
||||
if (mechanismType == null || algorithm == null || provider == null) {
|
||||
throw new NullPointerException();
|
||||
} else if (provider.length() == 0) {
|
||||
throw new NoSuchProviderException();
|
||||
}
|
||||
boolean dom = false;
|
||||
if (mechanismType.equals("DOM")) {
|
||||
dom = true;
|
||||
}
|
||||
Service s = GetInstance.getService
|
||||
("TransformService", algorithm, provider);
|
||||
String value = s.getAttribute("MechanismType");
|
||||
if ((value == null && dom) ||
|
||||
(value != null && value.equals(mechanismType))) {
|
||||
Instance instance = GetInstance.getInstance(s, null);
|
||||
TransformService ts = (TransformService) instance.impl;
|
||||
ts.algorithm = algorithm;
|
||||
ts.mechanism = mechanismType;
|
||||
ts.provider = instance.provider;
|
||||
return ts;
|
||||
}
|
||||
throw new NoSuchAlgorithmException
|
||||
(algorithm + " algorithm and " + mechanismType
|
||||
+ " mechanism not available");
|
||||
}
|
||||
|
||||
private static class MechanismMapEntry implements Map.Entry<String,String> {
|
||||
private final String mechanism;
|
||||
private final String algorithm;
|
||||
private final String key;
|
||||
MechanismMapEntry(String algorithm, String mechanism) {
|
||||
this.algorithm = algorithm;
|
||||
this.mechanism = mechanism;
|
||||
this.key = "TransformService." + algorithm + " MechanismType";
|
||||
}
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof Map.Entry)) {
|
||||
return false;
|
||||
}
|
||||
Map.Entry<?,?> e = (Map.Entry<?,?>) o;
|
||||
return (getKey()==null ?
|
||||
e.getKey()==null : getKey().equals(e.getKey())) &&
|
||||
(getValue()==null ?
|
||||
e.getValue()==null : getValue().equals(e.getValue()));
|
||||
}
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
public String getValue() {
|
||||
return mechanism;
|
||||
}
|
||||
public String setValue(String value) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
public int hashCode() {
|
||||
return (getKey()==null ? 0 : getKey().hashCode()) ^
|
||||
(getValue()==null ? 0 : getValue().hashCode());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the mechanism type supported by this <code>TransformService</code>.
|
||||
*
|
||||
* @return the mechanism type
|
||||
*/
|
||||
public final String getMechanismType() {
|
||||
return mechanism;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the URI of the algorithm supported by this
|
||||
* <code>TransformService</code>.
|
||||
*
|
||||
* @return the algorithm URI
|
||||
*/
|
||||
public final String getAlgorithm() {
|
||||
return algorithm;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the provider of this <code>TransformService</code>.
|
||||
*
|
||||
* @return the provider
|
||||
*/
|
||||
public final Provider getProvider() {
|
||||
return provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes this <code>TransformService</code> with the specified
|
||||
* parameters.
|
||||
*
|
||||
* <p>If the parameters exist in XML form, the
|
||||
* {@link #init(XMLStructure, XMLCryptoContext)} method should be used to
|
||||
* initialize the <code>TransformService</code>.
|
||||
*
|
||||
* @param params the algorithm parameters (may be <code>null</code> if
|
||||
* not required or optional)
|
||||
* @throws InvalidAlgorithmParameterException if the specified parameters
|
||||
* are invalid for this algorithm
|
||||
*/
|
||||
public abstract void init(TransformParameterSpec params)
|
||||
throws InvalidAlgorithmParameterException;
|
||||
|
||||
/**
|
||||
* Marshals the algorithm-specific parameters. If there are no parameters
|
||||
* to be marshalled, this method returns without throwing an exception.
|
||||
*
|
||||
* @param parent a mechanism-specific structure containing the parent
|
||||
* node that the marshalled parameters should be appended to
|
||||
* @param context the <code>XMLCryptoContext</code> containing
|
||||
* additional context (may be <code>null</code> if not applicable)
|
||||
* @throws ClassCastException if the type of <code>parent</code> or
|
||||
* <code>context</code> is not compatible with this
|
||||
* <code>TransformService</code>
|
||||
* @throws NullPointerException if <code>parent</code> is <code>null</code>
|
||||
* @throws MarshalException if the parameters cannot be marshalled
|
||||
*/
|
||||
public abstract void marshalParams
|
||||
(XMLStructure parent, XMLCryptoContext context)
|
||||
throws MarshalException;
|
||||
|
||||
/**
|
||||
* Initializes this <code>TransformService</code> with the specified
|
||||
* parameters and document context.
|
||||
*
|
||||
* @param parent a mechanism-specific structure containing the parent
|
||||
* structure
|
||||
* @param context the <code>XMLCryptoContext</code> containing
|
||||
* additional context (may be <code>null</code> if not applicable)
|
||||
* @throws ClassCastException if the type of <code>parent</code> or
|
||||
* <code>context</code> is not compatible with this
|
||||
* <code>TransformService</code>
|
||||
* @throws NullPointerException if <code>parent</code> is <code>null</code>
|
||||
* @throws InvalidAlgorithmParameterException if the specified parameters
|
||||
* are invalid for this algorithm
|
||||
*/
|
||||
public abstract void init(XMLStructure parent, XMLCryptoContext context)
|
||||
throws InvalidAlgorithmParameterException;
|
||||
}
|
||||
129
jdkSrc/jdk8/javax/xml/crypto/dsig/XMLObject.java
Normal file
129
jdkSrc/jdk8/javax/xml/crypto/dsig/XMLObject.java
Normal file
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* ===========================================================================
|
||||
*
|
||||
* (C) Copyright IBM Corp. 2003 All Rights Reserved.
|
||||
*
|
||||
* ===========================================================================
|
||||
*/
|
||||
/*
|
||||
* $Id: XMLObject.java,v 1.5 2005/05/10 16:03:48 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig;
|
||||
|
||||
import java.util.List;
|
||||
import javax.xml.crypto.XMLStructure;
|
||||
|
||||
/**
|
||||
* A representation of the XML <code>Object</code> element as defined in
|
||||
* the <a href="http://www.w3.org/TR/xmldsig-core/">
|
||||
* W3C Recommendation for XML-Signature Syntax and Processing</a>.
|
||||
* An <code>XMLObject</code> may contain any data and may include optional
|
||||
* MIME type, ID, and encoding attributes. The XML Schema Definition is
|
||||
* defined as:
|
||||
*
|
||||
* <pre><code>
|
||||
* <element name="Object" type="ds:ObjectType"/>
|
||||
* <complexType name="ObjectType" mixed="true">
|
||||
* <sequence minOccurs="0" maxOccurs="unbounded">
|
||||
* <any namespace="##any" processContents="lax"/>
|
||||
* </sequence>
|
||||
* <attribute name="Id" type="ID" use="optional"/>
|
||||
* <attribute name="MimeType" type="string" use="optional"/>
|
||||
* <attribute name="Encoding" type="anyURI" use="optional"/>
|
||||
* </complexType>
|
||||
* </code></pre>
|
||||
*
|
||||
* A <code>XMLObject</code> instance may be created by invoking the
|
||||
* {@link XMLSignatureFactory#newXMLObject newXMLObject} method of the
|
||||
* {@link XMLSignatureFactory} class; for example:
|
||||
*
|
||||
* <pre>
|
||||
* XMLSignatureFactory fac = XMLSignatureFactory.getInstance("DOM");
|
||||
* List content = Collections.singletonList(fac.newManifest(references)));
|
||||
* XMLObject object = factory.newXMLObject(content, "object-1", null, null);
|
||||
* </pre>
|
||||
*
|
||||
* <p>Note that this class is named <code>XMLObject</code> rather than
|
||||
* <code>Object</code> to avoid naming clashes with the existing
|
||||
* {@link java.lang.Object java.lang.Object} class.
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @author Joyce L. Leung
|
||||
* @since 1.6
|
||||
* @see XMLSignatureFactory#newXMLObject(List, String, String, String)
|
||||
*/
|
||||
public interface XMLObject extends XMLStructure {
|
||||
|
||||
/**
|
||||
* URI that identifies the <code>Object</code> element (this can be
|
||||
* specified as the value of the <code>type</code> parameter of the
|
||||
* {@link Reference} class to identify the referent's type).
|
||||
*/
|
||||
final static String TYPE = "http://www.w3.org/2000/09/xmldsig#Object";
|
||||
|
||||
/**
|
||||
* Returns an {@link java.util.Collections#unmodifiableList unmodifiable
|
||||
* list} of {@link XMLStructure}s contained in this <code>XMLObject</code>,
|
||||
* which represent elements from any namespace.
|
||||
*
|
||||
*<p>If there is a public subclass representing the type of
|
||||
* <code>XMLStructure</code>, it is returned as an instance of that class
|
||||
* (ex: a <code>SignatureProperties</code> element would be returned
|
||||
* as an instance of {@link javax.xml.crypto.dsig.SignatureProperties}).
|
||||
*
|
||||
* @return an unmodifiable list of <code>XMLStructure</code>s (may be empty
|
||||
* but never <code>null</code>)
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
List getContent();
|
||||
|
||||
/**
|
||||
* Returns the Id of this <code>XMLObject</code>.
|
||||
*
|
||||
* @return the Id (or <code>null</code> if not specified)
|
||||
*/
|
||||
String getId();
|
||||
|
||||
/**
|
||||
* Returns the mime type of this <code>XMLObject</code>. The
|
||||
* mime type is an optional attribute which describes the data within this
|
||||
* <code>XMLObject</code> (independent of its encoding).
|
||||
*
|
||||
* @return the mime type (or <code>null</code> if not specified)
|
||||
*/
|
||||
String getMimeType();
|
||||
|
||||
/**
|
||||
* Returns the encoding URI of this <code>XMLObject</code>. The encoding
|
||||
* URI identifies the method by which the object is encoded.
|
||||
*
|
||||
* @return the encoding URI (or <code>null</code> if not specified)
|
||||
*/
|
||||
String getEncoding();
|
||||
}
|
||||
63
jdkSrc/jdk8/javax/xml/crypto/dsig/XMLSignContext.java
Normal file
63
jdkSrc/jdk8/javax/xml/crypto/dsig/XMLSignContext.java
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: XMLSignContext.java,v 1.8 2005/05/10 16:03:48 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig;
|
||||
|
||||
import javax.xml.crypto.KeySelector;
|
||||
import javax.xml.crypto.XMLCryptoContext;
|
||||
|
||||
/**
|
||||
* Contains context information for generating XML Signatures. This interface
|
||||
* is primarily intended for type-safety.
|
||||
*
|
||||
* <p>Note that <code>XMLSignContext</code> instances can contain
|
||||
* information and state specific to the XML signature structure it is
|
||||
* used with. The results are unpredictable if an
|
||||
* <code>XMLSignContext</code> is used with different signature structures
|
||||
* (for example, you should not use the same <code>XMLSignContext</code>
|
||||
* instance to sign two different {@link XMLSignature} objects).
|
||||
* <p>
|
||||
* <b><a name="Supported Properties"></a>Supported Properties</b>
|
||||
* <p>The following properties can be set using the
|
||||
* {@link #setProperty setProperty} method.
|
||||
* <ul>
|
||||
* <li><code>javax.xml.crypto.dsig.cacheReference</code>: value must be a
|
||||
* {@link Boolean}. This property controls whether or not the digested
|
||||
* {@link Reference} objects will cache the dereferenced content and
|
||||
* pre-digested input for subsequent retrieval via the
|
||||
* {@link Reference#getDereferencedData Reference.getDereferencedData} and
|
||||
* {@link Reference#getDigestInputStream Reference.getDigestInputStream}
|
||||
* methods. The default value if not specified is
|
||||
* <code>Boolean.FALSE</code>.
|
||||
* </ul>
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
* @see XMLSignature#sign(XMLSignContext)
|
||||
*/
|
||||
public interface XMLSignContext extends XMLCryptoContext {}
|
||||
246
jdkSrc/jdk8/javax/xml/crypto/dsig/XMLSignature.java
Normal file
246
jdkSrc/jdk8/javax/xml/crypto/dsig/XMLSignature.java
Normal file
@@ -0,0 +1,246 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* ===========================================================================
|
||||
*
|
||||
* (C) Copyright IBM Corp. 2003 All Rights Reserved.
|
||||
*
|
||||
* ===========================================================================
|
||||
*/
|
||||
/*
|
||||
* $Id: XMLSignature.java,v 1.10 2005/05/10 16:03:48 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig;
|
||||
|
||||
import javax.xml.crypto.KeySelector;
|
||||
import javax.xml.crypto.KeySelectorResult;
|
||||
import javax.xml.crypto.MarshalException;
|
||||
import javax.xml.crypto.XMLStructure;
|
||||
import javax.xml.crypto.dsig.keyinfo.KeyInfo;
|
||||
import java.security.Signature;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A representation of the XML <code>Signature</code> element as
|
||||
* defined in the <a href="http://www.w3.org/TR/xmldsig-core/">
|
||||
* W3C Recommendation for XML-Signature Syntax and Processing</a>.
|
||||
* This class contains methods for signing and validating XML signatures
|
||||
* with behavior as defined by the W3C specification. The XML Schema Definition
|
||||
* is defined as:
|
||||
* <pre><code>
|
||||
* <element name="Signature" type="ds:SignatureType"/>
|
||||
* <complexType name="SignatureType">
|
||||
* <sequence>
|
||||
* <element ref="ds:SignedInfo"/>
|
||||
* <element ref="ds:SignatureValue"/>
|
||||
* <element ref="ds:KeyInfo" minOccurs="0"/>
|
||||
* <element ref="ds:Object" minOccurs="0" maxOccurs="unbounded"/>
|
||||
* </sequence>
|
||||
* <attribute name="Id" type="ID" use="optional"/>
|
||||
* </complexType>
|
||||
* </code></pre>
|
||||
* <p>
|
||||
* An <code>XMLSignature</code> instance may be created by invoking one of the
|
||||
* {@link XMLSignatureFactory#newXMLSignature newXMLSignature} methods of the
|
||||
* {@link XMLSignatureFactory} class.
|
||||
*
|
||||
* <p>If the contents of the underlying document containing the
|
||||
* <code>XMLSignature</code> are subsequently modified, the behavior is
|
||||
* undefined.
|
||||
*
|
||||
* <p>Note that this class is named <code>XMLSignature</code> rather than
|
||||
* <code>Signature</code> to avoid naming clashes with the existing
|
||||
* {@link Signature java.security.Signature} class.
|
||||
*
|
||||
* @see XMLSignatureFactory#newXMLSignature(SignedInfo, KeyInfo)
|
||||
* @see XMLSignatureFactory#newXMLSignature(SignedInfo, KeyInfo, List, String, String)
|
||||
* @author Joyce L. Leung
|
||||
* @author Sean Mullan
|
||||
* @author Erwin van der Koogh
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
*/
|
||||
public interface XMLSignature extends XMLStructure {
|
||||
|
||||
/**
|
||||
* The XML Namespace URI of the W3C Recommendation for XML-Signature
|
||||
* Syntax and Processing.
|
||||
*/
|
||||
final static String XMLNS = "http://www.w3.org/2000/09/xmldsig#";
|
||||
|
||||
/**
|
||||
* Validates the signature according to the
|
||||
* <a href="http://www.w3.org/TR/xmldsig-core/#sec-CoreValidation">
|
||||
* core validation processing rules</a>. This method validates the
|
||||
* signature using the existing state, it does not unmarshal and
|
||||
* reinitialize the contents of the <code>XMLSignature</code> using the
|
||||
* location information specified in the context.
|
||||
*
|
||||
* <p>This method only validates the signature the first time it is
|
||||
* invoked. On subsequent invocations, it returns a cached result.
|
||||
*
|
||||
* @param validateContext the validating context
|
||||
* @return <code>true</code> if the signature passed core validation,
|
||||
* otherwise <code>false</code>
|
||||
* @throws ClassCastException if the type of <code>validateContext</code>
|
||||
* is not compatible with this <code>XMLSignature</code>
|
||||
* @throws NullPointerException if <code>validateContext</code> is
|
||||
* <code>null</code>
|
||||
* @throws XMLSignatureException if an unexpected error occurs during
|
||||
* validation that prevented the validation operation from completing
|
||||
*/
|
||||
boolean validate(XMLValidateContext validateContext)
|
||||
throws XMLSignatureException;
|
||||
|
||||
/**
|
||||
* Returns the key info of this <code>XMLSignature</code>.
|
||||
*
|
||||
* @return the key info (may be <code>null</code> if not specified)
|
||||
*/
|
||||
KeyInfo getKeyInfo();
|
||||
|
||||
/**
|
||||
* Returns the signed info of this <code>XMLSignature</code>.
|
||||
*
|
||||
* @return the signed info (never <code>null</code>)
|
||||
*/
|
||||
SignedInfo getSignedInfo();
|
||||
|
||||
/**
|
||||
* Returns an {@link java.util.Collections#unmodifiableList unmodifiable
|
||||
* list} of {@link XMLObject}s contained in this <code>XMLSignature</code>.
|
||||
*
|
||||
* @return an unmodifiable list of <code>XMLObject</code>s (may be empty
|
||||
* but never <code>null</code>)
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
List getObjects();
|
||||
|
||||
/**
|
||||
* Returns the optional Id of this <code>XMLSignature</code>.
|
||||
*
|
||||
* @return the Id (may be <code>null</code> if not specified)
|
||||
*/
|
||||
String getId();
|
||||
|
||||
/**
|
||||
* Returns the signature value of this <code>XMLSignature</code>.
|
||||
*
|
||||
* @return the signature value
|
||||
*/
|
||||
SignatureValue getSignatureValue();
|
||||
|
||||
/**
|
||||
* Signs this <code>XMLSignature</code>.
|
||||
*
|
||||
* <p>If this method throws an exception, this <code>XMLSignature</code> and
|
||||
* the <code>signContext</code> parameter will be left in the state that
|
||||
* it was in prior to the invocation.
|
||||
*
|
||||
* @param signContext the signing context
|
||||
* @throws ClassCastException if the type of <code>signContext</code> is
|
||||
* not compatible with this <code>XMLSignature</code>
|
||||
* @throws NullPointerException if <code>signContext</code> is
|
||||
* <code>null</code>
|
||||
* @throws MarshalException if an exception occurs while marshalling
|
||||
* @throws XMLSignatureException if an unexpected exception occurs while
|
||||
* generating the signature
|
||||
*/
|
||||
void sign(XMLSignContext signContext) throws MarshalException,
|
||||
XMLSignatureException;
|
||||
|
||||
/**
|
||||
* Returns the result of the {@link KeySelector}, if specified, after
|
||||
* this <code>XMLSignature</code> has been signed or validated.
|
||||
*
|
||||
* @return the key selector result, or <code>null</code> if a key
|
||||
* selector has not been specified or this <code>XMLSignature</code>
|
||||
* has not been signed or validated
|
||||
*/
|
||||
KeySelectorResult getKeySelectorResult();
|
||||
|
||||
/**
|
||||
* A representation of the XML <code>SignatureValue</code> element as
|
||||
* defined in the <a href="http://www.w3.org/TR/xmldsig-core/">
|
||||
* W3C Recommendation for XML-Signature Syntax and Processing</a>.
|
||||
* The XML Schema Definition is defined as:
|
||||
* <p>
|
||||
* <pre>
|
||||
* <element name="SignatureValue" type="ds:SignatureValueType"/>
|
||||
* <complexType name="SignatureValueType">
|
||||
* <simpleContent>
|
||||
* <extension base="base64Binary">
|
||||
* <attribute name="Id" type="ID" use="optional"/>
|
||||
* </extension>
|
||||
* </simpleContent>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
*/
|
||||
public interface SignatureValue extends XMLStructure {
|
||||
/**
|
||||
* Returns the optional <code>Id</code> attribute of this
|
||||
* <code>SignatureValue</code>, which permits this element to be
|
||||
* referenced from elsewhere.
|
||||
*
|
||||
* @return the <code>Id</code> attribute (may be <code>null</code> if
|
||||
* not specified)
|
||||
*/
|
||||
String getId();
|
||||
|
||||
/**
|
||||
* Returns the signature value of this <code>SignatureValue</code>.
|
||||
*
|
||||
* @return the signature value (may be <code>null</code> if the
|
||||
* <code>XMLSignature</code> has not been signed yet). Each
|
||||
* invocation of this method returns a new clone of the array to
|
||||
* prevent subsequent modification.
|
||||
*/
|
||||
byte[] getValue();
|
||||
|
||||
/**
|
||||
* Validates the signature value. This method performs a
|
||||
* cryptographic validation of the signature calculated over the
|
||||
* <code>SignedInfo</code> of the <code>XMLSignature</code>.
|
||||
*
|
||||
* <p>This method only validates the signature the first
|
||||
* time it is invoked. On subsequent invocations, it returns a cached
|
||||
* result.
|
||||
*
|
||||
* @return <code>true</code> if the signature was
|
||||
* validated successfully; <code>false</code> otherwise
|
||||
* @param validateContext the validating context
|
||||
* @throws NullPointerException if <code>validateContext</code> is
|
||||
* <code>null</code>
|
||||
* @throws XMLSignatureException if an unexpected exception occurs while
|
||||
* validating the signature
|
||||
*/
|
||||
boolean validate(XMLValidateContext validateContext)
|
||||
throws XMLSignatureException;
|
||||
}
|
||||
}
|
||||
153
jdkSrc/jdk8/javax/xml/crypto/dsig/XMLSignatureException.java
Normal file
153
jdkSrc/jdk8/javax/xml/crypto/dsig/XMLSignatureException.java
Normal file
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: XMLSignatureException.java,v 1.5 2005/05/10 16:03:48 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
/**
|
||||
* Indicates an exceptional condition that occurred during the XML
|
||||
* signature generation or validation process.
|
||||
*
|
||||
* <p>An {@code XMLSignatureException} can contain a cause: another
|
||||
* throwable that caused this {@code XMLSignatureException} to get thrown.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public class XMLSignatureException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -3438102491013869995L;
|
||||
|
||||
/**
|
||||
* The throwable that caused this exception to get thrown, or null if this
|
||||
* exception was not caused by another throwable or if the causative
|
||||
* throwable is unknown.
|
||||
*
|
||||
* @serial
|
||||
*/
|
||||
private Throwable cause;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code XMLSignatureException} with
|
||||
* {@code null} as its detail message.
|
||||
*/
|
||||
public XMLSignatureException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@code XMLSignatureException} with the specified
|
||||
* detail message.
|
||||
*
|
||||
* @param message the detail message
|
||||
*/
|
||||
public XMLSignatureException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@code XMLSignatureException} with the
|
||||
* specified detail message and cause.
|
||||
* <p>Note that the detail message associated with
|
||||
* {@code cause} is <i>not</i> automatically incorporated in
|
||||
* this exception's detail message.
|
||||
*
|
||||
* @param message the detail message
|
||||
* @param cause the cause (A {@code null} value is permitted, and
|
||||
* indicates that the cause is nonexistent or unknown.)
|
||||
*/
|
||||
public XMLSignatureException(String message, Throwable cause) {
|
||||
super(message);
|
||||
this.cause = cause;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@code XMLSignatureException} with the specified
|
||||
* cause and a detail message of
|
||||
* {@code (cause==null ? null : cause.toString())}
|
||||
* (which typically contains the class and detail message of
|
||||
* {@code cause}).
|
||||
*
|
||||
* @param cause the cause (A {@code null} value is permitted, and
|
||||
* indicates that the cause is nonexistent or unknown.)
|
||||
*/
|
||||
public XMLSignatureException(Throwable cause) {
|
||||
super(cause==null ? null : cause.toString());
|
||||
this.cause = cause;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the cause of this {@code XMLSignatureException} or
|
||||
* {@code null} if the cause is nonexistent or unknown. (The
|
||||
* cause is the throwable that caused this
|
||||
* {@code XMLSignatureException} to get thrown.)
|
||||
*
|
||||
* @return the cause of this {@code XMLSignatureException} or
|
||||
* {@code null} if the cause is nonexistent or unknown.
|
||||
*/
|
||||
public Throwable getCause() {
|
||||
return cause;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints this {@code XMLSignatureException}, its backtrace and
|
||||
* the cause's backtrace to the standard error stream.
|
||||
*/
|
||||
public void printStackTrace() {
|
||||
super.printStackTrace();
|
||||
if (cause != null) {
|
||||
cause.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints this {@code XMLSignatureException}, its backtrace and
|
||||
* the cause's backtrace to the specified print stream.
|
||||
*
|
||||
* @param s {@code PrintStream} to use for output
|
||||
*/
|
||||
public void printStackTrace(PrintStream s) {
|
||||
super.printStackTrace(s);
|
||||
if (cause != null) {
|
||||
cause.printStackTrace(s);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints this {@code XMLSignatureException}, its backtrace and
|
||||
* the cause's backtrace to the specified print writer.
|
||||
*
|
||||
* @param s {@code PrintWriter} to use for output
|
||||
*/
|
||||
public void printStackTrace(PrintWriter s) {
|
||||
super.printStackTrace(s);
|
||||
if (cause != null) {
|
||||
cause.printStackTrace(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
804
jdkSrc/jdk8/javax/xml/crypto/dsig/XMLSignatureFactory.java
Normal file
804
jdkSrc/jdk8/javax/xml/crypto/dsig/XMLSignatureFactory.java
Normal file
@@ -0,0 +1,804 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: XMLSignatureFactory.java,v 1.14 2005/09/15 14:29:01 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig;
|
||||
|
||||
import javax.xml.crypto.Data;
|
||||
import javax.xml.crypto.MarshalException;
|
||||
import javax.xml.crypto.NoSuchMechanismException;
|
||||
import javax.xml.crypto.URIDereferencer;
|
||||
import javax.xml.crypto.XMLStructure;
|
||||
import javax.xml.crypto.dom.DOMStructure;
|
||||
import javax.xml.crypto.dsig.keyinfo.KeyInfo;
|
||||
import javax.xml.crypto.dsig.keyinfo.KeyInfoFactory;
|
||||
import javax.xml.crypto.dsig.spec.*;
|
||||
import javax.xml.crypto.dsig.dom.DOMValidateContext;
|
||||
import javax.xml.crypto.dsig.dom.DOMSignContext;
|
||||
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.NoSuchProviderException;
|
||||
import java.security.Provider;
|
||||
import java.security.Security;
|
||||
import java.util.List;
|
||||
|
||||
import sun.security.jca.*;
|
||||
import sun.security.jca.GetInstance.Instance;
|
||||
|
||||
/**
|
||||
* A factory for creating {@link XMLSignature} objects from scratch or
|
||||
* for unmarshalling an <code>XMLSignature</code> object from a corresponding
|
||||
* XML representation.
|
||||
*
|
||||
* <h2>XMLSignatureFactory Type</h2>
|
||||
*
|
||||
* <p>Each instance of <code>XMLSignatureFactory</code> supports a specific
|
||||
* XML mechanism type. To create an <code>XMLSignatureFactory</code>, call one
|
||||
* of the static {@link #getInstance getInstance} methods, passing in the XML
|
||||
* mechanism type desired, for example:
|
||||
*
|
||||
* <blockquote><code>
|
||||
* XMLSignatureFactory factory = XMLSignatureFactory.getInstance("DOM");
|
||||
* </code></blockquote>
|
||||
*
|
||||
* <p>The objects that this factory produces will be based
|
||||
* on DOM and abide by the DOM interoperability requirements as defined in the
|
||||
* <a href="../../../../../technotes/guides/security/xmldsig/overview.html#DOM Mechanism Requirements">
|
||||
* DOM Mechanism Requirements</a> section of the API overview. See the
|
||||
* <a href="../../../../../technotes/guides/security/xmldsig/overview.html#Service Provider">
|
||||
* Service Providers</a> section of the API overview for a list of standard
|
||||
* mechanism types.
|
||||
*
|
||||
* <p><code>XMLSignatureFactory</code> implementations are registered and loaded
|
||||
* using the {@link java.security.Provider} mechanism.
|
||||
* For example, a service provider that supports the
|
||||
* DOM mechanism would be specified in the <code>Provider</code> subclass as:
|
||||
* <pre>
|
||||
* put("XMLSignatureFactory.DOM", "org.example.DOMXMLSignatureFactory");
|
||||
* </pre>
|
||||
*
|
||||
* <p>An implementation MUST minimally support the default mechanism type: DOM.
|
||||
*
|
||||
* <p>Note that a caller must use the same <code>XMLSignatureFactory</code>
|
||||
* instance to create the <code>XMLStructure</code>s of a particular
|
||||
* <code>XMLSignature</code> that is to be generated. The behavior is
|
||||
* undefined if <code>XMLStructure</code>s from different providers or
|
||||
* different mechanism types are used together.
|
||||
*
|
||||
* <p>Also, the <code>XMLStructure</code>s that are created by this factory
|
||||
* may contain state specific to the <code>XMLSignature</code> and are not
|
||||
* intended to be reusable.
|
||||
*
|
||||
* <h2>Creating XMLSignatures from scratch</h2>
|
||||
*
|
||||
* <p>Once the <code>XMLSignatureFactory</code> has been created, objects
|
||||
* can be instantiated by calling the appropriate method. For example, a
|
||||
* {@link Reference} instance may be created by invoking one of the
|
||||
* {@link #newReference newReference} methods.
|
||||
*
|
||||
* <h2>Unmarshalling XMLSignatures from XML</h2>
|
||||
*
|
||||
* <p>Alternatively, an <code>XMLSignature</code> may be created from an
|
||||
* existing XML representation by invoking the {@link #unmarshalXMLSignature
|
||||
* unmarshalXMLSignature} method and passing it a mechanism-specific
|
||||
* {@link XMLValidateContext} instance containing the XML content:
|
||||
*
|
||||
* <pre>
|
||||
* DOMValidateContext context = new DOMValidateContext(key, signatureElement);
|
||||
* XMLSignature signature = factory.unmarshalXMLSignature(context);
|
||||
* </pre>
|
||||
*
|
||||
* Each <code>XMLSignatureFactory</code> must support the required
|
||||
* <code>XMLValidateContext</code> types for that factory type, but may support
|
||||
* others. A DOM <code>XMLSignatureFactory</code> must support {@link
|
||||
* DOMValidateContext} objects.
|
||||
*
|
||||
* <h2>Signing and marshalling XMLSignatures to XML</h2>
|
||||
*
|
||||
* Each <code>XMLSignature</code> created by the factory can also be
|
||||
* marshalled to an XML representation and signed, by invoking the
|
||||
* {@link XMLSignature#sign sign} method of the
|
||||
* {@link XMLSignature} object and passing it a mechanism-specific
|
||||
* {@link XMLSignContext} object containing the signing key and
|
||||
* marshalling parameters (see {@link DOMSignContext}).
|
||||
* For example:
|
||||
*
|
||||
* <pre>
|
||||
* DOMSignContext context = new DOMSignContext(privateKey, document);
|
||||
* signature.sign(context);
|
||||
* </pre>
|
||||
*
|
||||
* <b>Concurrent Access</b>
|
||||
* <p>The static methods of this class are guaranteed to be thread-safe.
|
||||
* Multiple threads may concurrently invoke the static methods defined in this
|
||||
* class with no ill effects.
|
||||
*
|
||||
* <p>However, this is not true for the non-static methods defined by this
|
||||
* class. Unless otherwise documented by a specific provider, threads that
|
||||
* need to access a single <code>XMLSignatureFactory</code> instance
|
||||
* concurrently should synchronize amongst themselves and provide the
|
||||
* necessary locking. Multiple threads each manipulating a different
|
||||
* <code>XMLSignatureFactory</code> instance need not synchronize.
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
*/
|
||||
public abstract class XMLSignatureFactory {
|
||||
|
||||
private String mechanismType;
|
||||
private Provider provider;
|
||||
|
||||
/**
|
||||
* Default constructor, for invocation by subclasses.
|
||||
*/
|
||||
protected XMLSignatureFactory() {}
|
||||
|
||||
/**
|
||||
* Returns an <code>XMLSignatureFactory</code> that supports the
|
||||
* specified XML processing mechanism and representation type (ex: "DOM").
|
||||
*
|
||||
* <p>This method uses the standard JCA provider lookup mechanism to
|
||||
* locate and instantiate an <code>XMLSignatureFactory</code>
|
||||
* implementation of the desired mechanism type. It traverses the list of
|
||||
* registered security <code>Provider</code>s, starting with the most
|
||||
* preferred <code>Provider</code>. A new <code>XMLSignatureFactory</code>
|
||||
* object from the first <code>Provider</code> that supports the specified
|
||||
* mechanism is returned.
|
||||
*
|
||||
* <p>Note that the list of registered providers may be retrieved via
|
||||
* the {@link Security#getProviders() Security.getProviders()} method.
|
||||
*
|
||||
* @param mechanismType the type of the XML processing mechanism and
|
||||
* representation. See the <a
|
||||
* href="../../../../../technotes/guides/security/xmldsig/overview.html#Service Provider">
|
||||
* Service Providers</a> section of the API overview for a list of
|
||||
* standard mechanism types.
|
||||
* @return a new <code>XMLSignatureFactory</code>
|
||||
* @throws NullPointerException if <code>mechanismType</code> is
|
||||
* <code>null</code>
|
||||
* @throws NoSuchMechanismException if no <code>Provider</code> supports an
|
||||
* <code>XMLSignatureFactory</code> implementation for the specified
|
||||
* mechanism
|
||||
* @see Provider
|
||||
*/
|
||||
public static XMLSignatureFactory getInstance(String mechanismType) {
|
||||
if (mechanismType == null) {
|
||||
throw new NullPointerException("mechanismType cannot be null");
|
||||
}
|
||||
Instance instance;
|
||||
try {
|
||||
instance = GetInstance.getInstance
|
||||
("XMLSignatureFactory", null, mechanismType);
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
throw new NoSuchMechanismException(nsae);
|
||||
}
|
||||
XMLSignatureFactory factory = (XMLSignatureFactory) instance.impl;
|
||||
factory.mechanismType = mechanismType;
|
||||
factory.provider = instance.provider;
|
||||
return factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an <code>XMLSignatureFactory</code> that supports the
|
||||
* requested XML processing mechanism and representation type (ex: "DOM"),
|
||||
* as supplied by the specified provider. Note that the specified
|
||||
* <code>Provider</code> object does not have to be registered in the
|
||||
* provider list.
|
||||
*
|
||||
* @param mechanismType the type of the XML processing mechanism and
|
||||
* representation. See the <a
|
||||
* href="../../../../../technotes/guides/security/xmldsig/overview.html#Service Provider">
|
||||
* Service Providers</a> section of the API overview for a list of
|
||||
* standard mechanism types.
|
||||
* @param provider the <code>Provider</code> object
|
||||
* @return a new <code>XMLSignatureFactory</code>
|
||||
* @throws NullPointerException if <code>provider</code> or
|
||||
* <code>mechanismType</code> is <code>null</code>
|
||||
* @throws NoSuchMechanismException if an <code>XMLSignatureFactory</code>
|
||||
* implementation for the specified mechanism is not available
|
||||
* from the specified <code>Provider</code> object
|
||||
* @see Provider
|
||||
*/
|
||||
public static XMLSignatureFactory getInstance(String mechanismType,
|
||||
Provider provider) {
|
||||
if (mechanismType == null) {
|
||||
throw new NullPointerException("mechanismType cannot be null");
|
||||
} else if (provider == null) {
|
||||
throw new NullPointerException("provider cannot be null");
|
||||
}
|
||||
|
||||
Instance instance;
|
||||
try {
|
||||
instance = GetInstance.getInstance
|
||||
("XMLSignatureFactory", null, mechanismType, provider);
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
throw new NoSuchMechanismException(nsae);
|
||||
}
|
||||
XMLSignatureFactory factory = (XMLSignatureFactory) instance.impl;
|
||||
factory.mechanismType = mechanismType;
|
||||
factory.provider = instance.provider;
|
||||
return factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an <code>XMLSignatureFactory</code> that supports the
|
||||
* requested XML processing mechanism and representation type (ex: "DOM"),
|
||||
* as supplied by the specified provider. The specified provider must be
|
||||
* registered in the security provider list.
|
||||
*
|
||||
* <p>Note that the list of registered providers may be retrieved via
|
||||
* the {@link Security#getProviders() Security.getProviders()} method.
|
||||
*
|
||||
* @param mechanismType the type of the XML processing mechanism and
|
||||
* representation. See the <a
|
||||
* href="../../../../../technotes/guides/security/xmldsig/overview.html#Service Provider">
|
||||
* Service Providers</a> section of the API overview for a list of
|
||||
* standard mechanism types.
|
||||
* @param provider the string name of the provider
|
||||
* @return a new <code>XMLSignatureFactory</code>
|
||||
* @throws NoSuchProviderException if the specified provider is not
|
||||
* registered in the security provider list
|
||||
* @throws NullPointerException if <code>provider</code> or
|
||||
* <code>mechanismType</code> is <code>null</code>
|
||||
* @throws NoSuchMechanismException if an <code>XMLSignatureFactory</code>
|
||||
* implementation for the specified mechanism is not
|
||||
* available from the specified provider
|
||||
* @see Provider
|
||||
*/
|
||||
public static XMLSignatureFactory getInstance(String mechanismType,
|
||||
String provider) throws NoSuchProviderException {
|
||||
if (mechanismType == null) {
|
||||
throw new NullPointerException("mechanismType cannot be null");
|
||||
} else if (provider == null) {
|
||||
throw new NullPointerException("provider cannot be null");
|
||||
} else if (provider.length() == 0) {
|
||||
throw new NoSuchProviderException();
|
||||
}
|
||||
|
||||
Instance instance;
|
||||
try {
|
||||
instance = GetInstance.getInstance
|
||||
("XMLSignatureFactory", null, mechanismType, provider);
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
throw new NoSuchMechanismException(nsae);
|
||||
}
|
||||
XMLSignatureFactory factory = (XMLSignatureFactory) instance.impl;
|
||||
factory.mechanismType = mechanismType;
|
||||
factory.provider = instance.provider;
|
||||
return factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an <code>XMLSignatureFactory</code> that supports the
|
||||
* default XML processing mechanism and representation type ("DOM").
|
||||
*
|
||||
* <p>This method uses the standard JCA provider lookup mechanism to
|
||||
* locate and instantiate an <code>XMLSignatureFactory</code>
|
||||
* implementation of the default mechanism type. It traverses the list of
|
||||
* registered security <code>Provider</code>s, starting with the most
|
||||
* preferred <code>Provider</code>. A new <code>XMLSignatureFactory</code>
|
||||
* object from the first <code>Provider</code> that supports the DOM
|
||||
* mechanism is returned.
|
||||
*
|
||||
* <p>Note that the list of registered providers may be retrieved via
|
||||
* the {@link Security#getProviders() Security.getProviders()} method.
|
||||
*
|
||||
* @return a new <code>XMLSignatureFactory</code>
|
||||
* @throws NoSuchMechanismException if no <code>Provider</code> supports an
|
||||
* <code>XMLSignatureFactory</code> implementation for the DOM
|
||||
* mechanism
|
||||
* @see Provider
|
||||
*/
|
||||
public static XMLSignatureFactory getInstance() {
|
||||
return getInstance("DOM");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of the XML processing mechanism and representation
|
||||
* supported by this <code>XMLSignatureFactory</code> (ex: "DOM").
|
||||
*
|
||||
* @return the XML processing mechanism type supported by this
|
||||
* <code>XMLSignatureFactory</code>
|
||||
*/
|
||||
public final String getMechanismType() {
|
||||
return mechanismType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the provider of this <code>XMLSignatureFactory</code>.
|
||||
*
|
||||
* @return the provider of this <code>XMLSignatureFactory</code>
|
||||
*/
|
||||
public final Provider getProvider() {
|
||||
return provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an <code>XMLSignature</code> and initializes it with the contents
|
||||
* of the specified <code>SignedInfo</code> and <code>KeyInfo</code>
|
||||
* objects.
|
||||
*
|
||||
* @param si the signed info
|
||||
* @param ki the key info (may be <code>null</code>)
|
||||
* @return an <code>XMLSignature</code>
|
||||
* @throws NullPointerException if <code>si</code> is <code>null</code>
|
||||
*/
|
||||
public abstract XMLSignature newXMLSignature(SignedInfo si, KeyInfo ki);
|
||||
|
||||
/**
|
||||
* Creates an <code>XMLSignature</code> and initializes it with the
|
||||
* specified parameters.
|
||||
*
|
||||
* @param si the signed info
|
||||
* @param ki the key info (may be <code>null</code>)
|
||||
* @param objects a list of {@link XMLObject}s (may be empty or
|
||||
* <code>null</code>)
|
||||
* @param id the Id (may be <code>null</code>)
|
||||
* @param signatureValueId the SignatureValue Id (may be <code>null</code>)
|
||||
* @return an <code>XMLSignature</code>
|
||||
* @throws NullPointerException if <code>si</code> is <code>null</code>
|
||||
* @throws ClassCastException if any of the <code>objects</code> are not of
|
||||
* type <code>XMLObject</code>
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public abstract XMLSignature newXMLSignature(SignedInfo si, KeyInfo ki,
|
||||
List objects, String id, String signatureValueId);
|
||||
|
||||
/**
|
||||
* Creates a <code>Reference</code> with the specified URI and digest
|
||||
* method.
|
||||
*
|
||||
* @param uri the reference URI (may be <code>null</code>)
|
||||
* @param dm the digest method
|
||||
* @return a <code>Reference</code>
|
||||
* @throws IllegalArgumentException if <code>uri</code> is not RFC 2396
|
||||
* compliant
|
||||
* @throws NullPointerException if <code>dm</code> is <code>null</code>
|
||||
*/
|
||||
public abstract Reference newReference(String uri, DigestMethod dm);
|
||||
|
||||
/**
|
||||
* Creates a <code>Reference</code> with the specified parameters.
|
||||
*
|
||||
* @param uri the reference URI (may be <code>null</code>)
|
||||
* @param dm the digest method
|
||||
* @param transforms a list of {@link Transform}s. The list is defensively
|
||||
* copied to protect against subsequent modification. May be
|
||||
* <code>null</code> or empty.
|
||||
* @param type the reference type, as a URI (may be <code>null</code>)
|
||||
* @param id the reference ID (may be <code>null</code>)
|
||||
* @return a <code>Reference</code>
|
||||
* @throws ClassCastException if any of the <code>transforms</code> are
|
||||
* not of type <code>Transform</code>
|
||||
* @throws IllegalArgumentException if <code>uri</code> is not RFC 2396
|
||||
* compliant
|
||||
* @throws NullPointerException if <code>dm</code> is <code>null</code>
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public abstract Reference newReference(String uri, DigestMethod dm,
|
||||
List transforms, String type, String id);
|
||||
|
||||
/**
|
||||
* Creates a <code>Reference</code> with the specified parameters and
|
||||
* pre-calculated digest value.
|
||||
*
|
||||
* <p>This method is useful when the digest value of a
|
||||
* <code>Reference</code> has been previously computed. See for example,
|
||||
* the
|
||||
* <a href="http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=dss">
|
||||
* OASIS-DSS (Digital Signature Services)</a> specification.
|
||||
*
|
||||
* @param uri the reference URI (may be <code>null</code>)
|
||||
* @param dm the digest method
|
||||
* @param transforms a list of {@link Transform}s. The list is defensively
|
||||
* copied to protect against subsequent modification. May be
|
||||
* <code>null</code> or empty.
|
||||
* @param type the reference type, as a URI (may be <code>null</code>)
|
||||
* @param id the reference ID (may be <code>null</code>)
|
||||
* @param digestValue the digest value. The array is cloned to protect
|
||||
* against subsequent modification.
|
||||
* @return a <code>Reference</code>
|
||||
* @throws ClassCastException if any of the <code>transforms</code> are
|
||||
* not of type <code>Transform</code>
|
||||
* @throws IllegalArgumentException if <code>uri</code> is not RFC 2396
|
||||
* compliant
|
||||
* @throws NullPointerException if <code>dm</code> or
|
||||
* <code>digestValue</code> is <code>null</code>
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public abstract Reference newReference(String uri, DigestMethod dm,
|
||||
List transforms, String type, String id, byte[] digestValue);
|
||||
|
||||
/**
|
||||
* Creates a <code>Reference</code> with the specified parameters.
|
||||
*
|
||||
* <p>This method is useful when a list of transforms have already been
|
||||
* applied to the <code>Reference</code>. See for example,
|
||||
* the
|
||||
* <a href="http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=dss">
|
||||
* OASIS-DSS (Digital Signature Services)</a> specification.
|
||||
*
|
||||
* <p>When an <code>XMLSignature</code> containing this reference is
|
||||
* generated, the specified <code>transforms</code> (if non-null) are
|
||||
* applied to the specified <code>result</code>. The
|
||||
* <code>Transforms</code> element of the resulting <code>Reference</code>
|
||||
* element is set to the concatenation of the
|
||||
* <code>appliedTransforms</code> and <code>transforms</code>.
|
||||
*
|
||||
* @param uri the reference URI (may be <code>null</code>)
|
||||
* @param dm the digest method
|
||||
* @param appliedTransforms a list of {@link Transform}s that have
|
||||
* already been applied. The list is defensively
|
||||
* copied to protect against subsequent modification. The list must
|
||||
* contain at least one entry.
|
||||
* @param result the result of processing the sequence of
|
||||
* <code>appliedTransforms</code>
|
||||
* @param transforms a list of {@link Transform}s that are to be applied
|
||||
* when generating the signature. The list is defensively copied to
|
||||
* protect against subsequent modification. May be <code>null</code>
|
||||
* or empty.
|
||||
* @param type the reference type, as a URI (may be <code>null</code>)
|
||||
* @param id the reference ID (may be <code>null</code>)
|
||||
* @return a <code>Reference</code>
|
||||
* @throws ClassCastException if any of the transforms (in either list)
|
||||
* are not of type <code>Transform</code>
|
||||
* @throws IllegalArgumentException if <code>uri</code> is not RFC 2396
|
||||
* compliant or <code>appliedTransforms</code> is empty
|
||||
* @throws NullPointerException if <code>dm</code>,
|
||||
* <code>appliedTransforms</code> or <code>result</code> is
|
||||
* <code>null</code>
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public abstract Reference newReference(String uri, DigestMethod dm,
|
||||
List appliedTransforms, Data result, List transforms, String type,
|
||||
String id);
|
||||
|
||||
/**
|
||||
* Creates a <code>SignedInfo</code> with the specified canonicalization
|
||||
* and signature methods, and list of one or more references.
|
||||
*
|
||||
* @param cm the canonicalization method
|
||||
* @param sm the signature method
|
||||
* @param references a list of one or more {@link Reference}s. The list is
|
||||
* defensively copied to protect against subsequent modification.
|
||||
* @return a <code>SignedInfo</code>
|
||||
* @throws ClassCastException if any of the references are not of
|
||||
* type <code>Reference</code>
|
||||
* @throws IllegalArgumentException if <code>references</code> is empty
|
||||
* @throws NullPointerException if any of the parameters
|
||||
* are <code>null</code>
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public abstract SignedInfo newSignedInfo(CanonicalizationMethod cm,
|
||||
SignatureMethod sm, List references);
|
||||
|
||||
/**
|
||||
* Creates a <code>SignedInfo</code> with the specified parameters.
|
||||
*
|
||||
* @param cm the canonicalization method
|
||||
* @param sm the signature method
|
||||
* @param references a list of one or more {@link Reference}s. The list is
|
||||
* defensively copied to protect against subsequent modification.
|
||||
* @param id the id (may be <code>null</code>)
|
||||
* @return a <code>SignedInfo</code>
|
||||
* @throws ClassCastException if any of the references are not of
|
||||
* type <code>Reference</code>
|
||||
* @throws IllegalArgumentException if <code>references</code> is empty
|
||||
* @throws NullPointerException if <code>cm</code>, <code>sm</code>, or
|
||||
* <code>references</code> are <code>null</code>
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public abstract SignedInfo newSignedInfo(CanonicalizationMethod cm,
|
||||
SignatureMethod sm, List references, String id);
|
||||
|
||||
// Object factory methods
|
||||
/**
|
||||
* Creates an <code>XMLObject</code> from the specified parameters.
|
||||
*
|
||||
* @param content a list of {@link XMLStructure}s. The list
|
||||
* is defensively copied to protect against subsequent modification.
|
||||
* May be <code>null</code> or empty.
|
||||
* @param id the Id (may be <code>null</code>)
|
||||
* @param mimeType the mime type (may be <code>null</code>)
|
||||
* @param encoding the encoding (may be <code>null</code>)
|
||||
* @return an <code>XMLObject</code>
|
||||
* @throws ClassCastException if <code>content</code> contains any
|
||||
* entries that are not of type {@link XMLStructure}
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public abstract XMLObject newXMLObject(List content, String id,
|
||||
String mimeType, String encoding);
|
||||
|
||||
/**
|
||||
* Creates a <code>Manifest</code> containing the specified
|
||||
* list of {@link Reference}s.
|
||||
*
|
||||
* @param references a list of one or more <code>Reference</code>s. The list
|
||||
* is defensively copied to protect against subsequent modification.
|
||||
* @return a <code>Manifest</code>
|
||||
* @throws NullPointerException if <code>references</code> is
|
||||
* <code>null</code>
|
||||
* @throws IllegalArgumentException if <code>references</code> is empty
|
||||
* @throws ClassCastException if <code>references</code> contains any
|
||||
* entries that are not of type {@link Reference}
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public abstract Manifest newManifest(List references);
|
||||
|
||||
/**
|
||||
* Creates a <code>Manifest</code> containing the specified
|
||||
* list of {@link Reference}s and optional id.
|
||||
*
|
||||
* @param references a list of one or more <code>Reference</code>s. The list
|
||||
* is defensively copied to protect against subsequent modification.
|
||||
* @param id the id (may be <code>null</code>)
|
||||
* @return a <code>Manifest</code>
|
||||
* @throws NullPointerException if <code>references</code> is
|
||||
* <code>null</code>
|
||||
* @throws IllegalArgumentException if <code>references</code> is empty
|
||||
* @throws ClassCastException if <code>references</code> contains any
|
||||
* entries that are not of type {@link Reference}
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public abstract Manifest newManifest(List references, String id);
|
||||
|
||||
/**
|
||||
* Creates a <code>SignatureProperty</code> containing the specified
|
||||
* list of {@link XMLStructure}s, target URI and optional id.
|
||||
*
|
||||
* @param content a list of one or more <code>XMLStructure</code>s. The list
|
||||
* is defensively copied to protect against subsequent modification.
|
||||
* @param target the target URI of the Signature that this property applies
|
||||
* to
|
||||
* @param id the id (may be <code>null</code>)
|
||||
* @return a <code>SignatureProperty</code>
|
||||
* @throws NullPointerException if <code>content</code> or
|
||||
* <code>target</code> is <code>null</code>
|
||||
* @throws IllegalArgumentException if <code>content</code> is empty
|
||||
* @throws ClassCastException if <code>content</code> contains any
|
||||
* entries that are not of type {@link XMLStructure}
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public abstract SignatureProperty newSignatureProperty
|
||||
(List content, String target, String id);
|
||||
|
||||
/**
|
||||
* Creates a <code>SignatureProperties</code> containing the specified
|
||||
* list of {@link SignatureProperty}s and optional id.
|
||||
*
|
||||
* @param properties a list of one or more <code>SignatureProperty</code>s.
|
||||
* The list is defensively copied to protect against subsequent
|
||||
* modification.
|
||||
* @param id the id (may be <code>null</code>)
|
||||
* @return a <code>SignatureProperties</code>
|
||||
* @throws NullPointerException if <code>properties</code>
|
||||
* is <code>null</code>
|
||||
* @throws IllegalArgumentException if <code>properties</code> is empty
|
||||
* @throws ClassCastException if <code>properties</code> contains any
|
||||
* entries that are not of type {@link SignatureProperty}
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public abstract SignatureProperties newSignatureProperties
|
||||
(List properties, String id);
|
||||
|
||||
// Algorithm factory methods
|
||||
/**
|
||||
* Creates a <code>DigestMethod</code> for the specified algorithm URI
|
||||
* and parameters.
|
||||
*
|
||||
* @param algorithm the URI identifying the digest algorithm
|
||||
* @param params algorithm-specific digest parameters (may be
|
||||
* <code>null</code>)
|
||||
* @return the <code>DigestMethod</code>
|
||||
* @throws InvalidAlgorithmParameterException if the specified parameters
|
||||
* are inappropriate for the requested algorithm
|
||||
* @throws NoSuchAlgorithmException if an implementation of the
|
||||
* specified algorithm cannot be found
|
||||
* @throws NullPointerException if <code>algorithm</code> is
|
||||
* <code>null</code>
|
||||
*/
|
||||
public abstract DigestMethod newDigestMethod(String algorithm,
|
||||
DigestMethodParameterSpec params) throws NoSuchAlgorithmException,
|
||||
InvalidAlgorithmParameterException;
|
||||
|
||||
/**
|
||||
* Creates a <code>SignatureMethod</code> for the specified algorithm URI
|
||||
* and parameters.
|
||||
*
|
||||
* @param algorithm the URI identifying the signature algorithm
|
||||
* @param params algorithm-specific signature parameters (may be
|
||||
* <code>null</code>)
|
||||
* @return the <code>SignatureMethod</code>
|
||||
* @throws InvalidAlgorithmParameterException if the specified parameters
|
||||
* are inappropriate for the requested algorithm
|
||||
* @throws NoSuchAlgorithmException if an implementation of the
|
||||
* specified algorithm cannot be found
|
||||
* @throws NullPointerException if <code>algorithm</code> is
|
||||
* <code>null</code>
|
||||
*/
|
||||
public abstract SignatureMethod newSignatureMethod(String algorithm,
|
||||
SignatureMethodParameterSpec params) throws NoSuchAlgorithmException,
|
||||
InvalidAlgorithmParameterException;
|
||||
|
||||
/**
|
||||
* Creates a <code>Transform</code> for the specified algorithm URI
|
||||
* and parameters.
|
||||
*
|
||||
* @param algorithm the URI identifying the transform algorithm
|
||||
* @param params algorithm-specific transform parameters (may be
|
||||
* <code>null</code>)
|
||||
* @return the <code>Transform</code>
|
||||
* @throws InvalidAlgorithmParameterException if the specified parameters
|
||||
* are inappropriate for the requested algorithm
|
||||
* @throws NoSuchAlgorithmException if an implementation of the
|
||||
* specified algorithm cannot be found
|
||||
* @throws NullPointerException if <code>algorithm</code> is
|
||||
* <code>null</code>
|
||||
*/
|
||||
public abstract Transform newTransform(String algorithm,
|
||||
TransformParameterSpec params) throws NoSuchAlgorithmException,
|
||||
InvalidAlgorithmParameterException;
|
||||
|
||||
/**
|
||||
* Creates a <code>Transform</code> for the specified algorithm URI
|
||||
* and parameters. The parameters are specified as a mechanism-specific
|
||||
* <code>XMLStructure</code> (ex: {@link DOMStructure}). This method is
|
||||
* useful when the parameters are in XML form or there is no standard
|
||||
* class for specifying the parameters.
|
||||
*
|
||||
* @param algorithm the URI identifying the transform algorithm
|
||||
* @param params a mechanism-specific XML structure from which to
|
||||
* unmarshal the parameters from (may be <code>null</code> if
|
||||
* not required or optional)
|
||||
* @return the <code>Transform</code>
|
||||
* @throws ClassCastException if the type of <code>params</code> is
|
||||
* inappropriate for this <code>XMLSignatureFactory</code>
|
||||
* @throws InvalidAlgorithmParameterException if the specified parameters
|
||||
* are inappropriate for the requested algorithm
|
||||
* @throws NoSuchAlgorithmException if an implementation of the
|
||||
* specified algorithm cannot be found
|
||||
* @throws NullPointerException if <code>algorithm</code> is
|
||||
* <code>null</code>
|
||||
*/
|
||||
public abstract Transform newTransform(String algorithm,
|
||||
XMLStructure params) throws NoSuchAlgorithmException,
|
||||
InvalidAlgorithmParameterException;
|
||||
|
||||
/**
|
||||
* Creates a <code>CanonicalizationMethod</code> for the specified
|
||||
* algorithm URI and parameters.
|
||||
*
|
||||
* @param algorithm the URI identifying the canonicalization algorithm
|
||||
* @param params algorithm-specific canonicalization parameters (may be
|
||||
* <code>null</code>)
|
||||
* @return the <code>CanonicalizationMethod</code>
|
||||
* @throws InvalidAlgorithmParameterException if the specified parameters
|
||||
* are inappropriate for the requested algorithm
|
||||
* @throws NoSuchAlgorithmException if an implementation of the
|
||||
* specified algorithm cannot be found
|
||||
* @throws NullPointerException if <code>algorithm</code> is
|
||||
* <code>null</code>
|
||||
*/
|
||||
public abstract CanonicalizationMethod newCanonicalizationMethod(
|
||||
String algorithm, C14NMethodParameterSpec params)
|
||||
throws NoSuchAlgorithmException, InvalidAlgorithmParameterException;
|
||||
|
||||
/**
|
||||
* Creates a <code>CanonicalizationMethod</code> for the specified
|
||||
* algorithm URI and parameters. The parameters are specified as a
|
||||
* mechanism-specific <code>XMLStructure</code> (ex: {@link DOMStructure}).
|
||||
* This method is useful when the parameters are in XML form or there is
|
||||
* no standard class for specifying the parameters.
|
||||
*
|
||||
* @param algorithm the URI identifying the canonicalization algorithm
|
||||
* @param params a mechanism-specific XML structure from which to
|
||||
* unmarshal the parameters from (may be <code>null</code> if
|
||||
* not required or optional)
|
||||
* @return the <code>CanonicalizationMethod</code>
|
||||
* @throws ClassCastException if the type of <code>params</code> is
|
||||
* inappropriate for this <code>XMLSignatureFactory</code>
|
||||
* @throws InvalidAlgorithmParameterException if the specified parameters
|
||||
* are inappropriate for the requested algorithm
|
||||
* @throws NoSuchAlgorithmException if an implementation of the
|
||||
* specified algorithm cannot be found
|
||||
* @throws NullPointerException if <code>algorithm</code> is
|
||||
* <code>null</code>
|
||||
*/
|
||||
public abstract CanonicalizationMethod newCanonicalizationMethod(
|
||||
String algorithm, XMLStructure params)
|
||||
throws NoSuchAlgorithmException, InvalidAlgorithmParameterException;
|
||||
|
||||
/**
|
||||
* Returns a <code>KeyInfoFactory</code> that creates <code>KeyInfo</code>
|
||||
* objects. The returned <code>KeyInfoFactory</code> has the same
|
||||
* mechanism type and provider as this <code>XMLSignatureFactory</code>.
|
||||
*
|
||||
* @return a <code>KeyInfoFactory</code>
|
||||
* @throws NoSuchMechanismException if a <code>KeyFactory</code>
|
||||
* implementation with the same mechanism type and provider
|
||||
* is not available
|
||||
*/
|
||||
public final KeyInfoFactory getKeyInfoFactory() {
|
||||
return KeyInfoFactory.getInstance(getMechanismType(), getProvider());
|
||||
}
|
||||
|
||||
/**
|
||||
* Unmarshals a new <code>XMLSignature</code> instance from a
|
||||
* mechanism-specific <code>XMLValidateContext</code> instance.
|
||||
*
|
||||
* @param context a mechanism-specific context from which to unmarshal the
|
||||
* signature from
|
||||
* @return the <code>XMLSignature</code>
|
||||
* @throws NullPointerException if <code>context</code> is
|
||||
* <code>null</code>
|
||||
* @throws ClassCastException if the type of <code>context</code> is
|
||||
* inappropriate for this factory
|
||||
* @throws MarshalException if an unrecoverable exception occurs
|
||||
* during unmarshalling
|
||||
*/
|
||||
public abstract XMLSignature unmarshalXMLSignature
|
||||
(XMLValidateContext context) throws MarshalException;
|
||||
|
||||
/**
|
||||
* Unmarshals a new <code>XMLSignature</code> instance from a
|
||||
* mechanism-specific <code>XMLStructure</code> instance.
|
||||
* This method is useful if you only want to unmarshal (and not
|
||||
* validate) an <code>XMLSignature</code>.
|
||||
*
|
||||
* @param xmlStructure a mechanism-specific XML structure from which to
|
||||
* unmarshal the signature from
|
||||
* @return the <code>XMLSignature</code>
|
||||
* @throws NullPointerException if <code>xmlStructure</code> is
|
||||
* <code>null</code>
|
||||
* @throws ClassCastException if the type of <code>xmlStructure</code> is
|
||||
* inappropriate for this factory
|
||||
* @throws MarshalException if an unrecoverable exception occurs
|
||||
* during unmarshalling
|
||||
*/
|
||||
public abstract XMLSignature unmarshalXMLSignature
|
||||
(XMLStructure xmlStructure) throws MarshalException;
|
||||
|
||||
/**
|
||||
* Indicates whether a specified feature is supported.
|
||||
*
|
||||
* @param feature the feature name (as an absolute URI)
|
||||
* @return <code>true</code> if the specified feature is supported,
|
||||
* <code>false</code> otherwise
|
||||
* @throws NullPointerException if <code>feature</code> is <code>null</code>
|
||||
*/
|
||||
public abstract boolean isFeatureSupported(String feature);
|
||||
|
||||
/**
|
||||
* Returns a reference to the <code>URIDereferencer</code> that is used by
|
||||
* default to dereference URIs in {@link Reference} objects.
|
||||
*
|
||||
* @return a reference to the default <code>URIDereferencer</code> (never
|
||||
* <code>null</code>)
|
||||
*/
|
||||
public abstract URIDereferencer getURIDereferencer();
|
||||
}
|
||||
63
jdkSrc/jdk8/javax/xml/crypto/dsig/XMLValidateContext.java
Normal file
63
jdkSrc/jdk8/javax/xml/crypto/dsig/XMLValidateContext.java
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: XMLValidateContext.java,v 1.8 2005/05/10 16:03:49 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig;
|
||||
|
||||
import javax.xml.crypto.XMLCryptoContext;
|
||||
|
||||
/**
|
||||
* Contains context information for validating XML Signatures. This interface
|
||||
* is primarily intended for type-safety.
|
||||
*
|
||||
* <p>Note that <code>XMLValidateContext</code> instances can contain
|
||||
* information and state specific to the XML signature structure it is
|
||||
* used with. The results are unpredictable if an
|
||||
* <code>XMLValidateContext</code> is used with different signature structures
|
||||
* (for example, you should not use the same <code>XMLValidateContext</code>
|
||||
* instance to validate two different {@link XMLSignature} objects).
|
||||
* <p>
|
||||
* <b><a name="Supported Properties"></a>Supported Properties</b>
|
||||
* <p>The following properties can be set by an application using the
|
||||
* {@link #setProperty setProperty} method.
|
||||
* <ul>
|
||||
* <li><code>javax.xml.crypto.dsig.cacheReference</code>: value must be a
|
||||
* {@link Boolean}. This property controls whether or not the
|
||||
* {@link Reference#validate Reference.validate} method will cache the
|
||||
* dereferenced content and pre-digested input for subsequent retrieval via
|
||||
* the {@link Reference#getDereferencedData Reference.getDereferencedData}
|
||||
* and {@link Reference#getDigestInputStream
|
||||
* Reference.getDigestInputStream} methods. The default value if not
|
||||
* specified is <code>Boolean.FALSE</code>.
|
||||
* </ul>
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
* @see XMLSignature#validate(XMLValidateContext)
|
||||
* @see Reference#validate(XMLValidateContext)
|
||||
*/
|
||||
public interface XMLValidateContext extends XMLCryptoContext {}
|
||||
209
jdkSrc/jdk8/javax/xml/crypto/dsig/dom/DOMSignContext.java
Normal file
209
jdkSrc/jdk8/javax/xml/crypto/dsig/dom/DOMSignContext.java
Normal file
@@ -0,0 +1,209 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: DOMSignContext.java,v 1.9 2005/05/10 16:31:14 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig.dom;
|
||||
|
||||
import javax.xml.crypto.KeySelector;
|
||||
import javax.xml.crypto.dom.DOMCryptoContext;
|
||||
import javax.xml.crypto.dsig.XMLSignContext;
|
||||
import javax.xml.crypto.dsig.XMLSignature;
|
||||
import java.security.Key;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/**
|
||||
* A DOM-specific {@link XMLSignContext}. This class contains additional methods
|
||||
* to specify the location in a DOM tree where an {@link XMLSignature}
|
||||
* object is to be marshalled when generating the signature.
|
||||
*
|
||||
* <p>Note that <code>DOMSignContext</code> instances can contain
|
||||
* information and state specific to the XML signature structure it is
|
||||
* used with. The results are unpredictable if a
|
||||
* <code>DOMSignContext</code> is used with different signature structures
|
||||
* (for example, you should not use the same <code>DOMSignContext</code>
|
||||
* instance to sign two different {@link XMLSignature} objects).
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
*/
|
||||
public class DOMSignContext extends DOMCryptoContext implements XMLSignContext {
|
||||
|
||||
private Node parent;
|
||||
private Node nextSibling;
|
||||
|
||||
/**
|
||||
* Creates a <code>DOMSignContext</code> with the specified signing key
|
||||
* and parent node. The signing key is stored in a
|
||||
* {@link KeySelector#singletonKeySelector singleton KeySelector} that is
|
||||
* returned by the {@link #getKeySelector getKeySelector} method.
|
||||
* The marshalled <code>XMLSignature</code> will be added as the last
|
||||
* child element of the specified parent node unless a next sibling node is
|
||||
* specified by invoking the {@link #setNextSibling setNextSibling} method.
|
||||
*
|
||||
* @param signingKey the signing key
|
||||
* @param parent the parent node
|
||||
* @throws NullPointerException if <code>signingKey</code> or
|
||||
* <code>parent</code> is <code>null</code>
|
||||
*/
|
||||
public DOMSignContext(Key signingKey, Node parent) {
|
||||
if (signingKey == null) {
|
||||
throw new NullPointerException("signingKey cannot be null");
|
||||
}
|
||||
if (parent == null) {
|
||||
throw new NullPointerException("parent cannot be null");
|
||||
}
|
||||
setKeySelector(KeySelector.singletonKeySelector(signingKey));
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>DOMSignContext</code> with the specified signing key,
|
||||
* parent and next sibling nodes. The signing key is stored in a
|
||||
* {@link KeySelector#singletonKeySelector singleton KeySelector} that is
|
||||
* returned by the {@link #getKeySelector getKeySelector} method.
|
||||
* The marshalled <code>XMLSignature</code> will be inserted as a child
|
||||
* element of the specified parent node and immediately before the
|
||||
* specified next sibling node.
|
||||
*
|
||||
* @param signingKey the signing key
|
||||
* @param parent the parent node
|
||||
* @param nextSibling the next sibling node
|
||||
* @throws NullPointerException if <code>signingKey</code>,
|
||||
* <code>parent</code> or <code>nextSibling</code> is <code>null</code>
|
||||
*/
|
||||
public DOMSignContext(Key signingKey, Node parent, Node nextSibling) {
|
||||
if (signingKey == null) {
|
||||
throw new NullPointerException("signingKey cannot be null");
|
||||
}
|
||||
if (parent == null) {
|
||||
throw new NullPointerException("parent cannot be null");
|
||||
}
|
||||
if (nextSibling == null) {
|
||||
throw new NullPointerException("nextSibling cannot be null");
|
||||
}
|
||||
setKeySelector(KeySelector.singletonKeySelector(signingKey));
|
||||
this.parent = parent;
|
||||
this.nextSibling = nextSibling;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>DOMSignContext</code> with the specified key selector
|
||||
* and parent node. The marshalled <code>XMLSignature</code> will be added
|
||||
* as the last child element of the specified parent node unless a next
|
||||
* sibling node is specified by invoking the
|
||||
* {@link #setNextSibling setNextSibling} method.
|
||||
*
|
||||
* @param ks the key selector
|
||||
* @param parent the parent node
|
||||
* @throws NullPointerException if <code>ks</code> or <code>parent</code>
|
||||
* is <code>null</code>
|
||||
*/
|
||||
public DOMSignContext(KeySelector ks, Node parent) {
|
||||
if (ks == null) {
|
||||
throw new NullPointerException("key selector cannot be null");
|
||||
}
|
||||
if (parent == null) {
|
||||
throw new NullPointerException("parent cannot be null");
|
||||
}
|
||||
setKeySelector(ks);
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>DOMSignContext</code> with the specified key selector,
|
||||
* parent and next sibling nodes. The marshalled <code>XMLSignature</code>
|
||||
* will be inserted as a child element of the specified parent node and
|
||||
* immediately before the specified next sibling node.
|
||||
*
|
||||
* @param ks the key selector
|
||||
* @param parent the parent node
|
||||
* @param nextSibling the next sibling node
|
||||
* @throws NullPointerException if <code>ks</code>, <code>parent</code> or
|
||||
* <code>nextSibling</code> is <code>null</code>
|
||||
*/
|
||||
public DOMSignContext(KeySelector ks, Node parent, Node nextSibling) {
|
||||
if (ks == null) {
|
||||
throw new NullPointerException("key selector cannot be null");
|
||||
}
|
||||
if (parent == null) {
|
||||
throw new NullPointerException("parent cannot be null");
|
||||
}
|
||||
if (nextSibling == null) {
|
||||
throw new NullPointerException("nextSibling cannot be null");
|
||||
}
|
||||
setKeySelector(ks);
|
||||
this.parent = parent;
|
||||
this.nextSibling = nextSibling;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the parent node.
|
||||
*
|
||||
* @param parent the parent node. The marshalled <code>XMLSignature</code>
|
||||
* will be added as a child element of this node.
|
||||
* @throws NullPointerException if <code>parent</code> is <code>null</code>
|
||||
* @see #getParent
|
||||
*/
|
||||
public void setParent(Node parent) {
|
||||
if (parent == null) {
|
||||
throw new NullPointerException("parent is null");
|
||||
}
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the next sibling node.
|
||||
*
|
||||
* @param nextSibling the next sibling node. The marshalled
|
||||
* <code>XMLSignature</code> will be inserted immediately before this
|
||||
* node. Specify <code>null</code> to remove the current setting.
|
||||
* @see #getNextSibling
|
||||
*/
|
||||
public void setNextSibling(Node nextSibling) {
|
||||
this.nextSibling = nextSibling;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parent node.
|
||||
*
|
||||
* @return the parent node (never <code>null</code>)
|
||||
* @see #setParent(Node)
|
||||
*/
|
||||
public Node getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the nextSibling node.
|
||||
*
|
||||
* @return the nextSibling node, or <code>null</code> if not specified.
|
||||
* @see #setNextSibling(Node)
|
||||
*/
|
||||
public Node getNextSibling() {
|
||||
return nextSibling;
|
||||
}
|
||||
}
|
||||
135
jdkSrc/jdk8/javax/xml/crypto/dsig/dom/DOMValidateContext.java
Normal file
135
jdkSrc/jdk8/javax/xml/crypto/dsig/dom/DOMValidateContext.java
Normal file
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: DOMValidateContext.java,v 1.8 2005/05/10 16:31:14 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig.dom;
|
||||
|
||||
import javax.xml.crypto.KeySelector;
|
||||
import javax.xml.crypto.dom.DOMCryptoContext;
|
||||
import javax.xml.crypto.dsig.XMLSignature;
|
||||
import javax.xml.crypto.dsig.XMLSignatureFactory;
|
||||
import javax.xml.crypto.dsig.XMLValidateContext;
|
||||
import java.security.Key;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
/**
|
||||
* A DOM-specific {@link XMLValidateContext}. This class contains additional
|
||||
* methods to specify the location in a DOM tree where an {@link XMLSignature}
|
||||
* is to be unmarshalled and validated from.
|
||||
*
|
||||
* <p>Note that the behavior of an unmarshalled <code>XMLSignature</code>
|
||||
* is undefined if the contents of the underlying DOM tree are modified by the
|
||||
* caller after the <code>XMLSignature</code> is created.
|
||||
*
|
||||
* <p>Also, note that <code>DOMValidateContext</code> instances can contain
|
||||
* information and state specific to the XML signature structure it is
|
||||
* used with. The results are unpredictable if a
|
||||
* <code>DOMValidateContext</code> is used with different signature structures
|
||||
* (for example, you should not use the same <code>DOMValidateContext</code>
|
||||
* instance to validate two different {@link XMLSignature} objects).
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
* @see XMLSignatureFactory#unmarshalXMLSignature(XMLValidateContext)
|
||||
*/
|
||||
public class DOMValidateContext extends DOMCryptoContext
|
||||
implements XMLValidateContext {
|
||||
|
||||
private Node node;
|
||||
|
||||
/**
|
||||
* Creates a <code>DOMValidateContext</code> containing the specified key
|
||||
* selector and node.
|
||||
*
|
||||
* @param ks a key selector for finding a validation key
|
||||
* @param node the node
|
||||
* @throws NullPointerException if <code>ks</code> or <code>node</code> is
|
||||
* <code>null</code>
|
||||
*/
|
||||
public DOMValidateContext(KeySelector ks, Node node) {
|
||||
if (ks == null) {
|
||||
throw new NullPointerException("key selector is null");
|
||||
}
|
||||
init(node, ks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>DOMValidateContext</code> containing the specified key
|
||||
* and node. The validating key will be stored in a
|
||||
* {@link KeySelector#singletonKeySelector singleton KeySelector} that
|
||||
* is returned when the {@link #getKeySelector getKeySelector}
|
||||
* method is called.
|
||||
*
|
||||
* @param validatingKey the validating key
|
||||
* @param node the node
|
||||
* @throws NullPointerException if <code>validatingKey</code> or
|
||||
* <code>node</code> is <code>null</code>
|
||||
*/
|
||||
public DOMValidateContext(Key validatingKey, Node node) {
|
||||
if (validatingKey == null) {
|
||||
throw new NullPointerException("validatingKey is null");
|
||||
}
|
||||
init(node, KeySelector.singletonKeySelector(validatingKey));
|
||||
}
|
||||
|
||||
private void init(Node node, KeySelector ks) {
|
||||
if (node == null) {
|
||||
throw new NullPointerException("node is null");
|
||||
}
|
||||
|
||||
this.node = node;
|
||||
super.setKeySelector(ks);
|
||||
if (System.getSecurityManager() != null) {
|
||||
super.setProperty("org.jcp.xml.dsig.secureValidation",
|
||||
Boolean.TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the node.
|
||||
*
|
||||
* @param node the node
|
||||
* @throws NullPointerException if <code>node</code> is <code>null</code>
|
||||
* @see #getNode
|
||||
*/
|
||||
public void setNode(Node node) {
|
||||
if (node == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the node.
|
||||
*
|
||||
* @return the node (never <code>null</code>)
|
||||
* @see #setNode(Node)
|
||||
*/
|
||||
public Node getNode() {
|
||||
return node;
|
||||
}
|
||||
}
|
||||
124
jdkSrc/jdk8/javax/xml/crypto/dsig/keyinfo/KeyInfo.java
Normal file
124
jdkSrc/jdk8/javax/xml/crypto/dsig/keyinfo/KeyInfo.java
Normal file
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: KeyInfo.java,v 1.7 2005/05/10 16:35:34 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig.keyinfo;
|
||||
|
||||
import java.util.List;
|
||||
import javax.xml.crypto.MarshalException;
|
||||
import javax.xml.crypto.XMLCryptoContext;
|
||||
import javax.xml.crypto.XMLStructure;
|
||||
|
||||
/**
|
||||
* A representation of the XML <code>KeyInfo</code> element as defined in
|
||||
* the <a href="http://www.w3.org/TR/xmldsig-core/">
|
||||
* W3C Recommendation for XML-Signature Syntax and Processing</a>.
|
||||
* A <code>KeyInfo</code> contains a list of {@link XMLStructure}s, each of
|
||||
* which contain information that enables the recipient(s) to obtain the key
|
||||
* needed to validate an XML signature. The XML Schema Definition is defined as:
|
||||
*
|
||||
* <pre>
|
||||
* <element name="KeyInfo" type="ds:KeyInfoType"/>
|
||||
* <complexType name="KeyInfoType" mixed="true">
|
||||
* <choice maxOccurs="unbounded">
|
||||
* <element ref="ds:KeyName"/>
|
||||
* <element ref="ds:KeyValue"/>
|
||||
* <element ref="ds:RetrievalMethod"/>
|
||||
* <element ref="ds:X509Data"/>
|
||||
* <element ref="ds:PGPData"/>
|
||||
* <element ref="ds:SPKIData"/>
|
||||
* <element ref="ds:MgmtData"/>
|
||||
* <any processContents="lax" namespace="##other"/>
|
||||
* <!-- (1,1) elements from (0,unbounded) namespaces -->
|
||||
* </choice>
|
||||
* <attribute name="Id" type="ID" use="optional"/>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
* A <code>KeyInfo</code> instance may be created by invoking one of the
|
||||
* {@link KeyInfoFactory#newKeyInfo newKeyInfo} methods of the
|
||||
* {@link KeyInfoFactory} class, and passing it a list of one or more
|
||||
* <code>XMLStructure</code>s and an optional id parameter;
|
||||
* for example:
|
||||
* <pre>
|
||||
* KeyInfoFactory factory = KeyInfoFactory.getInstance("DOM");
|
||||
* KeyInfo keyInfo = factory.newKeyInfo
|
||||
* (Collections.singletonList(factory.newKeyName("Alice"), "keyinfo-1"));
|
||||
* </pre>
|
||||
*
|
||||
* <p><code>KeyInfo</code> objects can also be marshalled to XML by invoking
|
||||
* the {@link #marshal marshal} method.
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
* @see KeyInfoFactory#newKeyInfo(List)
|
||||
* @see KeyInfoFactory#newKeyInfo(List, String)
|
||||
*/
|
||||
public interface KeyInfo extends XMLStructure {
|
||||
|
||||
/**
|
||||
* Returns an {@link java.util.Collections#unmodifiableList unmodifiable
|
||||
* list} containing the key information. Each entry of the list is
|
||||
* an {@link XMLStructure}.
|
||||
*
|
||||
* <p>If there is a public subclass representing the type of
|
||||
* <code>XMLStructure</code>, it is returned as an instance of that
|
||||
* class (ex: an <code>X509Data</code> element would be returned as an
|
||||
* instance of {@link javax.xml.crypto.dsig.keyinfo.X509Data}).
|
||||
*
|
||||
* @return an unmodifiable list of one or more <code>XMLStructure</code>s
|
||||
* in this <code>KeyInfo</code>. Never returns <code>null</code> or an
|
||||
* empty list.
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
List getContent();
|
||||
|
||||
/**
|
||||
* Return the optional Id attribute of this <code>KeyInfo</code>, which
|
||||
* may be useful for referencing this <code>KeyInfo</code> from other
|
||||
* XML structures.
|
||||
*
|
||||
* @return the Id attribute of this <code>KeyInfo</code> (may be
|
||||
* <code>null</code> if not specified)
|
||||
*/
|
||||
String getId();
|
||||
|
||||
/**
|
||||
* Marshals the key info to XML.
|
||||
*
|
||||
* @param parent a mechanism-specific structure containing the parent node
|
||||
* that the marshalled key info will be appended to
|
||||
* @param context the <code>XMLCryptoContext</code> containing additional
|
||||
* context (may be null if not applicable)
|
||||
* @throws ClassCastException if the type of <code>parent</code> or
|
||||
* <code>context</code> is not compatible with this key info
|
||||
* @throws MarshalException if the key info cannot be marshalled
|
||||
* @throws NullPointerException if <code>parent</code> is <code>null</code>
|
||||
*/
|
||||
void marshal(XMLStructure parent, XMLCryptoContext context)
|
||||
throws MarshalException;
|
||||
}
|
||||
528
jdkSrc/jdk8/javax/xml/crypto/dsig/keyinfo/KeyInfoFactory.java
Normal file
528
jdkSrc/jdk8/javax/xml/crypto/dsig/keyinfo/KeyInfoFactory.java
Normal file
@@ -0,0 +1,528 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: KeyInfoFactory.java,v 1.12 2005/05/10 16:35:35 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig.keyinfo;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.security.KeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.NoSuchProviderException;
|
||||
import java.security.Provider;
|
||||
import java.security.PublicKey;
|
||||
import java.security.Security;
|
||||
import java.security.cert.X509CRL;
|
||||
import java.util.List;
|
||||
import javax.xml.crypto.MarshalException;
|
||||
import javax.xml.crypto.NoSuchMechanismException;
|
||||
import javax.xml.crypto.URIDereferencer;
|
||||
import javax.xml.crypto.XMLStructure;
|
||||
import javax.xml.crypto.dom.DOMStructure;
|
||||
import javax.xml.crypto.dsig.*;
|
||||
|
||||
import sun.security.jca.*;
|
||||
import sun.security.jca.GetInstance.Instance;
|
||||
|
||||
/**
|
||||
* A factory for creating {@link KeyInfo} objects from scratch or for
|
||||
* unmarshalling a <code>KeyInfo</code> object from a corresponding XML
|
||||
* representation.
|
||||
*
|
||||
* <p>Each instance of <code>KeyInfoFactory</code> supports a specific
|
||||
* XML mechanism type. To create a <code>KeyInfoFactory</code>, call one of the
|
||||
* static {@link #getInstance getInstance} methods, passing in the XML
|
||||
* mechanism type desired, for example:
|
||||
*
|
||||
* <blockquote><code>
|
||||
* KeyInfoFactory factory = KeyInfoFactory.getInstance("DOM");
|
||||
* </code></blockquote>
|
||||
*
|
||||
* <p>The objects that this factory produces will be based
|
||||
* on DOM and abide by the DOM interoperability requirements as defined in the
|
||||
* <a href="../../../../../../technotes/guides/security/xmldsig/overview.html#DOM Mechanism Requirements">
|
||||
* DOM Mechanism Requirements</a> section of the API overview. See the
|
||||
* <a href="../../../../../../technotes/guides/security/xmldsig/overview.html#Service Provider">
|
||||
* Service Providers</a> section of the API overview for a list of standard
|
||||
* mechanism types.
|
||||
*
|
||||
* <p><code>KeyInfoFactory</code> implementations are registered and loaded
|
||||
* using the {@link java.security.Provider} mechanism.
|
||||
* For example, a service provider that supports the
|
||||
* DOM mechanism would be specified in the <code>Provider</code> subclass as:
|
||||
* <pre>
|
||||
* put("KeyInfoFactory.DOM", "org.example.DOMKeyInfoFactory");
|
||||
* </pre>
|
||||
*
|
||||
* <p>Also, the <code>XMLStructure</code>s that are created by this factory
|
||||
* may contain state specific to the <code>KeyInfo</code> and are not
|
||||
* intended to be reusable.
|
||||
*
|
||||
* <p>An implementation MUST minimally support the default mechanism type: DOM.
|
||||
*
|
||||
* <p>Note that a caller must use the same <code>KeyInfoFactory</code>
|
||||
* instance to create the <code>XMLStructure</code>s of a particular
|
||||
* <code>KeyInfo</code> object. The behavior is undefined if
|
||||
* <code>XMLStructure</code>s from different providers or different mechanism
|
||||
* types are used together.
|
||||
*
|
||||
* <p><b>Concurrent Access</b>
|
||||
* <p>The static methods of this class are guaranteed to be thread-safe.
|
||||
* Multiple threads may concurrently invoke the static methods defined in this
|
||||
* class with no ill effects.
|
||||
*
|
||||
* <p>However, this is not true for the non-static methods defined by this
|
||||
* class. Unless otherwise documented by a specific provider, threads that
|
||||
* need to access a single <code>KeyInfoFactory</code> instance concurrently
|
||||
* should synchronize amongst themselves and provide the necessary locking.
|
||||
* Multiple threads each manipulating a different <code>KeyInfoFactory</code>
|
||||
* instance need not synchronize.
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
*/
|
||||
public abstract class KeyInfoFactory {
|
||||
|
||||
private String mechanismType;
|
||||
private Provider provider;
|
||||
|
||||
/**
|
||||
* Default constructor, for invocation by subclasses.
|
||||
*/
|
||||
protected KeyInfoFactory() {}
|
||||
|
||||
/**
|
||||
* Returns a <code>KeyInfoFactory</code> that supports the
|
||||
* specified XML processing mechanism and representation type (ex: "DOM").
|
||||
*
|
||||
* <p>This method uses the standard JCA provider lookup mechanism to
|
||||
* locate and instantiate a <code>KeyInfoFactory</code> implementation of
|
||||
* the desired mechanism type. It traverses the list of registered security
|
||||
* <code>Provider</code>s, starting with the most preferred
|
||||
* <code>Provider</code>. A new <code>KeyInfoFactory</code> object
|
||||
* from the first <code>Provider</code> that supports the specified
|
||||
* mechanism is returned.
|
||||
*
|
||||
* <p> Note that the list of registered providers may be retrieved via
|
||||
* the {@link Security#getProviders() Security.getProviders()} method.
|
||||
*
|
||||
* @param mechanismType the type of the XML processing mechanism and
|
||||
* representation. See the <a
|
||||
* href="../../../../../../technotes/guides/security/xmldsig/overview.html#Service Provider">
|
||||
* Service Providers</a> section of the API overview for a list of
|
||||
* standard mechanism types.
|
||||
* @return a new <code>KeyInfoFactory</code>
|
||||
* @throws NullPointerException if <code>mechanismType</code> is
|
||||
* <code>null</code>
|
||||
* @throws NoSuchMechanismException if no <code>Provider</code> supports a
|
||||
* <code>KeyInfoFactory</code> implementation for the specified mechanism
|
||||
* @see Provider
|
||||
*/
|
||||
public static KeyInfoFactory getInstance(String mechanismType) {
|
||||
if (mechanismType == null) {
|
||||
throw new NullPointerException("mechanismType cannot be null");
|
||||
}
|
||||
Instance instance;
|
||||
try {
|
||||
instance = GetInstance.getInstance
|
||||
("KeyInfoFactory", null, mechanismType);
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
throw new NoSuchMechanismException(nsae);
|
||||
}
|
||||
KeyInfoFactory factory = (KeyInfoFactory) instance.impl;
|
||||
factory.mechanismType = mechanismType;
|
||||
factory.provider = instance.provider;
|
||||
return factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a <code>KeyInfoFactory</code> that supports the
|
||||
* requested XML processing mechanism and representation type (ex: "DOM"),
|
||||
* as supplied by the specified provider. Note that the specified
|
||||
* <code>Provider</code> object does not have to be registered in the
|
||||
* provider list.
|
||||
*
|
||||
* @param mechanismType the type of the XML processing mechanism and
|
||||
* representation. See the <a
|
||||
* href="../../../../../../technotes/guides/security/xmldsig/overview.html#Service Provider">
|
||||
* Service Providers</a> section of the API overview for a list of
|
||||
* standard mechanism types.
|
||||
* @param provider the <code>Provider</code> object
|
||||
* @return a new <code>KeyInfoFactory</code>
|
||||
* @throws NullPointerException if <code>mechanismType</code> or
|
||||
* <code>provider</code> are <code>null</code>
|
||||
* @throws NoSuchMechanismException if a <code>KeyInfoFactory</code>
|
||||
* implementation for the specified mechanism is not available from the
|
||||
* specified <code>Provider</code> object
|
||||
* @see Provider
|
||||
*/
|
||||
public static KeyInfoFactory getInstance(String mechanismType,
|
||||
Provider provider) {
|
||||
if (mechanismType == null) {
|
||||
throw new NullPointerException("mechanismType cannot be null");
|
||||
} else if (provider == null) {
|
||||
throw new NullPointerException("provider cannot be null");
|
||||
}
|
||||
|
||||
Instance instance;
|
||||
try {
|
||||
instance = GetInstance.getInstance
|
||||
("KeyInfoFactory", null, mechanismType, provider);
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
throw new NoSuchMechanismException(nsae);
|
||||
}
|
||||
KeyInfoFactory factory = (KeyInfoFactory) instance.impl;
|
||||
factory.mechanismType = mechanismType;
|
||||
factory.provider = instance.provider;
|
||||
return factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a <code>KeyInfoFactory</code> that supports the
|
||||
* requested XML processing mechanism and representation type (ex: "DOM"),
|
||||
* as supplied by the specified provider. The specified provider must be
|
||||
* registered in the security provider list.
|
||||
*
|
||||
* <p>Note that the list of registered providers may be retrieved via
|
||||
* the {@link Security#getProviders() Security.getProviders()} method.
|
||||
*
|
||||
* @param mechanismType the type of the XML processing mechanism and
|
||||
* representation. See the <a
|
||||
* href="../../../../../../technotes/guides/security/xmldsig/overview.html#Service Provider">
|
||||
* Service Providers</a> section of the API overview for a list of
|
||||
* standard mechanism types.
|
||||
* @param provider the string name of the provider
|
||||
* @return a new <code>KeyInfoFactory</code>
|
||||
* @throws NoSuchProviderException if the specified provider is not
|
||||
* registered in the security provider list
|
||||
* @throws NullPointerException if <code>mechanismType</code> or
|
||||
* <code>provider</code> are <code>null</code>
|
||||
* @throws NoSuchMechanismException if a <code>KeyInfoFactory</code>
|
||||
* implementation for the specified mechanism is not available from the
|
||||
* specified provider
|
||||
* @see Provider
|
||||
*/
|
||||
public static KeyInfoFactory getInstance(String mechanismType,
|
||||
String provider) throws NoSuchProviderException {
|
||||
if (mechanismType == null) {
|
||||
throw new NullPointerException("mechanismType cannot be null");
|
||||
} else if (provider == null) {
|
||||
throw new NullPointerException("provider cannot be null");
|
||||
} else if (provider.length() == 0) {
|
||||
throw new NoSuchProviderException();
|
||||
}
|
||||
|
||||
Instance instance;
|
||||
try {
|
||||
instance = GetInstance.getInstance
|
||||
("KeyInfoFactory", null, mechanismType, provider);
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
throw new NoSuchMechanismException(nsae);
|
||||
}
|
||||
KeyInfoFactory factory = (KeyInfoFactory) instance.impl;
|
||||
factory.mechanismType = mechanismType;
|
||||
factory.provider = instance.provider;
|
||||
return factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a <code>KeyInfoFactory</code> that supports the
|
||||
* default XML processing mechanism and representation type ("DOM").
|
||||
*
|
||||
* <p>This method uses the standard JCA provider lookup mechanism to
|
||||
* locate and instantiate a <code>KeyInfoFactory</code> implementation of
|
||||
* the default mechanism type. It traverses the list of registered security
|
||||
* <code>Provider</code>s, starting with the most preferred
|
||||
* <code>Provider</code>. A new <code>KeyInfoFactory</code> object
|
||||
* from the first <code>Provider</code> that supports the DOM mechanism is
|
||||
* returned.
|
||||
*
|
||||
* <p> Note that the list of registered providers may be retrieved via
|
||||
* the {@link Security#getProviders() Security.getProviders()} method.
|
||||
*
|
||||
* @return a new <code>KeyInfoFactory</code>
|
||||
* @throws NoSuchMechanismException if no <code>Provider</code> supports a
|
||||
* <code>KeyInfoFactory</code> implementation for the DOM mechanism
|
||||
* @see Provider
|
||||
*/
|
||||
public static KeyInfoFactory getInstance() {
|
||||
return getInstance("DOM");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of the XML processing mechanism and representation
|
||||
* supported by this <code>KeyInfoFactory</code> (ex: "DOM")
|
||||
*
|
||||
* @return the XML processing mechanism type supported by this
|
||||
* <code>KeyInfoFactory</code>
|
||||
*/
|
||||
public final String getMechanismType() {
|
||||
return mechanismType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the provider of this <code>KeyInfoFactory</code>.
|
||||
*
|
||||
* @return the provider of this <code>KeyInfoFactory</code>
|
||||
*/
|
||||
public final Provider getProvider() {
|
||||
return provider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>KeyInfo</code> containing the specified list of
|
||||
* key information types.
|
||||
*
|
||||
* @param content a list of one or more {@link XMLStructure}s representing
|
||||
* key information types. The list is defensively copied to protect
|
||||
* against subsequent modification.
|
||||
* @return a <code>KeyInfo</code>
|
||||
* @throws NullPointerException if <code>content</code> is <code>null</code>
|
||||
* @throws IllegalArgumentException if <code>content</code> is empty
|
||||
* @throws ClassCastException if <code>content</code> contains any entries
|
||||
* that are not of type {@link XMLStructure}
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public abstract KeyInfo newKeyInfo(List content);
|
||||
|
||||
/**
|
||||
* Creates a <code>KeyInfo</code> containing the specified list of key
|
||||
* information types and optional id. The
|
||||
* <code>id</code> parameter represents the value of an XML
|
||||
* <code>ID</code> attribute and is useful for referencing
|
||||
* the <code>KeyInfo</code> from other XML structures.
|
||||
*
|
||||
* @param content a list of one or more {@link XMLStructure}s representing
|
||||
* key information types. The list is defensively copied to protect
|
||||
* against subsequent modification.
|
||||
* @param id the value of an XML <code>ID</code> (may be <code>null</code>)
|
||||
* @return a <code>KeyInfo</code>
|
||||
* @throws NullPointerException if <code>content</code> is <code>null</code>
|
||||
* @throws IllegalArgumentException if <code>content</code> is empty
|
||||
* @throws ClassCastException if <code>content</code> contains any entries
|
||||
* that are not of type {@link XMLStructure}
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public abstract KeyInfo newKeyInfo(List content, String id);
|
||||
|
||||
/**
|
||||
* Creates a <code>KeyName</code> from the specified name.
|
||||
*
|
||||
* @param name the name that identifies the key
|
||||
* @return a <code>KeyName</code>
|
||||
* @throws NullPointerException if <code>name</code> is <code>null</code>
|
||||
*/
|
||||
public abstract KeyName newKeyName(String name);
|
||||
|
||||
/**
|
||||
* Creates a <code>KeyValue</code> from the specified public key.
|
||||
*
|
||||
* @param key the public key
|
||||
* @return a <code>KeyValue</code>
|
||||
* @throws KeyException if the <code>key</code>'s algorithm is not
|
||||
* recognized or supported by this <code>KeyInfoFactory</code>
|
||||
* @throws NullPointerException if <code>key</code> is <code>null</code>
|
||||
*/
|
||||
public abstract KeyValue newKeyValue(PublicKey key) throws KeyException;
|
||||
|
||||
/**
|
||||
* Creates a <code>PGPData</code> from the specified PGP public key
|
||||
* identifier.
|
||||
*
|
||||
* @param keyId a PGP public key identifier as defined in <a href=
|
||||
* "http://www.ietf.org/rfc/rfc2440.txt">RFC 2440</a>, section 11.2.
|
||||
* The array is cloned to protect against subsequent modification.
|
||||
* @return a <code>PGPData</code>
|
||||
* @throws NullPointerException if <code>keyId</code> is <code>null</code>
|
||||
* @throws IllegalArgumentException if the key id is not in the correct
|
||||
* format
|
||||
*/
|
||||
public abstract PGPData newPGPData(byte[] keyId);
|
||||
|
||||
/**
|
||||
* Creates a <code>PGPData</code> from the specified PGP public key
|
||||
* identifier, and optional key material packet and list of external
|
||||
* elements.
|
||||
*
|
||||
* @param keyId a PGP public key identifier as defined in <a href=
|
||||
* "http://www.ietf.org/rfc/rfc2440.txt">RFC 2440</a>, section 11.2.
|
||||
* The array is cloned to protect against subsequent modification.
|
||||
* @param keyPacket a PGP key material packet as defined in <a href=
|
||||
* "http://www.ietf.org/rfc/rfc2440.txt">RFC 2440</a>, section 5.5.
|
||||
* The array is cloned to protect against subsequent modification. May
|
||||
* be <code>null</code>.
|
||||
* @param other a list of {@link XMLStructure}s representing elements from
|
||||
* an external namespace. The list is defensively copied to protect
|
||||
* against subsequent modification. May be <code>null</code> or empty.
|
||||
* @return a <code>PGPData</code>
|
||||
* @throws NullPointerException if <code>keyId</code> is <code>null</code>
|
||||
* @throws IllegalArgumentException if the <code>keyId</code> or
|
||||
* <code>keyPacket</code> is not in the correct format. For
|
||||
* <code>keyPacket</code>, the format of the packet header is
|
||||
* checked and the tag is verified that it is of type key material. The
|
||||
* contents and format of the packet body are not checked.
|
||||
* @throws ClassCastException if <code>other</code> contains any
|
||||
* entries that are not of type {@link XMLStructure}
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public abstract PGPData newPGPData(byte[] keyId, byte[] keyPacket,
|
||||
List other);
|
||||
|
||||
/**
|
||||
* Creates a <code>PGPData</code> from the specified PGP key material
|
||||
* packet and optional list of external elements.
|
||||
*
|
||||
* @param keyPacket a PGP key material packet as defined in <a href=
|
||||
* "http://www.ietf.org/rfc/rfc2440.txt">RFC 2440</a>, section 5.5.
|
||||
* The array is cloned to protect against subsequent modification.
|
||||
* @param other a list of {@link XMLStructure}s representing elements from
|
||||
* an external namespace. The list is defensively copied to protect
|
||||
* against subsequent modification. May be <code>null</code> or empty.
|
||||
* @return a <code>PGPData</code>
|
||||
* @throws NullPointerException if <code>keyPacket</code> is
|
||||
* <code>null</code>
|
||||
* @throws IllegalArgumentException if <code>keyPacket</code> is not in the
|
||||
* correct format. For <code>keyPacket</code>, the format of the packet
|
||||
* header is checked and the tag is verified that it is of type key
|
||||
* material. The contents and format of the packet body are not checked.
|
||||
* @throws ClassCastException if <code>other</code> contains any
|
||||
* entries that are not of type {@link XMLStructure}
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public abstract PGPData newPGPData(byte[] keyPacket, List other);
|
||||
|
||||
/**
|
||||
* Creates a <code>RetrievalMethod</code> from the specified URI.
|
||||
*
|
||||
* @param uri the URI that identifies the <code>KeyInfo</code> information
|
||||
* to be retrieved
|
||||
* @return a <code>RetrievalMethod</code>
|
||||
* @throws NullPointerException if <code>uri</code> is <code>null</code>
|
||||
* @throws IllegalArgumentException if <code>uri</code> is not RFC 2396
|
||||
* compliant
|
||||
*/
|
||||
public abstract RetrievalMethod newRetrievalMethod(String uri);
|
||||
|
||||
/**
|
||||
* Creates a <code>RetrievalMethod</code> from the specified parameters.
|
||||
*
|
||||
* @param uri the URI that identifies the <code>KeyInfo</code> information
|
||||
* to be retrieved
|
||||
* @param type a URI that identifies the type of <code>KeyInfo</code>
|
||||
* information to be retrieved (may be <code>null</code>)
|
||||
* @param transforms a list of {@link Transform}s. The list is defensively
|
||||
* copied to protect against subsequent modification. May be
|
||||
* <code>null</code> or empty.
|
||||
* @return a <code>RetrievalMethod</code>
|
||||
* @throws NullPointerException if <code>uri</code> is <code>null</code>
|
||||
* @throws IllegalArgumentException if <code>uri</code> is not RFC 2396
|
||||
* compliant
|
||||
* @throws ClassCastException if <code>transforms</code> contains any
|
||||
* entries that are not of type {@link Transform}
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public abstract RetrievalMethod newRetrievalMethod(String uri, String type,
|
||||
List transforms);
|
||||
|
||||
/**
|
||||
* Creates a <code>X509Data</code> containing the specified list of
|
||||
* X.509 content.
|
||||
*
|
||||
* @param content a list of one or more X.509 content types. Valid types are
|
||||
* {@link String} (subject names), <code>byte[]</code> (subject key ids),
|
||||
* {@link java.security.cert.X509Certificate}, {@link X509CRL},
|
||||
* or {@link XMLStructure} ({@link X509IssuerSerial}
|
||||
* objects or elements from an external namespace). Subject names are
|
||||
* distinguished names in RFC 2253 String format. Implementations MUST
|
||||
* support the attribute type keywords defined in RFC 2253 (CN, L, ST,
|
||||
* O, OU, C, STREET, DC and UID). Implementations MAY support additional
|
||||
* keywords. The list is defensively copied to protect against
|
||||
* subsequent modification.
|
||||
* @return a <code>X509Data</code>
|
||||
* @throws NullPointerException if <code>content</code> is <code>null</code>
|
||||
* @throws IllegalArgumentException if <code>content</code> is empty, or
|
||||
* if a subject name is not RFC 2253 compliant or one of the attribute
|
||||
* type keywords is not recognized.
|
||||
* @throws ClassCastException if <code>content</code> contains any entries
|
||||
* that are not of one of the valid types mentioned above
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public abstract X509Data newX509Data(List content);
|
||||
|
||||
/**
|
||||
* Creates an <code>X509IssuerSerial</code> from the specified X.500 issuer
|
||||
* distinguished name and serial number.
|
||||
*
|
||||
* @param issuerName the issuer's distinguished name in RFC 2253 String
|
||||
* format. Implementations MUST support the attribute type keywords
|
||||
* defined in RFC 2253 (CN, L, ST, O, OU, C, STREET, DC and UID).
|
||||
* Implementations MAY support additional keywords.
|
||||
* @param serialNumber the serial number
|
||||
* @return an <code>X509IssuerSerial</code>
|
||||
* @throws NullPointerException if <code>issuerName</code> or
|
||||
* <code>serialNumber</code> are <code>null</code>
|
||||
* @throws IllegalArgumentException if the issuer name is not RFC 2253
|
||||
* compliant or one of the attribute type keywords is not recognized.
|
||||
*/
|
||||
public abstract X509IssuerSerial newX509IssuerSerial
|
||||
(String issuerName, BigInteger serialNumber);
|
||||
|
||||
/**
|
||||
* Indicates whether a specified feature is supported.
|
||||
*
|
||||
* @param feature the feature name (as an absolute URI)
|
||||
* @return <code>true</code> if the specified feature is supported,
|
||||
* <code>false</code> otherwise
|
||||
* @throws NullPointerException if <code>feature</code> is <code>null</code>
|
||||
*/
|
||||
public abstract boolean isFeatureSupported(String feature);
|
||||
|
||||
/**
|
||||
* Returns a reference to the <code>URIDereferencer</code> that is used by
|
||||
* default to dereference URIs in {@link RetrievalMethod} objects.
|
||||
*
|
||||
* @return a reference to the default <code>URIDereferencer</code>
|
||||
*/
|
||||
public abstract URIDereferencer getURIDereferencer();
|
||||
|
||||
/**
|
||||
* Unmarshals a new <code>KeyInfo</code> instance from a
|
||||
* mechanism-specific <code>XMLStructure</code> (ex: {@link DOMStructure})
|
||||
* instance.
|
||||
*
|
||||
* @param xmlStructure a mechanism-specific XML structure from which to
|
||||
* unmarshal the keyinfo from
|
||||
* @return the <code>KeyInfo</code>
|
||||
* @throws NullPointerException if <code>xmlStructure</code> is
|
||||
* <code>null</code>
|
||||
* @throws ClassCastException if the type of <code>xmlStructure</code> is
|
||||
* inappropriate for this factory
|
||||
* @throws MarshalException if an unrecoverable exception occurs during
|
||||
* unmarshalling
|
||||
*/
|
||||
public abstract KeyInfo unmarshalKeyInfo(XMLStructure xmlStructure)
|
||||
throws MarshalException;
|
||||
}
|
||||
67
jdkSrc/jdk8/javax/xml/crypto/dsig/keyinfo/KeyName.java
Normal file
67
jdkSrc/jdk8/javax/xml/crypto/dsig/keyinfo/KeyName.java
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: KeyName.java,v 1.4 2005/05/10 16:35:35 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig.keyinfo;
|
||||
|
||||
import javax.xml.crypto.XMLStructure;
|
||||
|
||||
/**
|
||||
* A representation of the XML <code>KeyName</code> element as
|
||||
* defined in the <a href="http://www.w3.org/TR/xmldsig-core/">
|
||||
* W3C Recommendation for XML-Signature Syntax and Processing</a>.
|
||||
* A <code>KeyName</code> object contains a string value which may be used
|
||||
* by the signer to communicate a key identifier to the recipient. The
|
||||
* XML Schema Definition is defined as:
|
||||
*
|
||||
* <pre>
|
||||
* <element name="KeyName" type="string"/>
|
||||
* </pre>
|
||||
*
|
||||
* A <code>KeyName</code> instance may be created by invoking the
|
||||
* {@link KeyInfoFactory#newKeyName newKeyName} method of the
|
||||
* {@link KeyInfoFactory} class, and passing it a <code>String</code>
|
||||
* representing the name of the key; for example:
|
||||
* <pre>
|
||||
* KeyInfoFactory factory = KeyInfoFactory.getInstance("DOM");
|
||||
* KeyName keyName = factory.newKeyName("Alice");
|
||||
* </pre>
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
* @see KeyInfoFactory#newKeyName(String)
|
||||
*/
|
||||
public interface KeyName extends XMLStructure {
|
||||
|
||||
/**
|
||||
* Returns the name of this <code>KeyName</code>.
|
||||
*
|
||||
* @return the name of this <code>KeyName</code> (never
|
||||
* <code>null</code>)
|
||||
*/
|
||||
String getName();
|
||||
}
|
||||
134
jdkSrc/jdk8/javax/xml/crypto/dsig/keyinfo/KeyValue.java
Normal file
134
jdkSrc/jdk8/javax/xml/crypto/dsig/keyinfo/KeyValue.java
Normal file
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: KeyValue.java,v 1.4 2005/05/10 16:35:35 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig.keyinfo;
|
||||
|
||||
import java.security.KeyException;
|
||||
import java.security.KeyStore;
|
||||
import java.security.PublicKey;
|
||||
import java.security.interfaces.DSAPublicKey;
|
||||
import java.security.interfaces.RSAPublicKey;
|
||||
import javax.xml.crypto.XMLStructure;
|
||||
|
||||
/**
|
||||
* A representation of the XML <code>KeyValue</code> element as defined
|
||||
* in the <a href="http://www.w3.org/TR/xmldsig-core/">
|
||||
* W3C Recommendation for XML-Signature Syntax and Processing</a>. A
|
||||
* <code>KeyValue</code> object contains a single public key that may be
|
||||
* useful in validating the signature. The XML schema definition is defined as:
|
||||
*
|
||||
* <pre>
|
||||
* <element name="KeyValue" type="ds:KeyValueType"/>
|
||||
* <complexType name="KeyValueType" mixed="true">
|
||||
* <choice>
|
||||
* <element ref="ds:DSAKeyValue"/>
|
||||
* <element ref="ds:RSAKeyValue"/>
|
||||
* <any namespace="##other" processContents="lax"/>
|
||||
* </choice>
|
||||
* </complexType>
|
||||
*
|
||||
* <element name="DSAKeyValue" type="ds:DSAKeyValueType"/>
|
||||
* <complexType name="DSAKeyValueType">
|
||||
* <sequence>
|
||||
* <sequence minOccurs="0">
|
||||
* <element name="P" type="ds:CryptoBinary"/>
|
||||
* <element name="Q" type="ds:CryptoBinary"/>
|
||||
* </sequence>
|
||||
* <element name="G" type="ds:CryptoBinary" minOccurs="0"/>
|
||||
* <element name="Y" type="ds:CryptoBinary"/>
|
||||
* <element name="J" type="ds:CryptoBinary" minOccurs="0"/>
|
||||
* <sequence minOccurs="0">
|
||||
* <element name="Seed" type="ds:CryptoBinary"/>
|
||||
* <element name="PgenCounter" type="ds:CryptoBinary"/>
|
||||
* </sequence>
|
||||
* </sequence>
|
||||
* </complexType>
|
||||
*
|
||||
* <element name="RSAKeyValue" type="ds:RSAKeyValueType"/>
|
||||
* <complexType name="RSAKeyValueType">
|
||||
* <sequence>
|
||||
* <element name="Modulus" type="ds:CryptoBinary"/>
|
||||
* <element name="Exponent" type="ds:CryptoBinary"/>
|
||||
* </sequence>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
* A <code>KeyValue</code> instance may be created by invoking the
|
||||
* {@link KeyInfoFactory#newKeyValue newKeyValue} method of the
|
||||
* {@link KeyInfoFactory} class, and passing it a {@link
|
||||
* java.security.PublicKey} representing the value of the public key. Here is
|
||||
* an example of creating a <code>KeyValue</code> from a {@link DSAPublicKey}
|
||||
* of a {@link java.security.cert.Certificate} stored in a
|
||||
* {@link java.security.KeyStore}:
|
||||
* <pre>
|
||||
* KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
|
||||
* PublicKey dsaPublicKey = keyStore.getCertificate("myDSASigningCert").getPublicKey();
|
||||
* KeyInfoFactory factory = KeyInfoFactory.getInstance("DOM");
|
||||
* KeyValue keyValue = factory.newKeyValue(dsaPublicKey);
|
||||
* </pre>
|
||||
*
|
||||
* This class returns the <code>DSAKeyValue</code> and
|
||||
* <code>RSAKeyValue</code> elements as objects of type
|
||||
* {@link DSAPublicKey} and {@link RSAPublicKey}, respectively. Note that not
|
||||
* all of the fields in the schema are accessible as parameters of these
|
||||
* types.
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
* @see KeyInfoFactory#newKeyValue(PublicKey)
|
||||
*/
|
||||
public interface KeyValue extends XMLStructure {
|
||||
|
||||
/**
|
||||
* URI identifying the DSA KeyValue KeyInfo type:
|
||||
* http://www.w3.org/2000/09/xmldsig#DSAKeyValue. This can be specified as
|
||||
* the value of the <code>type</code> parameter of the
|
||||
* {@link RetrievalMethod} class to describe a remote
|
||||
* <code>DSAKeyValue</code> structure.
|
||||
*/
|
||||
final static String DSA_TYPE =
|
||||
"http://www.w3.org/2000/09/xmldsig#DSAKeyValue";
|
||||
|
||||
/**
|
||||
* URI identifying the RSA KeyValue KeyInfo type:
|
||||
* http://www.w3.org/2000/09/xmldsig#RSAKeyValue. This can be specified as
|
||||
* the value of the <code>type</code> parameter of the
|
||||
* {@link RetrievalMethod} class to describe a remote
|
||||
* <code>RSAKeyValue</code> structure.
|
||||
*/
|
||||
final static String RSA_TYPE =
|
||||
"http://www.w3.org/2000/09/xmldsig#RSAKeyValue";
|
||||
|
||||
/**
|
||||
* Returns the public key of this <code>KeyValue</code>.
|
||||
*
|
||||
* @return the public key of this <code>KeyValue</code>
|
||||
* @throws KeyException if this <code>KeyValue</code> cannot be converted
|
||||
* to a <code>PublicKey</code>
|
||||
*/
|
||||
PublicKey getPublicKey() throws KeyException;
|
||||
}
|
||||
117
jdkSrc/jdk8/javax/xml/crypto/dsig/keyinfo/PGPData.java
Normal file
117
jdkSrc/jdk8/javax/xml/crypto/dsig/keyinfo/PGPData.java
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: PGPData.java,v 1.4 2005/05/10 16:35:35 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig.keyinfo;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import javax.xml.crypto.XMLStructure;
|
||||
|
||||
/**
|
||||
* A representation of the XML <code>PGPData</code> element as defined in
|
||||
* the <a href="http://www.w3.org/TR/xmldsig-core/">
|
||||
* W3C Recommendation for XML-Signature Syntax and Processing</a>. A
|
||||
* <code>PGPData</code> object is used to convey information related to
|
||||
* PGP public key pairs and signatures on such keys. The XML Schema Definition
|
||||
* is defined as:
|
||||
*
|
||||
* <pre>
|
||||
* <element name="PGPData" type="ds:PGPDataType"/>
|
||||
* <complexType name="PGPDataType">
|
||||
* <choice>
|
||||
* <sequence>
|
||||
* <element name="PGPKeyID" type="base64Binary"/>
|
||||
* <element name="PGPKeyPacket" type="base64Binary" minOccurs="0"/>
|
||||
* <any namespace="##other" processContents="lax" minOccurs="0"
|
||||
* maxOccurs="unbounded"/>
|
||||
* </sequence>
|
||||
* <sequence>
|
||||
* <element name="PGPKeyPacket" type="base64Binary"/>
|
||||
* <any namespace="##other" processContents="lax" minOccurs="0"
|
||||
* maxOccurs="unbounded"/>
|
||||
* </sequence>
|
||||
* </choice>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
* A <code>PGPData</code> instance may be created by invoking one of the
|
||||
* {@link KeyInfoFactory#newPGPData newPGPData} methods of the {@link
|
||||
* KeyInfoFactory} class, and passing it
|
||||
* <code>byte</code> arrays representing the contents of the PGP public key
|
||||
* identifier and/or PGP key material packet, and an optional list of
|
||||
* elements from an external namespace.
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
* @see KeyInfoFactory#newPGPData(byte[])
|
||||
* @see KeyInfoFactory#newPGPData(byte[], byte[], List)
|
||||
* @see KeyInfoFactory#newPGPData(byte[], List)
|
||||
*/
|
||||
public interface PGPData extends XMLStructure {
|
||||
|
||||
/**
|
||||
* URI identifying the PGPData KeyInfo type:
|
||||
* http://www.w3.org/2000/09/xmldsig#PGPData. This can be specified as the
|
||||
* value of the <code>type</code> parameter of the {@link RetrievalMethod}
|
||||
* class to describe a remote <code>PGPData</code> structure.
|
||||
*/
|
||||
final static String TYPE = "http://www.w3.org/2000/09/xmldsig#PGPData";
|
||||
|
||||
/**
|
||||
* Returns the PGP public key identifier of this <code>PGPData</code> as
|
||||
* defined in <a href="http://www.ietf.org/rfc/rfc2440.txt">RFC 2440</a>,
|
||||
* section 11.2.
|
||||
*
|
||||
* @return the PGP public key identifier (may be <code>null</code> if
|
||||
* not specified). Each invocation of this method returns a new clone
|
||||
* to protect against subsequent modification.
|
||||
*/
|
||||
byte[] getKeyId();
|
||||
|
||||
/**
|
||||
* Returns the PGP key material packet of this <code>PGPData</code> as
|
||||
* defined in <a href="http://www.ietf.org/rfc/rfc2440.txt">RFC 2440</a>,
|
||||
* section 5.5.
|
||||
*
|
||||
* @return the PGP key material packet (may be <code>null</code> if not
|
||||
* specified). Each invocation of this method returns a new clone to
|
||||
* protect against subsequent modification.
|
||||
*/
|
||||
byte[] getKeyPacket();
|
||||
|
||||
/**
|
||||
* Returns an {@link Collections#unmodifiableList unmodifiable list}
|
||||
* of {@link XMLStructure}s representing elements from an external
|
||||
* namespace.
|
||||
*
|
||||
* @return an unmodifiable list of <code>XMLStructure</code>s (may be
|
||||
* empty, but never <code>null</code>)
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
List getExternalElements();
|
||||
}
|
||||
113
jdkSrc/jdk8/javax/xml/crypto/dsig/keyinfo/RetrievalMethod.java
Normal file
113
jdkSrc/jdk8/javax/xml/crypto/dsig/keyinfo/RetrievalMethod.java
Normal file
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: RetrievalMethod.java,v 1.8 2005/05/10 16:35:35 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig.keyinfo;
|
||||
|
||||
import javax.xml.crypto.Data;
|
||||
import javax.xml.crypto.URIReference;
|
||||
import javax.xml.crypto.URIReferenceException;
|
||||
import javax.xml.crypto.XMLCryptoContext;
|
||||
import javax.xml.crypto.XMLStructure;
|
||||
import javax.xml.crypto.dsig.Transform;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A representation of the XML <code>RetrievalMethod</code> element as
|
||||
* defined in the <a href="http://www.w3.org/TR/xmldsig-core/">
|
||||
* W3C Recommendation for XML-Signature Syntax and Processing</a>.
|
||||
* A <code>RetrievalMethod</code> object is used to convey a reference to
|
||||
* <code>KeyInfo</code> information that is stored at another location.
|
||||
* The XML schema definition is defined as:
|
||||
*
|
||||
* <pre>
|
||||
* <element name="RetrievalMethod" type="ds:RetrievalMethodType"/>
|
||||
* <complexType name="RetrievalMethodType">
|
||||
* <sequence>
|
||||
* <element name="Transforms" type="ds:TransformsType" minOccurs="0"/>
|
||||
* </sequence>
|
||||
* <attribute name="URI" type="anyURI"/>
|
||||
* <attribute name="Type" type="anyURI" use="optional"/>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
* A <code>RetrievalMethod</code> instance may be created by invoking one of the
|
||||
* {@link KeyInfoFactory#newRetrievalMethod newRetrievalMethod} methods
|
||||
* of the {@link KeyInfoFactory} class, and passing it the URI
|
||||
* identifying the location of the KeyInfo, an optional type URI identifying
|
||||
* the type of KeyInfo, and an optional list of {@link Transform}s; for example:
|
||||
* <pre>
|
||||
* KeyInfoFactory factory = KeyInfoFactory.getInstance("DOM");
|
||||
* RetrievalMethod rm = factory.newRetrievalMethod
|
||||
* ("#KeyValue-1", KeyValue.DSA_TYPE, Collections.singletonList(Transform.BASE64));
|
||||
* </pre>
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
* @see KeyInfoFactory#newRetrievalMethod(String)
|
||||
* @see KeyInfoFactory#newRetrievalMethod(String, String, List)
|
||||
*/
|
||||
public interface RetrievalMethod extends URIReference, XMLStructure {
|
||||
|
||||
/**
|
||||
* Returns an {@link java.util.Collections#unmodifiableList unmodifiable
|
||||
* list} of {@link Transform}s of this <code>RetrievalMethod</code>.
|
||||
*
|
||||
* @return an unmodifiable list of <code>Transform</code> objects (may be
|
||||
* empty but never <code>null</code>).
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
List getTransforms();
|
||||
|
||||
/**
|
||||
* Returns the URI of the referenced <code>KeyInfo</code> information.
|
||||
*
|
||||
* @return the URI of the referenced <code>KeyInfo</code> information in
|
||||
* RFC 2396 format (never <code>null</code>)
|
||||
*/
|
||||
String getURI();
|
||||
|
||||
/**
|
||||
* Dereferences the <code>KeyInfo</code> information referenced by this
|
||||
* <code>RetrievalMethod</code> and applies the specified
|
||||
* <code>Transform</code>s.
|
||||
*
|
||||
* @param context an <code>XMLCryptoContext</code> that may contain
|
||||
* additional useful information for dereferencing the URI. The
|
||||
* context's <code>baseURI</code> and <code>dereferencer</code>
|
||||
* parameters (if specified) are used to resolve and dereference this
|
||||
* <code>RetrievalMethod</code>
|
||||
* @return a <code>Data</code> object representing the raw contents of the
|
||||
* <code>KeyInfo</code> information referenced by this
|
||||
* <code>RetrievalMethod</code>. It is the caller's responsibility to
|
||||
* convert the returned data to an appropriate
|
||||
* <code>KeyInfo</code> object.
|
||||
* @throws NullPointerException if <code>context</code> is <code>null</code>
|
||||
* @throws URIReferenceException if there is an error while dereferencing
|
||||
*/
|
||||
Data dereference(XMLCryptoContext context) throws URIReferenceException;
|
||||
}
|
||||
114
jdkSrc/jdk8/javax/xml/crypto/dsig/keyinfo/X509Data.java
Normal file
114
jdkSrc/jdk8/javax/xml/crypto/dsig/keyinfo/X509Data.java
Normal file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: X509Data.java,v 1.4 2005/05/10 16:35:35 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig.keyinfo;
|
||||
|
||||
import javax.xml.crypto.XMLStructure;
|
||||
import java.security.cert.X509CRL;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A representation of the XML <code>X509Data</code> element as defined in
|
||||
* the <a href="http://www.w3.org/TR/xmldsig-core/">
|
||||
* W3C Recommendation for XML-Signature Syntax and Processing</a>. An
|
||||
* <code>X509Data</code> object contains one or more identifers of keys
|
||||
* or X.509 certificates (or certificates' identifiers or a revocation list).
|
||||
* The XML Schema Definition is defined as:
|
||||
*
|
||||
* <pre>
|
||||
* <element name="X509Data" type="ds:X509DataType"/>
|
||||
* <complexType name="X509DataType">
|
||||
* <sequence maxOccurs="unbounded">
|
||||
* <choice>
|
||||
* <element name="X509IssuerSerial" type="ds:X509IssuerSerialType"/>
|
||||
* <element name="X509SKI" type="base64Binary"/>
|
||||
* <element name="X509SubjectName" type="string"/>
|
||||
* <element name="X509Certificate" type="base64Binary"/>
|
||||
* <element name="X509CRL" type="base64Binary"/>
|
||||
* <any namespace="##other" processContents="lax"/>
|
||||
* </choice>
|
||||
* </sequence>
|
||||
* </complexType>
|
||||
*
|
||||
* <complexType name="X509IssuerSerialType">
|
||||
* <sequence>
|
||||
* <element name="X509IssuerName" type="string"/>
|
||||
* <element name="X509SerialNumber" type="integer"/>
|
||||
* </sequence>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
* An <code>X509Data</code> instance may be created by invoking the
|
||||
* {@link KeyInfoFactory#newX509Data newX509Data} methods of the
|
||||
* {@link KeyInfoFactory} class and passing it a list of one or more
|
||||
* {@link XMLStructure}s representing X.509 content; for example:
|
||||
* <pre>
|
||||
* KeyInfoFactory factory = KeyInfoFactory.getInstance("DOM");
|
||||
* X509Data x509Data = factory.newX509Data
|
||||
* (Collections.singletonList("cn=Alice"));
|
||||
* </pre>
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
* @see KeyInfoFactory#newX509Data(List)
|
||||
*/
|
||||
//@@@ check for illegal combinations of data violating MUSTs in W3c spec
|
||||
public interface X509Data extends XMLStructure {
|
||||
|
||||
/**
|
||||
* URI identifying the X509Data KeyInfo type:
|
||||
* http://www.w3.org/2000/09/xmldsig#X509Data. This can be specified as
|
||||
* the value of the <code>type</code> parameter of the
|
||||
* {@link RetrievalMethod} class to describe a remote
|
||||
* <code>X509Data</code> structure.
|
||||
*/
|
||||
final static String TYPE = "http://www.w3.org/2000/09/xmldsig#X509Data";
|
||||
|
||||
/**
|
||||
* URI identifying the binary (ASN.1 DER) X.509 Certificate KeyInfo type:
|
||||
* http://www.w3.org/2000/09/xmldsig#rawX509Certificate. This can be
|
||||
* specified as the value of the <code>type</code> parameter of the
|
||||
* {@link RetrievalMethod} class to describe a remote X509 Certificate.
|
||||
*/
|
||||
final static String RAW_X509_CERTIFICATE_TYPE =
|
||||
"http://www.w3.org/2000/09/xmldsig#rawX509Certificate";
|
||||
|
||||
/**
|
||||
* Returns an {@link java.util.Collections#unmodifiableList unmodifiable
|
||||
* list} of the content in this <code>X509Data</code>. Valid types are
|
||||
* {@link String} (subject names), <code>byte[]</code> (subject key ids),
|
||||
* {@link java.security.cert.X509Certificate}, {@link X509CRL},
|
||||
* or {@link XMLStructure} ({@link X509IssuerSerial}
|
||||
* objects or elements from an external namespace).
|
||||
*
|
||||
* @return an unmodifiable list of the content in this <code>X509Data</code>
|
||||
* (never <code>null</code> or empty)
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
List getContent();
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: X509IssuerSerial.java,v 1.4 2005/05/10 16:35:35 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig.keyinfo;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.security.cert.X509Certificate;
|
||||
import javax.xml.crypto.XMLStructure;
|
||||
|
||||
/**
|
||||
* A representation of the XML <code>X509IssuerSerial</code> element as
|
||||
* defined in the <a href="http://www.w3.org/TR/xmldsig-core/">
|
||||
* W3C Recommendation for XML-Signature Syntax and Processing</a>.
|
||||
* An <code>X509IssuerSerial</code> object contains an X.509 issuer
|
||||
* distinguished name (DN) and serial number pair. The XML schema definition is
|
||||
* defined as:
|
||||
*
|
||||
* <pre>
|
||||
* <element name="X509IssuerSerial" type="ds:X509IssuerSerialType"/>
|
||||
* <complexType name="X509IssuerSerialType">
|
||||
* <sequence>
|
||||
* <element name="X509IssuerName" type="string"/>
|
||||
* <element name="X509SerialNumber" type="integer"/>
|
||||
* </sequence>
|
||||
* </complexType>
|
||||
* </pre>
|
||||
*
|
||||
* An <code>X509IssuerSerial</code> instance may be created by invoking the
|
||||
* {@link KeyInfoFactory#newX509IssuerSerial newX509IssuerSerial} method
|
||||
* of the {@link KeyInfoFactory} class, and passing it a
|
||||
* <code>String</code> and <code>BigInteger</code> representing the X.500
|
||||
* DN and serial number. Here is an example of creating an
|
||||
* <code>X509IssuerSerial</code> from the issuer DN and serial number of an
|
||||
* existing {@link X509Certificate}:
|
||||
* <pre>
|
||||
* KeyInfoFactory factory = KeyInfoFactory.getInstance("DOM");
|
||||
* X509IssuerSerial issuer = factory.newX509IssuerSerial
|
||||
* (cert.getIssuerX500Principal().getName(), cert.getSerialNumber());
|
||||
* </pre>
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
* @see X509Data#getContent
|
||||
* @see KeyInfoFactory#newX509IssuerSerial(String, BigInteger)
|
||||
*/
|
||||
public interface X509IssuerSerial extends XMLStructure {
|
||||
|
||||
/**
|
||||
* Returns the X.500 distinguished name of this
|
||||
* <code>X509IssuerSerial</code> in
|
||||
* <a href="http://www.ietf.org/rfc/rfc2253.txt">RFC 2253</a> String format.
|
||||
*
|
||||
* @return the X.500 distinguished name in RFC 2253 String format (never
|
||||
* <code>null</code>)
|
||||
*/
|
||||
String getIssuerName();
|
||||
|
||||
/**
|
||||
* Returns the serial number of this <code>X509IssuerSerial</code>.
|
||||
*
|
||||
* @return the serial number (never <code>null</code>)
|
||||
*/
|
||||
BigInteger getSerialNumber();
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: C14NMethodParameterSpec.java,v 1.3 2005/05/10 16:40:17 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig.spec;
|
||||
|
||||
import javax.xml.crypto.dsig.CanonicalizationMethod;
|
||||
|
||||
/**
|
||||
* A specification of algorithm parameters for a {@link CanonicalizationMethod}
|
||||
* Algorithm. The purpose of this interface is to group (and provide type
|
||||
* safety for) all canonicalization (C14N) parameter specifications. All
|
||||
* canonicalization parameter specifications must implement this interface.
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
* @see CanonicalizationMethod
|
||||
*/
|
||||
public interface C14NMethodParameterSpec extends TransformParameterSpec {}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: DigestMethodParameterSpec.java,v 1.3 2005/05/10 16:40:17 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig.spec;
|
||||
|
||||
import javax.xml.crypto.dsig.DigestMethod;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
|
||||
/**
|
||||
* A specification of algorithm parameters for a {@link DigestMethod}
|
||||
* algorithm. The purpose of this interface is to group (and provide type
|
||||
* safety for) all digest method parameter specifications. All digest method
|
||||
* parameter specifications must implement this interface.
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
* @see DigestMethod
|
||||
*/
|
||||
public interface DigestMethodParameterSpec extends AlgorithmParameterSpec {}
|
||||
121
jdkSrc/jdk8/javax/xml/crypto/dsig/spec/ExcC14NParameterSpec.java
Normal file
121
jdkSrc/jdk8/javax/xml/crypto/dsig/spec/ExcC14NParameterSpec.java
Normal file
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: ExcC14NParameterSpec.java,v 1.7 2005/05/13 18:45:42 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig.spec;
|
||||
|
||||
import javax.xml.crypto.dsig.CanonicalizationMethod;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Parameters for the W3C Recommendation:
|
||||
* <a href="http://www.w3.org/TR/xml-exc-c14n/">
|
||||
* Exclusive XML Canonicalization (C14N) algorithm</a>. The
|
||||
* parameters include an optional inclusive namespace prefix list. The XML
|
||||
* Schema Definition of the Exclusive XML Canonicalization parameters is
|
||||
* defined as:
|
||||
* <pre><code>
|
||||
* <schema xmlns="http://www.w3.org/2001/XMLSchema"
|
||||
* xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#"
|
||||
* targetNamespace="http://www.w3.org/2001/10/xml-exc-c14n#"
|
||||
* version="0.1" elementFormDefault="qualified">
|
||||
*
|
||||
* <element name="InclusiveNamespaces" type="ec:InclusiveNamespaces"/>
|
||||
* <complexType name="InclusiveNamespaces">
|
||||
* <attribute name="PrefixList" type="xsd:string"/>
|
||||
* </complexType>
|
||||
* </schema>
|
||||
* </code></pre>
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
* @see CanonicalizationMethod
|
||||
*/
|
||||
public final class ExcC14NParameterSpec implements C14NMethodParameterSpec {
|
||||
|
||||
private List<String> preList;
|
||||
|
||||
/**
|
||||
* Indicates the default namespace ("#default").
|
||||
*/
|
||||
public static final String DEFAULT = "#default";
|
||||
|
||||
/**
|
||||
* Creates a <code>ExcC14NParameterSpec</code> with an empty prefix
|
||||
* list.
|
||||
*/
|
||||
public ExcC14NParameterSpec() {
|
||||
preList = Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>ExcC14NParameterSpec</code> with the specified list
|
||||
* of prefixes. The list is copied to protect against subsequent
|
||||
* modification.
|
||||
*
|
||||
* @param prefixList the inclusive namespace prefix list. Each entry in
|
||||
* the list is a <code>String</code> that represents a namespace prefix.
|
||||
* @throws NullPointerException if <code>prefixList</code> is
|
||||
* <code>null</code>
|
||||
* @throws ClassCastException if any of the entries in the list are not
|
||||
* of type <code>String</code>
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public ExcC14NParameterSpec(List prefixList) {
|
||||
if (prefixList == null) {
|
||||
throw new NullPointerException("prefixList cannot be null");
|
||||
}
|
||||
List<?> copy = new ArrayList<>((List<?>)prefixList);
|
||||
for (int i = 0, size = copy.size(); i < size; i++) {
|
||||
if (!(copy.get(i) instanceof String)) {
|
||||
throw new ClassCastException("not a String");
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> temp = (List<String>)copy;
|
||||
|
||||
preList = Collections.unmodifiableList(temp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the inclusive namespace prefix list. Each entry in the list
|
||||
* is a <code>String</code> that represents a namespace prefix.
|
||||
*
|
||||
* <p>This implementation returns an {@link
|
||||
* java.util.Collections#unmodifiableList unmodifiable list}.
|
||||
*
|
||||
* @return the inclusive namespace prefix list (may be empty but never
|
||||
* <code>null</code>)
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public List getPrefixList() {
|
||||
return preList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: HMACParameterSpec.java,v 1.4 2005/05/10 16:40:17 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig.spec;
|
||||
|
||||
import javax.xml.crypto.dsig.SignatureMethod;
|
||||
|
||||
/**
|
||||
* Parameters for the <a href="http://www.w3.org/TR/xmldsig-core/#sec-MACs">
|
||||
* XML Signature HMAC Algorithm</a>. The parameters include an optional output
|
||||
* length which specifies the MAC truncation length in bits. The resulting
|
||||
* HMAC will be truncated to the specified number of bits. If the parameter is
|
||||
* not specified, then this implies that all the bits of the hash are to be
|
||||
* output. The XML Schema Definition of the <code>HMACOutputLength</code>
|
||||
* element is defined as:
|
||||
* <pre><code>
|
||||
* <element name="HMACOutputLength" minOccurs="0" type="ds:HMACOutputLengthType"/>
|
||||
* <simpleType name="HMACOutputLengthType">
|
||||
* <restriction base="integer"/>
|
||||
* </simpleType>
|
||||
* </code></pre>
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
* @see SignatureMethod
|
||||
* @see <a href="http://www.ietf.org/rfc/rfc2104.txt">RFC 2104</a>
|
||||
*/
|
||||
public final class HMACParameterSpec implements SignatureMethodParameterSpec {
|
||||
|
||||
private int outputLength;
|
||||
|
||||
/**
|
||||
* Creates an <code>HMACParameterSpec</code> with the specified truncation
|
||||
* length.
|
||||
*
|
||||
* @param outputLength the truncation length in number of bits
|
||||
*/
|
||||
public HMACParameterSpec(int outputLength) {
|
||||
this.outputLength = outputLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the truncation length.
|
||||
*
|
||||
* @return the truncation length in number of bits
|
||||
*/
|
||||
public int getOutputLength() {
|
||||
return outputLength;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: SignatureMethodParameterSpec.java,v 1.3 2005/05/10 16:40:17 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig.spec;
|
||||
|
||||
import javax.xml.crypto.dsig.SignatureMethod;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
|
||||
/**
|
||||
* A specification of algorithm parameters for an XML {@link SignatureMethod}
|
||||
* algorithm. The purpose of this interface is to group (and provide type
|
||||
* safety for) all signature method parameter specifications. All signature
|
||||
* method parameter specifications must implement this interface.
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
* @see SignatureMethod
|
||||
*/
|
||||
public interface SignatureMethodParameterSpec extends AlgorithmParameterSpec {}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: TransformParameterSpec.java,v 1.3 2005/05/10 16:40:17 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig.spec;
|
||||
|
||||
import javax.xml.crypto.dsig.Transform;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
|
||||
/**
|
||||
* A specification of algorithm parameters for a {@link Transform}
|
||||
* algorithm. The purpose of this interface is to group (and provide type
|
||||
* safety for) all transform parameter specifications. All transform parameter
|
||||
* specifications must implement this interface.
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
* @see Transform
|
||||
*/
|
||||
public interface TransformParameterSpec extends AlgorithmParameterSpec {}
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: XPathFilter2ParameterSpec.java,v 1.7 2005/05/13 18:45:42 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig.spec;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import javax.xml.crypto.dsig.Transform;
|
||||
|
||||
/**
|
||||
* Parameters for the W3C Recommendation
|
||||
* <a href="http://www.w3.org/TR/xmldsig-filter2/">
|
||||
* XPath Filter 2.0 Transform Algorithm</a>.
|
||||
* The parameters include a list of one or more {@link XPathType} objects.
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
* @see Transform
|
||||
* @see XPathFilterParameterSpec
|
||||
*/
|
||||
public final class XPathFilter2ParameterSpec implements TransformParameterSpec {
|
||||
|
||||
private final List<XPathType> xPathList;
|
||||
|
||||
/**
|
||||
* Creates an <code>XPathFilter2ParameterSpec</code>.
|
||||
*
|
||||
* @param xPathList a list of one or more {@link XPathType} objects. The
|
||||
* list is defensively copied to protect against subsequent modification.
|
||||
* @throws ClassCastException if <code>xPathList</code> contains any
|
||||
* entries that are not of type {@link XPathType}
|
||||
* @throws IllegalArgumentException if <code>xPathList</code> is empty
|
||||
* @throws NullPointerException if <code>xPathList</code> is
|
||||
* <code>null</code>
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public XPathFilter2ParameterSpec(List xPathList) {
|
||||
if (xPathList == null) {
|
||||
throw new NullPointerException("xPathList cannot be null");
|
||||
}
|
||||
List<?> xPathListCopy = new ArrayList<>((List<?>)xPathList);
|
||||
if (xPathListCopy.isEmpty()) {
|
||||
throw new IllegalArgumentException("xPathList cannot be empty");
|
||||
}
|
||||
int size = xPathListCopy.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (!(xPathListCopy.get(i) instanceof XPathType)) {
|
||||
throw new ClassCastException
|
||||
("xPathList["+i+"] is not a valid type");
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<XPathType> temp = (List<XPathType>)xPathListCopy;
|
||||
|
||||
this.xPathList = Collections.unmodifiableList(temp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of one or more {@link XPathType} objects.
|
||||
* <p>
|
||||
* This implementation returns an {@link Collections#unmodifiableList
|
||||
* unmodifiable list}.
|
||||
*
|
||||
* @return a <code>List</code> of <code>XPathType</code> objects
|
||||
* (never <code>null</code> or empty)
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public List getXPathList() {
|
||||
return xPathList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: XPathFilterParameterSpec.java,v 1.4 2005/05/10 16:40:17 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig.spec;
|
||||
|
||||
import javax.xml.crypto.dsig.Transform;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* Parameters for the <a href="http://www.w3.org/TR/xmldsig-core/#sec-XPath">
|
||||
* XPath Filtering Transform Algorithm</a>.
|
||||
* The parameters include the XPath expression and an optional <code>Map</code>
|
||||
* of additional namespace prefix mappings. The XML Schema Definition of
|
||||
* the XPath Filtering transform parameters is defined as:
|
||||
* <pre><code>
|
||||
* <element name="XPath" type="string"/>
|
||||
* </code></pre>
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
* @see Transform
|
||||
*/
|
||||
public final class XPathFilterParameterSpec implements TransformParameterSpec {
|
||||
|
||||
private String xPath;
|
||||
private Map<String,String> nsMap;
|
||||
|
||||
/**
|
||||
* Creates an <code>XPathFilterParameterSpec</code> with the specified
|
||||
* XPath expression.
|
||||
*
|
||||
* @param xPath the XPath expression to be evaluated
|
||||
* @throws NullPointerException if <code>xPath</code> is <code>null</code>
|
||||
*/
|
||||
public XPathFilterParameterSpec(String xPath) {
|
||||
if (xPath == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
this.xPath = xPath;
|
||||
this.nsMap = Collections.emptyMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an <code>XPathFilterParameterSpec</code> with the specified
|
||||
* XPath expression and namespace map. The map is copied to protect against
|
||||
* subsequent modification.
|
||||
*
|
||||
* @param xPath the XPath expression to be evaluated
|
||||
* @param namespaceMap the map of namespace prefixes. Each key is a
|
||||
* namespace prefix <code>String</code> that maps to a corresponding
|
||||
* namespace URI <code>String</code>.
|
||||
* @throws NullPointerException if <code>xPath</code> or
|
||||
* <code>namespaceMap</code> are <code>null</code>
|
||||
* @throws ClassCastException if any of the map's keys or entries are not
|
||||
* of type <code>String</code>
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public XPathFilterParameterSpec(String xPath, Map namespaceMap) {
|
||||
if (xPath == null || namespaceMap == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
this.xPath = xPath;
|
||||
Map<?,?> copy = new HashMap<>((Map<?,?>)namespaceMap);
|
||||
Iterator<? extends Map.Entry<?,?>> entries = copy.entrySet().iterator();
|
||||
while (entries.hasNext()) {
|
||||
Map.Entry<?,?> me = entries.next();
|
||||
if (!(me.getKey() instanceof String) ||
|
||||
!(me.getValue() instanceof String)) {
|
||||
throw new ClassCastException("not a String");
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String,String> temp = (Map<String,String>)copy;
|
||||
|
||||
nsMap = Collections.unmodifiableMap(temp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the XPath expression to be evaluated.
|
||||
*
|
||||
* @return the XPath expression to be evaluated
|
||||
*/
|
||||
public String getXPath() {
|
||||
return xPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a map of namespace prefixes. Each key is a namespace prefix
|
||||
* <code>String</code> that maps to a corresponding namespace URI
|
||||
* <code>String</code>.
|
||||
* <p>
|
||||
* This implementation returns an {@link Collections#unmodifiableMap
|
||||
* unmodifiable map}.
|
||||
*
|
||||
* @return a <code>Map</code> of namespace prefixes to namespace URIs (may
|
||||
* be empty, but never <code>null</code>)
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Map getNamespaceMap() {
|
||||
return nsMap;
|
||||
}
|
||||
}
|
||||
205
jdkSrc/jdk8/javax/xml/crypto/dsig/spec/XPathType.java
Normal file
205
jdkSrc/jdk8/javax/xml/crypto/dsig/spec/XPathType.java
Normal file
@@ -0,0 +1,205 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: XPathType.java,v 1.4 2005/05/10 16:40:17 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig.spec;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* The XML Schema Definition of the <code>XPath</code> element as defined in the
|
||||
* <a href="http://www.w3.org/TR/xmldsig-filter2">
|
||||
* W3C Recommendation for XML-Signature XPath Filter 2.0</a>:
|
||||
* <pre><code>
|
||||
* <schema xmlns="http://www.w3.org/2001/XMLSchema"
|
||||
* xmlns:xf="http://www.w3.org/2002/06/xmldsig-filter2"
|
||||
* targetNamespace="http://www.w3.org/2002/06/xmldsig-filter2"
|
||||
* version="0.1" elementFormDefault="qualified">
|
||||
*
|
||||
* <element name="XPath"
|
||||
* type="xf:XPathType"/>
|
||||
*
|
||||
* <complexType name="XPathType">
|
||||
* <simpleContent>
|
||||
* <extension base="string">
|
||||
* <attribute name="Filter">
|
||||
* <simpleType>
|
||||
* <restriction base="string">
|
||||
* <enumeration value="intersect"/>
|
||||
* <enumeration value="subtract"/>
|
||||
* <enumeration value="union"/>
|
||||
* </restriction>
|
||||
* </simpleType>
|
||||
* </attribute>
|
||||
* </extension>
|
||||
* </simpleContent>
|
||||
* </complexType>
|
||||
* </code></pre>
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
* @see XPathFilter2ParameterSpec
|
||||
*/
|
||||
public class XPathType {
|
||||
|
||||
/**
|
||||
* Represents the filter set operation.
|
||||
*/
|
||||
public static class Filter {
|
||||
private final String operation;
|
||||
|
||||
private Filter(String operation) {
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string form of the operation.
|
||||
*
|
||||
* @return the string form of the operation
|
||||
*/
|
||||
public String toString() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
/**
|
||||
* The intersect filter operation.
|
||||
*/
|
||||
public static final Filter INTERSECT = new Filter("intersect");
|
||||
|
||||
/**
|
||||
* The subtract filter operation.
|
||||
*/
|
||||
public static final Filter SUBTRACT = new Filter("subtract");
|
||||
|
||||
/**
|
||||
* The union filter operation.
|
||||
*/
|
||||
public static final Filter UNION = new Filter("union");
|
||||
}
|
||||
|
||||
private final String expression;
|
||||
private final Filter filter;
|
||||
private Map<String,String> nsMap;
|
||||
|
||||
/**
|
||||
* Creates an <code>XPathType</code> instance with the specified XPath
|
||||
* expression and filter.
|
||||
*
|
||||
* @param expression the XPath expression to be evaluated
|
||||
* @param filter the filter operation ({@link Filter#INTERSECT},
|
||||
* {@link Filter#SUBTRACT}, or {@link Filter#UNION})
|
||||
* @throws NullPointerException if <code>expression</code> or
|
||||
* <code>filter</code> is <code>null</code>
|
||||
*/
|
||||
public XPathType(String expression, Filter filter) {
|
||||
if (expression == null) {
|
||||
throw new NullPointerException("expression cannot be null");
|
||||
}
|
||||
if (filter == null) {
|
||||
throw new NullPointerException("filter cannot be null");
|
||||
}
|
||||
this.expression = expression;
|
||||
this.filter = filter;
|
||||
this.nsMap = Collections.emptyMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an <code>XPathType</code> instance with the specified XPath
|
||||
* expression, filter, and namespace map. The map is copied to protect
|
||||
* against subsequent modification.
|
||||
*
|
||||
* @param expression the XPath expression to be evaluated
|
||||
* @param filter the filter operation ({@link Filter#INTERSECT},
|
||||
* {@link Filter#SUBTRACT}, or {@link Filter#UNION})
|
||||
* @param namespaceMap the map of namespace prefixes. Each key is a
|
||||
* namespace prefix <code>String</code> that maps to a corresponding
|
||||
* namespace URI <code>String</code>.
|
||||
* @throws NullPointerException if <code>expression</code>,
|
||||
* <code>filter</code> or <code>namespaceMap</code> are
|
||||
* <code>null</code>
|
||||
* @throws ClassCastException if any of the map's keys or entries are
|
||||
* not of type <code>String</code>
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public XPathType(String expression, Filter filter, Map namespaceMap) {
|
||||
this(expression, filter);
|
||||
if (namespaceMap == null) {
|
||||
throw new NullPointerException("namespaceMap cannot be null");
|
||||
}
|
||||
Map<?,?> copy = new HashMap<>((Map<?,?>)namespaceMap);
|
||||
Iterator<? extends Map.Entry<?,?>> entries = copy.entrySet().iterator();
|
||||
while (entries.hasNext()) {
|
||||
Map.Entry<?,?> me = entries.next();
|
||||
if (!(me.getKey() instanceof String) ||
|
||||
!(me.getValue() instanceof String)) {
|
||||
throw new ClassCastException("not a String");
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String,String> temp = (Map<String,String>)copy;
|
||||
|
||||
nsMap = Collections.unmodifiableMap(temp);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the XPath expression to be evaluated.
|
||||
*
|
||||
* @return the XPath expression to be evaluated
|
||||
*/
|
||||
public String getExpression() {
|
||||
return expression;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the filter operation.
|
||||
*
|
||||
* @return the filter operation
|
||||
*/
|
||||
public Filter getFilter() {
|
||||
return filter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a map of namespace prefixes. Each key is a namespace prefix
|
||||
* <code>String</code> that maps to a corresponding namespace URI
|
||||
* <code>String</code>.
|
||||
* <p>
|
||||
* This implementation returns an {@link Collections#unmodifiableMap
|
||||
* unmodifiable map}.
|
||||
*
|
||||
* @return a <code>Map</code> of namespace prefixes to namespace URIs
|
||||
* (may be empty, but never <code>null</code>)
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Map getNamespaceMap() {
|
||||
return nsMap;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
/*
|
||||
* $Id: XSLTTransformParameterSpec.java,v 1.4 2005/05/10 16:40:18 mullan Exp $
|
||||
*/
|
||||
package javax.xml.crypto.dsig.spec;
|
||||
|
||||
import javax.xml.crypto.dsig.Transform;
|
||||
import javax.xml.crypto.XMLStructure;
|
||||
|
||||
/**
|
||||
* Parameters for the <a href="http://www.w3.org/TR/1999/REC-xslt-19991116">
|
||||
* XSLT Transform Algorithm</a>.
|
||||
* The parameters include a namespace-qualified stylesheet element.
|
||||
*
|
||||
* <p>An <code>XSLTTransformParameterSpec</code> is instantiated with a
|
||||
* mechanism-dependent (ex: DOM) stylesheet element. For example:
|
||||
* <pre>
|
||||
* DOMStructure stylesheet = new DOMStructure(element)
|
||||
* XSLTTransformParameterSpec spec = new XSLTransformParameterSpec(stylesheet);
|
||||
* </pre>
|
||||
* where <code>element</code> is an {@link org.w3c.dom.Element} containing
|
||||
* the namespace-qualified stylesheet element.
|
||||
*
|
||||
* @author Sean Mullan
|
||||
* @author JSR 105 Expert Group
|
||||
* @since 1.6
|
||||
* @see Transform
|
||||
*/
|
||||
public final class XSLTTransformParameterSpec implements TransformParameterSpec{
|
||||
private XMLStructure stylesheet;
|
||||
|
||||
/**
|
||||
* Creates an <code>XSLTTransformParameterSpec</code> with the specified
|
||||
* stylesheet.
|
||||
*
|
||||
* @param stylesheet the XSLT stylesheet to be used
|
||||
* @throws NullPointerException if <code>stylesheet</code> is
|
||||
* <code>null</code>
|
||||
*/
|
||||
public XSLTTransformParameterSpec(XMLStructure stylesheet) {
|
||||
if (stylesheet == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
this.stylesheet = stylesheet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the stylesheet.
|
||||
*
|
||||
* @return the stylesheet
|
||||
*/
|
||||
public XMLStructure getStylesheet() {
|
||||
return stylesheet;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user