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 package org.apache.ws.security;
21
22 import org.w3c.dom.Element;
23
24 /**
25 * @author Werner Dittmann (Werner.Dittmann@siemens.com)
26 */
27 public class WSEncryptionPart {
28
29 private String name;
30 private String namespace;
31 private String encModifier;
32 private String encId;
33 private String id;
34 private Element element;
35
36 /**
37 * An xpath expression pointing to the data element
38 * that may be specified in case the encryption part is of type
39 * <code>org.apache.ws.security.WSConstants.PART_TYPE_ELEMENT</code>
40 */
41 private String xpath;
42
43 /**
44 * Constructor to initialize part structure with element, namespace, and modifier.
45 *
46 * This constructor initializes the parts structure to lookup for a
47 * fully qualified name of an element to encrypt or sign. The modifier
48 * controls how encryption encrypts the element, signature processing does
49 * not use the modifier information.
50 *
51 * <p/>
52 *
53 * Regarding the modifier ("Content" or "Element") refer to the W3C
54 * XML Encryption specification.
55 *
56 * @param nm Element's name
57 * @param nmspace Element's namespace
58 * @param encMod The encryption modifier
59 */
60 public WSEncryptionPart(String nm, String nmspace, String encMod) {
61 name = nm;
62 namespace = nmspace;
63 encModifier = encMod;
64 id = null;
65 }
66
67 /**
68 * Constructor to initialize part structure with element id.
69 *
70 * This constructor initializes the parts structure to lookup for a
71 * an element with the given Id to encrypt or sign.
72 *
73 * @param id The Id to of the element to process
74 */
75 public WSEncryptionPart(String id) {
76 this.id = id;
77 name = namespace = encModifier = null;
78 }
79
80 /**
81 * Constructor to initialize part structure with element id and modifier.
82 *
83 * This constructor initializes the parts structure to lookup for a
84 * an element with the given Id to encrypt or sign. The modifier
85 * controls how encryption encrypts the element, signature processing does
86 * not use the modifier information.
87 *
88 * <p/>
89 *
90 * Regarding the modifier ("Content" or "Element") refer to the W3C
91 * XML Encryption specification.
92 *
93 * @param id The Id to of the element to process
94 * @param encMod The encryption modifier
95 */
96 public WSEncryptionPart(String id, String encMod) {
97 this.id = id;
98 encModifier = encMod;
99 name = namespace = null;
100 }
101
102 /**
103 * @return the local name of the element to encrypt.
104 */
105 public String getName() {
106 return name;
107 }
108
109 /**
110 * @return the namespace of the element to encrypt
111 */
112 public String getNamespace() {
113 return namespace;
114 }
115
116 /**
117 * @return the encryption modifier
118 */
119 public String getEncModifier() {
120 return encModifier;
121 }
122
123 /**
124 * Set the encryption modifier
125 */
126 public void setEncModifier(String encModifier) {
127 this.encModifier = encModifier;
128 }
129
130 /**
131 * @return Returns the id.
132 */
133 public String getId() {
134 return id;
135 }
136
137 /**
138 * Set the id
139 * @param id
140 */
141 public void setId(String id) {
142 this.id = id;
143 }
144
145 public void setEncId(String id) {
146 encId = id;
147 }
148
149 public String getEncId() {
150 return encId;
151 }
152
153 /**
154 * @return the xpath
155 */
156 public String getXpath() {
157 return xpath;
158 }
159
160 /**
161 * @param xpath the xpath to set
162 */
163 public void setXpath(String xpath) {
164 this.xpath = xpath;
165 }
166
167 /**
168 * Set the DOM Element corresponding to this EncryptionPart
169 * @param element the DOM Element corresponding to this EncryptionPart
170 */
171 public void setElement(Element element) {
172 this.element = element;
173 }
174
175 /**
176 * Get the DOM Element corresponding to this EncryptionPart
177 * @return the DOM Element corresponding to this EncryptionPart
178 */
179 public Element getElement() {
180 return element;
181 }
182
183 }