Java class for anonymous complex type. 28 | * 29 | *
The following schema fragment specifies the expected content contained within this class. 30 | * 31 | *
32 | * <complexType> 33 | * <complexContent> 34 | * <restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> 35 | * <sequence> 36 | * <element name="minor" type="{http://www.w3.org/2001/XMLSchema}short"/> 37 | * <element name="major" type="{http://www.w3.org/2001/XMLSchema}short"/> 38 | * </sequence> 39 | * </restriction> 40 | * </complexContent> 41 | * </complexType> 42 | *43 | * 44 | * 45 | */ 46 | @XmlAccessorType(XmlAccessType.FIELD) 47 | @XmlType(name = "", propOrder = { 48 | "minor", 49 | "major" 50 | }) 51 | @XmlRootElement(name = "faultDetail") 52 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-28T07:05:22-05:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") 53 | public class FaultDetail { 54 | 55 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-28T07:05:22-05:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") 56 | protected short minor; 57 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-28T07:05:22-05:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") 58 | protected short major; 59 | 60 | /** 61 | * Gets the value of the minor property. 62 | * 63 | */ 64 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-28T07:05:22-05:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") 65 | public short getMinor() { 66 | return minor; 67 | } 68 | 69 | /** 70 | * Sets the value of the minor property. 71 | * 72 | */ 73 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-28T07:05:22-05:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") 74 | public void setMinor(short value) { 75 | this.minor = value; 76 | } 77 | 78 | /** 79 | * Gets the value of the major property. 80 | * 81 | */ 82 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-28T07:05:22-05:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") 83 | public short getMajor() { 84 | return major; 85 | } 86 | 87 | /** 88 | * Sets the value of the major property. 89 | * 90 | */ 91 | @Generated(value = "com.sun.tools.xjc.Driver", date = "2013-01-28T07:05:22-05:00", comments = "JAXB RI vhudson-jaxb-ri-2.1-2") 92 | public void setMajor(short value) { 93 | this.major = value; 94 | } 95 | 96 | } 97 | -------------------------------------------------------------------------------- /java-csp-wss4j/src/test/java/org/company/security/csp/wss4j/test/hello_world_soap_http/Greeter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.company.security.csp.wss4j.test.hello_world_soap_http; 18 | 19 | import javax.jws.Oneway; 20 | import javax.jws.WebMethod; 21 | import javax.jws.WebParam; 22 | import javax.jws.WebResult; 23 | import javax.jws.WebService; 24 | //import javax.xml.bind.annotation.XmlSeeAlso; 25 | import javax.xml.ws.RequestWrapper; 26 | import javax.xml.ws.ResponseWrapper; 27 | 28 | /** 29 | * This class was generated by Apache CXF 2.7.3 30 | * 2013-02-28T10:12:10.684Z 31 | * Generated source version: 2.7.3 32 | * 33 | */ 34 | @WebService(targetNamespace = "http://apache.org/hello_world_soap_http", name = "Greeter") 35 | //@XmlSeeAlso({org.apache.hello_world_soap_http.types.ObjectFactory.class}) 36 | public interface Greeter { 37 | 38 | @RequestWrapper(localName = "pingMe", targetNamespace = "http://apache.org/hello_world_soap_http/types", className = "org.apache.hello_world_soap_http.types.PingMe") 39 | @WebMethod 40 | @ResponseWrapper(localName = "pingMeResponse", targetNamespace = "http://apache.org/hello_world_soap_http/types", className = "org.apache.hello_world_soap_http.types.PingMeResponse") 41 | public void pingMe() throws PingMeFault; 42 | 43 | @WebResult(name = "responseType", targetNamespace = "http://apache.org/hello_world_soap_http/types") 44 | @RequestWrapper(localName = "sayHi", targetNamespace = "http://apache.org/hello_world_soap_http/types", className = "org.apache.hello_world_soap_http.types.SayHi") 45 | @WebMethod 46 | @ResponseWrapper(localName = "sayHiResponse", targetNamespace = "http://apache.org/hello_world_soap_http/types", className = "org.apache.hello_world_soap_http.types.SayHiResponse") 47 | public java.lang.String sayHi(); 48 | 49 | @Oneway 50 | @RequestWrapper(localName = "greetMeOneWay", targetNamespace = "http://apache.org/hello_world_soap_http/types", className = "org.apache.hello_world_soap_http.types.GreetMeOneWay") 51 | @WebMethod 52 | public void greetMeOneWay( 53 | @WebParam(name = "requestType", targetNamespace = "http://apache.org/hello_world_soap_http/types") 54 | java.lang.String requestType 55 | ); 56 | 57 | @WebResult(name = "responseType", targetNamespace = "http://apache.org/hello_world_soap_http/types") 58 | @RequestWrapper(localName = "greetMe", targetNamespace = "http://apache.org/hello_world_soap_http/types", className = "org.apache.hello_world_soap_http.types.GreetMe") 59 | @WebMethod 60 | @ResponseWrapper(localName = "greetMeResponse", targetNamespace = "http://apache.org/hello_world_soap_http/types", className = "org.apache.hello_world_soap_http.types.GreetMeResponse") 61 | public java.lang.String greetMe( 62 | @WebParam(name = "requestType", targetNamespace = "http://apache.org/hello_world_soap_http/types") 63 | java.lang.String requestType 64 | ); 65 | } 66 | -------------------------------------------------------------------------------- /java-csp-wss4j/src/test/java/org/company/security/csp/wss4j/test/hello_world_soap_http/GreeterServiceImpl.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.company.security.csp.wss4j.test.hello_world_soap_http; 18 | 19 | import javax.annotation.Resource; 20 | import javax.jws.WebParam; 21 | import javax.jws.WebService; 22 | import javax.xml.ws.WebServiceContext; 23 | 24 | //import org.apache.hello_world_soap_http.Greeter; 25 | //import org.apache.hello_world_soap_http.PingMeFault; 26 | 27 | @WebService(targetNamespace = "http://apache.org/hello_world_soap_http", 28 | serviceName = "SOAPService", 29 | endpointInterface = "org.company.security.csp.wss4j.test.hello_world_soap_http.Greeter") 30 | //endpointInterface = "org.apache.hello_world_soap_http.Greeter") 31 | public class GreeterServiceImpl implements Greeter { 32 | 33 | @Resource 34 | WebServiceContext context; 35 | 36 | @Override 37 | public void pingMe() throws PingMeFault { 38 | } 39 | 40 | @Override 41 | public String sayHi() { 42 | return "Hi"; 43 | } 44 | 45 | @Override 46 | public void greetMeOneWay(@WebParam(name = "requestType", targetNamespace = "http://apache.org/hello_world_soap_http/types") String requestType) { 47 | } 48 | 49 | @Override 50 | public String greetMe(@WebParam(name = "requestType", targetNamespace = "http://apache.org/hello_world_soap_http/types") String requestType) { 51 | return requestType; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /java-csp-wss4j/src/test/java/org/company/security/csp/wss4j/test/hello_world_soap_http/PingMeFault.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.company.security.csp.wss4j.test.hello_world_soap_http; 18 | 19 | import javax.xml.ws.WebFault; 20 | 21 | 22 | /** 23 | * This class was generated by Apache CXF 2.7.3 24 | * 2013-02-28T10:12:10.652Z 25 | * Generated source version: 2.7.3 26 | */ 27 | 28 | @WebFault(name = "faultDetail", targetNamespace = "http://apache.org/hello_world_soap_http/types") 29 | public class PingMeFault extends Exception { 30 | private static final long serialVersionUID = -8313446712127506030L; 31 | 32 | private FaultDetail faultDetail; 33 | 34 | public PingMeFault() { 35 | super(); 36 | } 37 | 38 | public PingMeFault(String message) { 39 | super(message); 40 | } 41 | 42 | public PingMeFault(String message, Throwable cause) { 43 | super(message, cause); 44 | } 45 | 46 | public PingMeFault(String message, FaultDetail faultDetail) { 47 | super(message); 48 | this.faultDetail = faultDetail; 49 | } 50 | 51 | public PingMeFault(String message, FaultDetail faultDetail, Throwable cause) { 52 | super(message, cause); 53 | this.faultDetail = faultDetail; 54 | } 55 | 56 | public FaultDetail getFaultInfo() { 57 | return this.faultDetail; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /java-csp-wss4j/src/test/java/org/company/security/csp/wss4j/test/hello_world_soap_http/SOAPService.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.company.security.csp.wss4j.test.hello_world_soap_http; 18 | 19 | import java.net.MalformedURLException; 20 | import java.net.URL; 21 | import javax.xml.namespace.QName; 22 | import javax.xml.ws.WebEndpoint; 23 | import javax.xml.ws.WebServiceClient; 24 | import javax.xml.ws.WebServiceFeature; 25 | import javax.xml.ws.Service; 26 | 27 | /** 28 | * This class was generated by Apache CXF 2.7.3 29 | * 2013-02-28T10:12:10.702Z 30 | * Generated source version: 2.7.3 31 | * 32 | */ 33 | @WebServiceClient(name = "SOAPService", 34 | wsdlLocation = "file:/home/hudson/hudson-slave/workspace/wss4j-trunk/wss4j/cxf-integration/src/test/resources/integration/helloWorld.wsdl", 35 | targetNamespace = "http://apache.org/hello_world_soap_http") 36 | public class SOAPService extends Service { 37 | 38 | public final static URL WSDL_LOCATION; 39 | 40 | public final static QName SERVICE = new QName("http://apache.org/hello_world_soap_http", "SOAPService"); 41 | public final static QName SoapPort = new QName("http://apache.org/hello_world_soap_http", "SoapPort"); 42 | static { 43 | URL url = null; 44 | try { 45 | url = new URL("file:/home/hudson/hudson-slave/workspace/wss4j-trunk/wss4j/cxf-integration/src/test/resources/integration/helloWorld.wsdl"); 46 | } catch (MalformedURLException e) { 47 | java.util.logging.Logger.getLogger(SOAPService.class.getName()) 48 | .log(java.util.logging.Level.INFO, 49 | "Can not initialize the default wsdl from {0}", "file:/home/hudson/hudson-slave/workspace/wss4j-trunk/wss4j/cxf-integration/src/test/resources/integration/helloWorld.wsdl"); 50 | } 51 | WSDL_LOCATION = url; 52 | } 53 | 54 | public SOAPService(URL wsdlLocation) { 55 | super(wsdlLocation, SERVICE); 56 | } 57 | 58 | public SOAPService(URL wsdlLocation, QName serviceName) { 59 | super(wsdlLocation, serviceName); 60 | } 61 | 62 | public SOAPService() { 63 | super(WSDL_LOCATION, SERVICE); 64 | } 65 | 66 | 67 | /** 68 | * 69 | * @return 70 | * returns Greeter 71 | */ 72 | @WebEndpoint(name = "SoapPort") 73 | public Greeter getSoapPort() { 74 | return super.getPort(SoapPort, Greeter.class); 75 | } 76 | 77 | /** 78 | * 79 | * @param features 80 | * A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the
features
parameter will have their default values.
81 | * @return
82 | * returns Greeter
83 | */
84 | @WebEndpoint(name = "SoapPort")
85 | public Greeter getSoapPort(WebServiceFeature... features) {
86 | return super.getPort(SoapPort, Greeter.class, features);
87 | }
88 |
89 | }
90 |
--------------------------------------------------------------------------------
/java-csp-wss4j/src/test/resources/log4j.properties:
--------------------------------------------------------------------------------
1 | log4j.rootLogger=TRACE, out, outfile
2 |
3 | ## CONSOLE appender not used by default
4 | log4j.appender.out=org.apache.log4j.ConsoleAppender
5 | ##log4j.appender.out.threshold=WARN
6 | log4j.appender.out.layout=org.apache.log4j.PatternLayout
7 | log4j.appender.out.layout.ConversionPattern=%d{dd.MM.yy HH:mm:ss} [%30.30t] %-30.30c{1} %-5p %m%n
8 |
9 | log4j.appender.outfile=org.apache.log4j.FileAppender
10 | log4j.appender.outfile.File=target/logging.log
11 | log4j.appender.outfile.layout=org.apache.log4j.PatternLayout
12 | log4j.appender.outfile.layout.ConversionPattern=%d{dd.MM.yy HH:mm:ss} [%30.30t] %-30.30c{1} %-5p %m%n
13 |
14 | log4j.throwableRenderer=org.apache.log4j.EnhancedThrowableRenderer
15 |
--------------------------------------------------------------------------------
/java-csp-wss4j/src/test/resources/receiver-crypto.properties:
--------------------------------------------------------------------------------
1 | org.apache.ws.security.crypto.provider=org.company.security.csp.ws.security.components.crypto.LocalMerlin
2 | org.apache.ws.security.crypto.merlin.cert.provider=CSPProvider
3 | org.apache.ws.security.crypto.merlin.keystore.provider=CSPProvider
4 | org.apache.ws.security.crypto.merlin.keystore.type=Windows-MY
5 | org.apache.ws.security.crypto.merlin.truststore.type=Windows-MY
6 |
--------------------------------------------------------------------------------
/java-csp-wss4j/src/test/resources/transmitter-crypto.properties:
--------------------------------------------------------------------------------
1 | org.apache.ws.security.crypto.provider=org.company.security.csp.ws.security.components.crypto.LocalMerlin
2 | org.apache.ws.security.crypto.merlin.cert.provider=CSPProvider
3 | org.apache.ws.security.crypto.merlin.keystore.provider=CSPProvider
4 | org.apache.ws.security.crypto.merlin.keystore.type=Windows-MY
5 | org.apache.ws.security.crypto.merlin.truststore.type=Windows-MY
6 |
--------------------------------------------------------------------------------
/java-csp-wss4j/src/test/resources/trusted/cert.sst:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/alexey-su/java-csp/e8453480b6a3a9036b03e37d8e108e0b7a1861b2/java-csp-wss4j/src/test/resources/trusted/cert.sst
--------------------------------------------------------------------------------
/java-csp-xmlsec-jsr105/pom.xml:
--------------------------------------------------------------------------------
1 | DOMCanonicalizationMethod
.
46 | *
47 | * @param spi TransformService
48 | */
49 | public DOMCanonicalizationMethod(TransformService spi)
50 | throws InvalidAlgorithmParameterException
51 | {
52 | super(spi);
53 | }
54 |
55 | /**
56 | * Creates a DOMCanonicalizationMethod
from an element. This
57 | * ctor invokes the abstract {@link #unmarshalParams unmarshalParams}
58 | * method to unmarshal any algorithm-specific input parameters.
59 | *
60 | * @param cmElem a CanonicalizationMethod element
61 | */
62 | public DOMCanonicalizationMethod(Element cmElem, XMLCryptoContext context,
63 | Provider provider)
64 | throws MarshalException
65 | {
66 | super(cmElem, context, provider);
67 | }
68 |
69 | /**
70 | * Canonicalizes the specified data using the underlying canonicalization
71 | * algorithm. This is a convenience method that is equivalent to invoking
72 | * the {@link #transform transform} method.
73 | *
74 | * @param data the data to be canonicalized
75 | * @param xc the XMLCryptoContext
containing
76 | * additional context (may be null
if not applicable)
77 | * @return the canonicalized data
78 | * @throws NullPointerException if data
is null
79 | * @throws TransformException if an unexpected error occurs while
80 | * canonicalizing the data
81 | */
82 | public Data canonicalize(Data data, XMLCryptoContext xc)
83 | throws TransformException
84 | {
85 | return transform(data, xc);
86 | }
87 |
88 | public Data canonicalize(Data data, XMLCryptoContext xc, OutputStream os)
89 | throws TransformException
90 | {
91 | return transform(data, xc, os);
92 | }
93 |
94 | @Override
95 | public boolean equals(Object o) {
96 | if (this == o) {
97 | return true;
98 | }
99 |
100 | if (!(o instanceof CanonicalizationMethod)) {
101 | return false;
102 | }
103 | CanonicalizationMethod ocm = (CanonicalizationMethod)o;
104 |
105 | return (getAlgorithm().equals(ocm.getAlgorithm()) &&
106 | DOMUtils.paramsEqual(getParameterSpec(), ocm.getParameterSpec()));
107 | }
108 |
109 | @Override
110 | public int hashCode() {
111 | assert false : "hashCode not designed";
112 | return 42; // any arbitrary constant will do
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/java-csp-xmlsec-jsr105/src/main/java/org/company/security/csp/xml/dsig/internal/dom/DOMDigestMethodFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.company.security.csp.xml.dsig.internal.dom;
18 |
19 | import java.security.InvalidAlgorithmParameterException;
20 | import java.security.MessageDigest;
21 | import java.security.NoSuchAlgorithmException;
22 |
23 | import javax.xml.crypto.MarshalException;
24 | import javax.xml.crypto.dsig.DigestMethod;
25 | import javax.xml.crypto.dsig.spec.DigestMethodParameterSpec;
26 |
27 | import org.apache.xml.security.algorithms.JCEMapper;
28 | import org.w3c.dom.Element;
29 |
30 | public class DOMDigestMethodFactory {
31 |
32 | public DigestMethod unmarshal(Element dmElem) throws MarshalException {
33 | String xmlAlgorithm = DOMUtils.getAttributeValue(dmElem, "Algorithm");
34 | String jceAlgorithm = JCEMapper.translateURItoJCEID(xmlAlgorithm);
35 | DigestMethodParameterSpec params = null;
36 |
37 | if(jceAlgorithm != null) {
38 | try {
39 | MessageDigest.getInstance(jceAlgorithm);
40 | }
41 | catch(NoSuchAlgorithmException e) {
42 | throw new MarshalException("unsupported DigestMethod algorithm: " + xmlAlgorithm, e);
43 | }
44 | }
45 | else {
46 | throw new MarshalException("unsupported DigestMethod algorithm: " + xmlAlgorithm);
47 | }
48 |
49 | DOMDigestMethodProxy proxy = null;
50 | try {
51 | proxy = new DOMDigestMethodProxy(xmlAlgorithm, jceAlgorithm, params);
52 |
53 | Element paramsElem = DOMUtils.getFirstChildElement(dmElem);
54 | if (paramsElem != null) {
55 | params = proxy.unmarshalParams(paramsElem);
56 |
57 | if (params != null) {
58 | proxy.checkParams(params);
59 | proxy = new DOMDigestMethodProxy(xmlAlgorithm, jceAlgorithm, params);
60 | }
61 | }
62 | }
63 | catch (InvalidAlgorithmParameterException iape) {
64 | throw new MarshalException(iape);
65 | }
66 | return proxy;
67 | }
68 |
69 | public DigestMethod newDigestMethod(String algorithm,
70 | DigestMethodParameterSpec params) throws NoSuchAlgorithmException,
71 | InvalidAlgorithmParameterException {
72 |
73 | String jceAlgorithm = JCEMapper.translateURItoJCEID(algorithm);
74 |
75 | if(jceAlgorithm != null) {
76 | MessageDigest.getInstance(jceAlgorithm);
77 | }
78 | else {
79 | throw new NoSuchAlgorithmException("unsupported algorithm " + algorithm);
80 | }
81 |
82 | return new DOMDigestMethodProxy(algorithm, jceAlgorithm, params);
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/java-csp-xmlsec-jsr105/src/main/java/org/company/security/csp/xml/dsig/internal/dom/DOMDigestMethodProxy.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.company.security.csp.xml.dsig.internal.dom;
18 |
19 | import java.security.InvalidAlgorithmParameterException;
20 | import java.security.spec.AlgorithmParameterSpec;
21 |
22 | import javax.xml.crypto.MarshalException;
23 | import javax.xml.crypto.dsig.DigestMethod;
24 | import javax.xml.crypto.dsig.spec.DigestMethodParameterSpec;
25 |
26 | import org.w3c.dom.Element;
27 |
28 | public class DOMDigestMethodProxy extends BaseStructure implements DigestMethod {
29 | private String xmlAlgorithm;
30 | private String jceAlgorithm;
31 | private DigestMethodParameterSpec params;
32 |
33 | public DOMDigestMethodProxy(String xmlAlgorithm, String jceAlgorithm,
34 | DigestMethodParameterSpec params)
35 | throws InvalidAlgorithmParameterException {
36 | this.xmlAlgorithm = xmlAlgorithm;
37 | this.jceAlgorithm = jceAlgorithm;
38 |
39 | if (params != null && !(params instanceof DigestMethodParameterSpec)) {
40 | throw new InvalidAlgorithmParameterException(
41 | "params must be of type DigestMethodParameterSpec");
42 | }
43 | checkParams((DigestMethodParameterSpec) params);
44 | this.params = (DigestMethodParameterSpec) params;
45 | }
46 |
47 | public String getMessageDigestAlgorithm() {
48 | return jceAlgorithm;
49 | }
50 |
51 | @Override
52 | public String getAlgorithm() {
53 | return xmlAlgorithm;
54 | }
55 |
56 | @Override
57 | public AlgorithmParameterSpec getParameterSpec() {
58 | return params;
59 | }
60 |
61 | /**
62 | * Checks if the specified parameters are valid for this algorithm. By
63 | * default, this method throws an exception if parameters are specified
64 | * since most DigestMethod algorithms do not have parameters. Subclasses
65 | * should override it if they have parameters.
66 | *
67 | * @param params
68 | * the algorithm-specific params (may be null
)
69 | * @throws InvalidAlgorithmParameterException
70 | * if the parameters are not appropriate for this digest method
71 | */
72 | void checkParams(DigestMethodParameterSpec params)
73 | throws InvalidAlgorithmParameterException {
74 | if (params != null) {
75 | throw new InvalidAlgorithmParameterException("no parameters "
76 | + "should be specified for the "
77 | + getMessageDigestAlgorithm() + " DigestMethod algorithm");
78 | }
79 | }
80 |
81 | /**
82 | * Unmarshals DigestMethodParameterSpec
from the specified
83 | * Element
. By default, this method throws an exception since
84 | * most DigestMethod algorithms do not have parameters. Subclasses should
85 | * override it if they have parameters.
86 | *
87 | * @param paramsElem
88 | * the Element
holding the input params
89 | * @return the algorithm-specific DigestMethodParameterSpec
90 | * @throws MarshalException
91 | * if the parameters cannot be unmarshalled
92 | */
93 | public DigestMethodParameterSpec unmarshalParams(Element paramsElem)
94 | throws MarshalException {
95 | throw new MarshalException("no parameters should "
96 | + "be specified for the " + getMessageDigestAlgorithm()
97 | + " DigestMethod algorithm");
98 | }
99 | }
100 |
--------------------------------------------------------------------------------
/java-csp-xmlsec-jsr105/src/main/java/org/company/security/csp/xml/dsig/internal/dom/DOMEnvelopedTransform.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 | /*
20 | * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
21 | */
22 | /*
23 | * $Id$
24 | */
25 | package org.company.security.csp.xml.dsig.internal.dom;
26 |
27 | import java.security.InvalidAlgorithmParameterException;
28 | import javax.xml.crypto.dsig.spec.TransformParameterSpec;
29 |
30 | /**
31 | * DOM-based implementation of Enveloped Signature Transform.
32 | * (Uses Apache XML-Sec Transform implementation)
33 | *
34 | * @author Sean Mullan
35 | */
36 | public final class DOMEnvelopedTransform extends ApacheTransform {
37 |
38 | @Override
39 | public void init(TransformParameterSpec params)
40 | throws InvalidAlgorithmParameterException {
41 | if (params != null) {
42 | throw new InvalidAlgorithmParameterException("params must be null");
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/java-csp-xmlsec-jsr105/src/main/java/org/company/security/csp/xml/dsig/internal/dom/DOMKeyInfoFactory.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 | /*
20 | * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
21 | */
22 | /*
23 | * $Id$
24 | */
25 | package org.company.security.csp.xml.dsig.internal.dom;
26 |
27 | import java.math.BigInteger;
28 | import java.security.KeyException;
29 | import java.security.PublicKey;
30 | import java.security.interfaces.DSAPublicKey;
31 | import java.security.interfaces.ECPublicKey;
32 | import java.security.interfaces.RSAPublicKey;
33 | import java.util.List;
34 | import javax.xml.crypto.*;
35 | import javax.xml.crypto.dom.DOMCryptoContext;
36 | import javax.xml.crypto.dsig.keyinfo.*;
37 | import org.w3c.dom.Document;
38 | import org.w3c.dom.Element;
39 | import org.w3c.dom.Node;
40 |
41 | /**
42 | * DOM-based implementation of KeyInfoFactory.
43 | *
44 | * @author Sean Mullan
45 | */
46 | public final class DOMKeyInfoFactory extends KeyInfoFactory {
47 |
48 | public DOMKeyInfoFactory() { }
49 |
50 | @Override
51 | @SuppressWarnings("rawtypes")
52 | public KeyInfo newKeyInfo(List content) {
53 | return newKeyInfo(content, null);
54 | }
55 |
56 | @Override
57 | @SuppressWarnings({ "unchecked", "rawtypes" })
58 | public KeyInfo newKeyInfo(List content, String id) {
59 | return new DOMKeyInfo(content, id);
60 | }
61 |
62 | @Override
63 | public KeyName newKeyName(String name) {
64 | return new DOMKeyName(name);
65 | }
66 |
67 | @Override
68 | public KeyValue newKeyValue(PublicKey key) throws KeyException {
69 | return DOMKeyValue.newKeyValue(key);
70 | }
71 |
72 | @Override
73 | public PGPData newPGPData(byte[] keyId) {
74 | return newPGPData(keyId, null, null);
75 | }
76 |
77 | @Override
78 | @SuppressWarnings({ "rawtypes", "unchecked" })
79 | public PGPData newPGPData(byte[] keyId, byte[] keyPacket, List other) {
80 | return new DOMPGPData(keyId, keyPacket, other);
81 | }
82 |
83 | @Override
84 | @SuppressWarnings({ "unchecked", "rawtypes" })
85 | public PGPData newPGPData(byte[] keyPacket, List other) {
86 | return new DOMPGPData(keyPacket, other);
87 | }
88 |
89 | @Override
90 | public RetrievalMethod newRetrievalMethod(String uri) {
91 | return newRetrievalMethod(uri, null, null);
92 | }
93 |
94 | @Override
95 | @SuppressWarnings({ "unchecked", "rawtypes" })
96 | public RetrievalMethod newRetrievalMethod(String uri, String type,
97 | List transforms) {
98 | if (uri == null) {
99 | throw new NullPointerException("uri must not be null");
100 | }
101 | return new DOMRetrievalMethod(uri, type, transforms);
102 | }
103 |
104 | @Override
105 | @SuppressWarnings("rawtypes")
106 | public X509Data newX509Data(List content) {
107 | return new DOMX509Data(content);
108 | }
109 |
110 | @Override
111 | public X509IssuerSerial newX509IssuerSerial(String issuerName,
112 | BigInteger serialNumber) {
113 | return new DOMX509IssuerSerial(issuerName, serialNumber);
114 | }
115 |
116 | @Override
117 | public boolean isFeatureSupported(String feature) {
118 | if (feature == null) {
119 | throw new NullPointerException();
120 | } else {
121 | return false;
122 | }
123 | }
124 |
125 | @Override
126 | public URIDereferencer getURIDereferencer() {
127 | return DOMURIDereferencer.INSTANCE;
128 | }
129 |
130 | @Override
131 | public KeyInfo unmarshalKeyInfo(XMLStructure xmlStructure)
132 | throws MarshalException {
133 | if (xmlStructure == null || !(xmlStructure instanceof javax.xml.crypto.dom.DOMStructure)) {
134 | throw new ClassCastException("xmlStructure must be of type DOMStructure");
135 | }
136 | Node node =
137 | ((javax.xml.crypto.dom.DOMStructure) xmlStructure).getNode();
138 | node.normalize();
139 |
140 | Element element = null;
141 | if (node.getNodeType() == Node.DOCUMENT_NODE) {
142 | element = ((Document) node).getDocumentElement();
143 | } else if (node.getNodeType() == Node.ELEMENT_NODE) {
144 | element = (Element) node;
145 | } else {
146 | throw new MarshalException
147 | ("xmlStructure does not contain a proper Node");
148 | }
149 |
150 | // check tag
151 | String tag = element.getLocalName();
152 | if (tag == null) {
153 | throw new MarshalException("Document implementation must " +
154 | "support DOM Level 2 and be namespace aware");
155 | }
156 | if (tag.equals("KeyInfo")) {
157 | return new DOMKeyInfo(element, new UnmarshalContext(), getProvider());
158 | } else {
159 | throw new MarshalException("invalid KeyInfo tag: " + tag);
160 | }
161 | }
162 |
163 | private static class UnmarshalContext extends DOMCryptoContext {
164 | UnmarshalContext() {}
165 | }
166 |
167 | }
168 |
--------------------------------------------------------------------------------
/java-csp-xmlsec-jsr105/src/main/java/org/company/security/csp/xml/dsig/internal/dom/DOMKeyName.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 | /*
20 | * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
21 | */
22 | /*
23 | * $Id$
24 | */
25 | package org.company.security.csp.xml.dsig.internal.dom;
26 |
27 | import javax.xml.crypto.dsig.keyinfo.KeyName;
28 |
29 | import org.w3c.dom.Element;
30 |
31 | /**
32 | * DOM-based implementation of KeyName.
33 | *
34 | * @author Sean Mullan
35 | */
36 | public final class DOMKeyName extends BaseStructure implements KeyName {
37 |
38 | private final String name;
39 |
40 | /**
41 | * Creates a DOMKeyName
.
42 | *
43 | * @param name the name of the key identifier
44 | * @throws NullPointerException if name
is null
45 | */
46 | public DOMKeyName(String name) {
47 | if (name == null) {
48 | throw new NullPointerException("name cannot be null");
49 | }
50 | this.name = name;
51 | }
52 |
53 | /**
54 | * Creates a DOMKeyName
from a KeyName element.
55 | *
56 | * @param knElem a KeyName element
57 | */
58 | public DOMKeyName(Element knElem) {
59 | name = textOfNode(knElem);
60 | }
61 |
62 | @Override
63 | public String getName() {
64 | return name;
65 | }
66 |
67 | @Override
68 | public boolean equals(Object obj) {
69 | if (this == obj) {
70 | return true;
71 | }
72 | if (!(obj instanceof KeyName)) {
73 | return false;
74 | }
75 | KeyName okn = (KeyName)obj;
76 | return name.equals(okn.getName());
77 | }
78 |
79 | @Override
80 | public int hashCode() {
81 | int result = 17;
82 | if (name != null) {
83 | result = 31 * result + name.hashCode();
84 | }
85 |
86 | return result;
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/java-csp-xmlsec-jsr105/src/main/java/org/company/security/csp/xml/dsig/internal/dom/DOMStructure.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 | /*
20 | * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
21 | */
22 | /*
23 | * $Id$
24 | */
25 | package org.company.security.csp.xml.dsig.internal.dom;
26 |
27 | import javax.xml.crypto.MarshalException;
28 | import javax.xml.crypto.XMLCryptoContext;
29 |
30 | /**
31 | * DOM-based abstract implementation of XMLStructure.
32 | *
33 | * @author Sean Mullan
34 | */
35 | public abstract class DOMStructure extends BaseStructure {
36 |
37 | public abstract void marshal(XmlWriter xwriter, String dsPrefix, XMLCryptoContext context) throws MarshalException;
38 | }
39 |
--------------------------------------------------------------------------------
/java-csp-xmlsec-jsr105/src/main/java/org/company/security/csp/xml/dsig/internal/dom/DOMURIDereferencer.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 | /*
20 | * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
21 | */
22 | /*
23 | * $Id$
24 | */
25 | package org.company.security.csp.xml.dsig.internal.dom;
26 |
27 | import org.w3c.dom.Attr;
28 | import org.w3c.dom.Element;
29 | import org.w3c.dom.Node;
30 |
31 | import org.apache.xml.security.Init;
32 | import org.apache.xml.security.utils.XMLUtils;
33 | import org.apache.xml.security.utils.resolver.ResourceResolver;
34 | import org.apache.xml.security.signature.XMLSignatureInput;
35 |
36 | import javax.xml.crypto.*;
37 | import javax.xml.crypto.dom.*;
38 |
39 | /**
40 | * DOM-based implementation of URIDereferencer.
41 | *
42 | * @author Sean Mullan
43 | */
44 | public class DOMURIDereferencer implements URIDereferencer {
45 |
46 | static final URIDereferencer INSTANCE = new DOMURIDereferencer();
47 |
48 | private DOMURIDereferencer() {
49 | // need to call org.apache.xml.security.Init.init()
50 | // before calling any apache security code
51 | Init.init();
52 | }
53 |
54 | @Override
55 | public Data dereference(URIReference uriRef, XMLCryptoContext context)
56 | throws URIReferenceException {
57 |
58 | if (uriRef == null) {
59 | throw new NullPointerException("uriRef cannot be null");
60 | }
61 | if (context == null) {
62 | throw new NullPointerException("context cannot be null");
63 | }
64 |
65 | DOMURIReference domRef = (DOMURIReference) uriRef;
66 | Attr uriAttr = (Attr) domRef.getHere();
67 | String uri = uriRef.getURI();
68 | DOMCryptoContext dcc = (DOMCryptoContext) context;
69 | String baseURI = context.getBaseURI();
70 |
71 | Boolean secureValidation = (Boolean)
72 | context.getProperty("org.apache.jcp.xml.dsig.secureValidation");
73 | boolean secVal = false;
74 | if (secureValidation != null && secureValidation) {
75 | secVal = true;
76 | }
77 |
78 | // Check if same-document URI and already registered on the context
79 | if (uri != null && uri.length() != 0 && uri.charAt(0) == '#') {
80 | String id = uri.substring(1);
81 |
82 | if (id.startsWith("xpointer(id(")) {
83 | int i1 = id.indexOf('\'');
84 | int i2 = id.indexOf('\'', i1+1);
85 | id = id.substring(i1+1, i2);
86 | }
87 |
88 | Node referencedElem = dcc.getElementById(id);
89 | if (referencedElem != null) {
90 | if (secVal) {
91 | Element start = referencedElem.getOwnerDocument().getDocumentElement();
92 | if (!XMLUtils.protectAgainstWrappingAttack(start, (Element)referencedElem, id)) {
93 | String error = "Multiple Elements with the same ID " + id + " were detected";
94 | throw new URIReferenceException(error);
95 | }
96 | }
97 |
98 | XMLSignatureInput result = new XMLSignatureInput(referencedElem);
99 | if (!uri.substring(1).startsWith("xpointer(id(")) {
100 | result.setExcludeComments(true);
101 | }
102 |
103 | result.setMIMEType("text/xml");
104 | if (baseURI != null && baseURI.length() > 0) {
105 | result.setSourceURI(baseURI.concat(uriAttr.getNodeValue()));
106 | } else {
107 | result.setSourceURI(uriAttr.getNodeValue());
108 | }
109 | return new ApacheNodeSetData(result);
110 | }
111 | }
112 |
113 | try {
114 | ResourceResolver apacheResolver =
115 | ResourceResolver.getInstance(uriAttr, baseURI, secVal);
116 | XMLSignatureInput in = apacheResolver.resolve(uriAttr, baseURI);
117 | // TODO xmlsec 2.0 change method signature
118 | // XMLSignatureInput in = apacheResolver.resolve(uriAttr, baseURI, secVal);
119 | if (in.isOctetStream()) {
120 | return new ApacheOctetStreamData(in);
121 | } else {
122 | return new ApacheNodeSetData(in);
123 | }
124 | } catch (Exception e) {
125 | throw new URIReferenceException(e);
126 | }
127 | }
128 | }
129 |
--------------------------------------------------------------------------------
/java-csp-xmlsec-jsr105/src/main/java/org/company/security/csp/xml/dsig/internal/dom/DOMX509IssuerSerial.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 | /*
20 | * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
21 | */
22 | /*
23 | * $Id$
24 | */
25 | package org.company.security.csp.xml.dsig.internal.dom;
26 |
27 | import javax.xml.crypto.dsig.keyinfo.X509IssuerSerial;
28 |
29 | import java.math.BigInteger;
30 | import javax.security.auth.x500.X500Principal;
31 | import org.w3c.dom.Element;
32 |
33 | /**
34 | * DOM-based implementation of X509IssuerSerial.
35 | *
36 | * @author Sean Mullan
37 | */
38 | public final class DOMX509IssuerSerial extends BaseStructure
39 | implements X509IssuerSerial {
40 |
41 | private final String issuerName;
42 | private final BigInteger serialNumber;
43 |
44 | /**
45 | * Creates a DOMX509IssuerSerial
containing the specified
46 | * issuer distinguished name/serial number pair.
47 | *
48 | * @param issuerName the X.509 issuer distinguished name in RFC 2253
49 | * String format
50 | * @param serialNumber the serial number
51 | * @throws IllegalArgumentException if the format of issuerName
52 | * is not RFC 2253 compliant
53 | * @throws NullPointerException if issuerName
or
54 | * serialNumber
is null
55 | */
56 | public DOMX509IssuerSerial(String issuerName, BigInteger serialNumber) {
57 | if (issuerName == null) {
58 | throw new NullPointerException("issuerName cannot be null");
59 | }
60 | if (serialNumber == null) {
61 | throw new NullPointerException("serialNumber cannot be null");
62 | }
63 | // check that issuer distinguished name conforms to RFC 2253
64 | new X500Principal(issuerName);
65 | this.issuerName = issuerName;
66 | this.serialNumber = serialNumber;
67 | }
68 |
69 | /**
70 | * Creates a DOMX509IssuerSerial
from an element.
71 | *
72 | * @param isElem an X509IssuerSerial element
73 | */
74 | public DOMX509IssuerSerial(Element isElem) {
75 | Element iNElem = DOMUtils.getFirstChildElement(isElem);
76 | Element sNElem = DOMUtils.getNextSiblingElement(iNElem);
77 | issuerName = iNElem.getFirstChild().getNodeValue();
78 | serialNumber = new BigInteger(sNElem.getFirstChild().getNodeValue());
79 | }
80 |
81 | @Override
82 | public String getIssuerName() {
83 | return issuerName;
84 | }
85 |
86 | @Override
87 | public BigInteger getSerialNumber() {
88 | return serialNumber;
89 | }
90 |
91 | @Override
92 | public boolean equals(Object obj) {
93 | if (this == obj) {
94 | return true;
95 | }
96 | if (!(obj instanceof X509IssuerSerial)) {
97 | return false;
98 | }
99 | X509IssuerSerial ois = (X509IssuerSerial)obj;
100 | return (issuerName.equals(ois.getIssuerName()) &&
101 | serialNumber.equals(ois.getSerialNumber()));
102 | }
103 |
104 | @Override
105 | public int hashCode() {
106 | int result = 17;
107 | if (issuerName != null) {
108 | result = 31 * result + issuerName.hashCode();
109 | }
110 | if (serialNumber != null) {
111 | result = 31 * result + serialNumber.hashCode();
112 | }
113 |
114 | return result;
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/java-csp-xmlsec-jsr105/src/main/java/org/company/security/csp/xml/dsig/internal/dom/DOMXPathTransform.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 | /*
20 | * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
21 | */
22 | /*
23 | * $Id$
24 | */
25 | package org.company.security.csp.xml.dsig.internal.dom;
26 |
27 | import javax.xml.crypto.*;
28 | import javax.xml.crypto.dsig.*;
29 | import javax.xml.crypto.dsig.spec.TransformParameterSpec;
30 | import javax.xml.crypto.dsig.spec.XPathFilterParameterSpec;
31 | import java.security.InvalidAlgorithmParameterException;
32 | import java.util.HashMap;
33 | import java.util.Map;
34 | import java.util.Set;
35 | import org.w3c.dom.Attr;
36 | import org.w3c.dom.Element;
37 | import org.w3c.dom.NamedNodeMap;
38 |
39 | /**
40 | * DOM-based implementation of XPath Filtering Transform.
41 | * (Uses Apache XML-Sec Transform implementation)
42 | *
43 | * @author Sean Mullan
44 | */
45 | public final class DOMXPathTransform extends ApacheTransform {
46 |
47 | @Override
48 | public void init(TransformParameterSpec params)
49 | throws InvalidAlgorithmParameterException
50 | {
51 | if (params == null) {
52 | throw new InvalidAlgorithmParameterException("params are required");
53 | } else if (!(params instanceof XPathFilterParameterSpec)) {
54 | throw new InvalidAlgorithmParameterException
55 | ("params must be of type XPathFilterParameterSpec");
56 | }
57 | this.params = params;
58 | }
59 |
60 | @Override
61 | public void init(XMLStructure parent, XMLCryptoContext context)
62 | throws InvalidAlgorithmParameterException
63 | {
64 | super.init(parent, context);
65 | unmarshalParams(DOMUtils.getFirstChildElement(transformElem));
66 | }
67 |
68 | private void unmarshalParams(Element paramsElem) {
69 | String xPath = paramsElem.getFirstChild().getNodeValue();
70 | // create a Map of namespace prefixes
71 | NamedNodeMap attributes = paramsElem.getAttributes();
72 | if (attributes != null) {
73 | int length = attributes.getLength();
74 | MapThis is written to be similar to javax.xml.stream.XMLStreamWriter, but 32 | * has slightly different requirements. Specifically, we need to be able to create 33 | * an "ID" type attribute, and get the current node. 34 | *
35 | */ 36 | public interface XmlWriter { 37 | 38 | /** 39 | * Utility class that brings together the class, and the method for marshaling an 40 | * instance of said class. 41 | * 42 | * @param