KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > org > apache > xml > internal > security > keys > content > RetrievalMethod


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17 package com.sun.org.apache.xml.internal.security.keys.content;
18
19
20
21
22 import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
23 import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException;
24 import com.sun.org.apache.xml.internal.security.transforms.Transforms;
25 import com.sun.org.apache.xml.internal.security.utils.Constants;
26 import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy;
27 import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
28 import org.w3c.dom.Attr JavaDoc;
29 import org.w3c.dom.Document JavaDoc;
30 import org.w3c.dom.Element JavaDoc;
31
32
33 /**
34  *
35  * @author $Author: raul $
36  */

37 public class RetrievalMethod extends SignatureElementProxy
38         implements KeyInfoContent {
39
40    /** {@link java.util.logging} logging facility */
41     static java.util.logging.Logger JavaDoc log =
42         java.util.logging.Logger.getLogger(RetrievalMethod.class.getName());
43    //J-
44
/** DSA retrieval */
45    public static final String JavaDoc TYPE_DSA = Constants.SignatureSpecNS + "DSAKeyValue";
46    /** RSA retrieval */
47    public static final String JavaDoc TYPE_RSA = Constants.SignatureSpecNS + "RSAKeyValue";
48    /** PGP retrieval */
49    public static final String JavaDoc TYPE_PGP = Constants.SignatureSpecNS + "PGPData";
50    /** SPKI retrieval */
51    public static final String JavaDoc TYPE_SPKI = Constants.SignatureSpecNS + "SPKIData";
52    /** MGMT retrieval */
53    public static final String JavaDoc TYPE_MGMT = Constants.SignatureSpecNS + "MgmtData";
54    /** X509 retrieval */
55    public static final String JavaDoc TYPE_X509 = Constants.SignatureSpecNS + "X509Data";
56    /** RAWX509 retrieval */
57    public static final String JavaDoc TYPE_RAWX509 = Constants.SignatureSpecNS + "rawX509Certificate";
58    //J+
59

60    /**
61     * Constructor RetrievalMethod
62     *
63     * @param element
64     * @param BaseURI
65     * @throws XMLSecurityException
66     */

67    public RetrievalMethod(Element JavaDoc element, String JavaDoc BaseURI)
68            throws XMLSecurityException {
69       super(element, BaseURI);
70    }
71
72    /**
73     * Constructor RetrievalMethod
74     *
75     * @param doc
76     * @param URI
77     * @param transforms
78     * @param Type
79     */

80    public RetrievalMethod(Document JavaDoc doc, String JavaDoc URI, Transforms transforms,
81                           String JavaDoc Type) {
82
83       super(doc);
84
85       this._constructionElement.setAttributeNS(null, Constants._ATT_URI, URI);
86
87       if (Type != null) {
88          this._constructionElement.setAttributeNS(null, Constants._ATT_TYPE, Type);
89       }
90
91       if (transforms != null) {
92          this._constructionElement.appendChild(transforms.getElement());
93          XMLUtils.addReturnToElement(this._constructionElement);
94       }
95    }
96
97    /**
98     * Method getURIAttr
99     *
100     * @return the URI attribute
101     */

102    public Attr JavaDoc getURIAttr() {
103       return this._constructionElement.getAttributeNodeNS(null, Constants._ATT_URI);
104    }
105
106    /**
107     * Method getURI
108     *
109     *
110     * @return URI string
111     */

112    public String JavaDoc getURI() {
113       return this.getURIAttr().getNodeValue();
114    }
115
116    /** @return the type*/
117    public String JavaDoc getType() {
118       return this._constructionElement.getAttributeNS(null, Constants._ATT_TYPE);
119    }
120
121    /**
122     * Method getTransforms
123     *
124     *
125     * @throws XMLSecurityException
126     * @return the transforamitons
127     */

128    public Transforms getTransforms() throws XMLSecurityException {
129
130       try {
131        Element JavaDoc transformsElem =
132              XMLUtils.selectDsNode(this._constructionElement,
133                                                 Constants
134                                                    ._TAG_TRANSFORMS, 0);
135
136          if (transformsElem != null) {
137             return new Transforms(transformsElem, this._baseURI);
138          }
139
140          return null;
141       } catch (XMLSignatureException ex) {
142          throw new XMLSecurityException("empty", ex);
143       }
144    }
145    
146    /** @inheritDoc */
147    public String JavaDoc getBaseLocalName() {
148       return Constants._TAG_RETRIEVALMETHOD;
149    }
150 }
151
Popular Tags