blob: feb8b26d3b587924f010567a29ee398e89bef2bf [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * reserved comment block
3 * DO NOT REMOVE OR ALTER!
4 */
5/*
6 * Copyright 1999-2004 The Apache Software Foundation.
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 *
20 */
21package com.sun.org.apache.xml.internal.security.keys.content;
22
23
24
25
26import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
27import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException;
28import com.sun.org.apache.xml.internal.security.transforms.Transforms;
29import com.sun.org.apache.xml.internal.security.utils.Constants;
30import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy;
31import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
32import org.w3c.dom.Attr;
33import org.w3c.dom.Document;
34import org.w3c.dom.Element;
35
36
37/**
38 *
39 * @author $Author: raul $
40 */
41public class RetrievalMethod extends SignatureElementProxy
42 implements KeyInfoContent {
43
44 /** {@link java.util.logging} logging facility */
45 static java.util.logging.Logger log =
46 java.util.logging.Logger.getLogger(RetrievalMethod.class.getName());
47 //J-
48 /** DSA retrieval */
49 public static final String TYPE_DSA = Constants.SignatureSpecNS + "DSAKeyValue";
50 /** RSA retrieval */
51 public static final String TYPE_RSA = Constants.SignatureSpecNS + "RSAKeyValue";
52 /** PGP retrieval */
53 public static final String TYPE_PGP = Constants.SignatureSpecNS + "PGPData";
54 /** SPKI retrieval */
55 public static final String TYPE_SPKI = Constants.SignatureSpecNS + "SPKIData";
56 /** MGMT retrieval */
57 public static final String TYPE_MGMT = Constants.SignatureSpecNS + "MgmtData";
58 /** X509 retrieval */
59 public static final String TYPE_X509 = Constants.SignatureSpecNS + "X509Data";
60 /** RAWX509 retrieval */
61 public static final String TYPE_RAWX509 = Constants.SignatureSpecNS + "rawX509Certificate";
62 //J+
63
64 /**
65 * Constructor RetrievalMethod
66 *
67 * @param element
68 * @param BaseURI
69 * @throws XMLSecurityException
70 */
71 public RetrievalMethod(Element element, String BaseURI)
72 throws XMLSecurityException {
73 super(element, BaseURI);
74 }
75
76 /**
77 * Constructor RetrievalMethod
78 *
79 * @param doc
80 * @param URI
81 * @param transforms
82 * @param Type
83 */
84 public RetrievalMethod(Document doc, String URI, Transforms transforms,
85 String Type) {
86
87 super(doc);
88
89 this._constructionElement.setAttributeNS(null, Constants._ATT_URI, URI);
90
91 if (Type != null) {
92 this._constructionElement.setAttributeNS(null, Constants._ATT_TYPE, Type);
93 }
94
95 if (transforms != null) {
96 this._constructionElement.appendChild(transforms.getElement());
97 XMLUtils.addReturnToElement(this._constructionElement);
98 }
99 }
100
101 /**
102 * Method getURIAttr
103 *
104 * @return the URI attribute
105 */
106 public Attr getURIAttr() {
107 return this._constructionElement.getAttributeNodeNS(null, Constants._ATT_URI);
108 }
109
110 /**
111 * Method getURI
112 *
113 *
114 * @return URI string
115 */
116 public String getURI() {
117 return this.getURIAttr().getNodeValue();
118 }
119
120 /** @return the type*/
121 public String getType() {
122 return this._constructionElement.getAttributeNS(null, Constants._ATT_TYPE);
123 }
124
125 /**
126 * Method getTransforms
127 *
128 *
129 * @throws XMLSecurityException
130 * @return the transforamitons
131 */
132 public Transforms getTransforms() throws XMLSecurityException {
133
134 try {
135 Element transformsElem =
136 XMLUtils.selectDsNode(this._constructionElement,
137 Constants
138 ._TAG_TRANSFORMS, 0);
139
140 if (transformsElem != null) {
141 return new Transforms(transformsElem, this._baseURI);
142 }
143
144 return null;
145 } catch (XMLSignatureException ex) {
146 throw new XMLSecurityException("empty", ex);
147 }
148 }
149
150 /** @inheritDoc */
151 public String getBaseLocalName() {
152 return Constants._TAG_RETRIEVALMETHOD;
153 }
154}