feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
@@ -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