Source Code Cross Referenced for Target.java in  » 6.0-JDK-Modules-com.sun » xws-security » com » sun » xml » wss » impl » policy » mls » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules com.sun » xws security » com.sun.xml.wss.impl.policy.mls 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: Target.java,v 1.4 2006/11/13 04:21:44 ashutoshshahi Exp $
003:         */
004:
005:        /*
006:         * The contents of this file are subject to the terms
007:         * of the Common Development and Distribution License
008:         * (the License).  You may not use this file except in
009:         * compliance with the License.
010:         * 
011:         * You can obtain a copy of the license at
012:         * https://glassfish.dev.java.net/public/CDDLv1.0.html.
013:         * See the License for the specific language governing
014:         * permissions and limitations under the License.
015:         * 
016:         * When distributing Covered Code, include this CDDL
017:         * Header Notice in each file and include the License file
018:         * at https://glassfish.dev.java.net/public/CDDLv1.0.html.
019:         * If applicable, add the following below the CDDL Header,
020:         * with the fields enclosed by brackets [] replaced by
021:         * you own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         * 
024:         * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
025:         */
026:
027:        package com.sun.xml.wss.impl.policy.mls;
028:
029:        import javax.xml.namespace.QName;
030:        import com.sun.xml.wss.impl.MessageConstants;
031:
032:        /*
033:         * Target specifies the qname or xpath or id to identify the
034:         * <target> element to apply the Sign/Encrypt Security Policy on.
035:         */
036:        public class Target {
037:
038:            protected static final String TARGET_VALUE_SOAP_BODY = "SOAP-BODY";
039:
040:            /**
041:             * type-identifier  for qname Target Type
042:             */
043:            public static final String TARGET_TYPE_VALUE_QNAME = "qname";
044:            /**
045:             * type-identifier for xpath Target Type
046:             */
047:            public static final String TARGET_TYPE_VALUE_XPATH = "xpath";
048:            /**
049:             * type-identifier for uri Target Type
050:             */
051:            public static final String TARGET_TYPE_VALUE_URI = "uri";
052:            /**
053:             * All Message Headers targeted at ultimate receiver role should be 
054:             * integrity protected.
055:             */
056:            public static final String ALL_MESSAGE_HEADERS = "ALL_MESSAGE_HEADERS";
057:            public static final String BODY = "{"
058:                    + MessageConstants.SOAP_1_1_NS + "}Body";
059:            public static final String BODY1_2 = "{"
060:                    + MessageConstants.SOAP_1_2_NS + "}Body";
061:            public static final QName BODY_QNAME = new QName(
062:                    MessageConstants.SOAP_1_1_NS, "Body");
063:            public static final QName SIGNATURE_CONFIRMATION = new QName(
064:                    MessageConstants.WSSE11_NS,
065:                    MessageConstants.SIGNATURE_CONFIRMATION_LNAME);
066:
067:            private String type = TARGET_TYPE_VALUE_QNAME;
068:
069:            private String value = BODY;
070:            private boolean contentOnly = true;
071:            private boolean enforce = true;
072:            private String xpathExpr = null;
073:            private QName qname = null;
074:            private boolean attachment = false;
075:            boolean bsp = false;
076:            boolean headersOnly = false;
077:            private String xpathVersion;
078:            private QName policyQName = null;
079:
080:            /**
081:             * Default constructor
082:             * When used, it creates a default Target of type <code>qname</code> and a value of
083:             * {http://schemas.xmlsoap.org/soap/envelope/}Body
084:             */
085:            public Target() {
086:            }
087:
088:            /**
089:             * Constructor
090:             * @param type the type of the Target (should be one of TARGET_TYPE_VALUE_QNAME, TARGET_TYPE_VALUE_XPATH, TARGET_TYPE_VALUE_URI)
091:             * @param value the value of the Target
092:             */
093:            public Target(String type, String value) {
094:                this .type = type;
095:                this .value = value;
096:                if (TARGET_TYPE_VALUE_QNAME.equals(type)
097:                        && TARGET_VALUE_SOAP_BODY.equals(value)) {
098:                    this .value = Target.BODY;
099:                }
100:            }
101:
102:            /**
103:             * Constructor
104:             * @param type the type of the Target (should be one of TARGET_TYPE_VALUE_QNAME, TARGET_TYPE_VALUE_XPATH, TARGET_TYPE_VALUE_URI)
105:             * @param value the value of the Target
106:             * @param contentOnly the content-only flag. This flag is used to decide whether the whole Target or only its Markup(content) should
107:             * be Encrypted.
108:             */
109:            public Target(String type, String value, boolean contentOnly) {
110:                this .type = type;
111:                this .value = value;
112:                this .contentOnly = contentOnly;
113:                if (TARGET_TYPE_VALUE_QNAME.equals(type)
114:                        && TARGET_VALUE_SOAP_BODY.equals(value)) {
115:                    this .value = Target.BODY;
116:                }
117:            }
118:
119:            /**
120:             * Constructor
121:             * @param type the type of the Target (should be one of TARGET_TYPE_VALUE_QNAME, TARGET_TYPE_VALUE_XPATH, TARGET_TYPE_VALUE_URI)
122:             * @param value the value of the Target
123:             * @param contentOnly the content-only flag. This flag is used to decide whether the whole Target or only its Markup(content) should
124:             * be Encrypted.
125:             * @param enforce when set to false, will cause the enclosing policy (SignaturePolicy/EncryptionPolicy) to consider the presence of
126:             * this Target reference as optional, while verifying the Policy on the Receiver side.
127:             * 
128:             */
129:            public Target(String type, String value, boolean contentOnly,
130:                    boolean enforce) {
131:                this .type = type;
132:                this .value = value;
133:                this .contentOnly = contentOnly;
134:                this .enforce = enforce;
135:                if (TARGET_TYPE_VALUE_QNAME.equals(type)
136:                        && TARGET_VALUE_SOAP_BODY.equals(value)) {
137:                    this .value = Target.BODY;
138:                }
139:            }
140:
141:            /**
142:             * set the enforcement flag, used when verifying Security on an inbound message.
143:             *@param enforce if set to True indicates that this Target is a compulsary target under the Policy in which
144:             * it appears.
145:             */
146:            public void setEnforce(boolean enforce) {
147:                this .enforce = enforce;
148:            }
149:
150:            /**
151:             *@return true if this Target appearing under a Policy should be enforced, false
152:             * if it is optional.
153:             */
154:            public boolean getEnforce() {
155:                return enforce;
156:            }
157:
158:            /**
159:             * @param headersOnly is set to true, indicates only headers should be processed by
160:             * this target
161:             * To be set by Policy
162:             */
163:            public void isSOAPHeadersOnly(boolean headersOnly) {
164:                this .headersOnly = headersOnly;
165:            }
166:
167:            /**
168:             * @return true if only the headers should be processed, false otherwise
169:             * default is false
170:             */
171:            public boolean isSOAPHeadersOnly() {
172:                return headersOnly;
173:            }
174:
175:            /*
176:             * Checks whether BSP checks are enabled for this target.
177:             */
178:            public void isBSP(boolean flag) {
179:                bsp = flag;
180:            }
181:
182:            /*
183:             */
184:            public boolean isBSP() {
185:                return bsp;
186:            }
187:
188:            /**
189:             *@return the type of the Target
190:             */
191:            public String getType() {
192:                return type;
193:            }
194:
195:            /**
196:             * set the type of the Target
197:             * @param type the type of the Target
198:             */
199:            public void setType(String type) {
200:                this .type = type;
201:            }
202:
203:            /**
204:             *@return the value of the Target
205:             */
206:            public String getValue() {
207:                return value;
208:            }
209:
210:            /**
211:             * set the value of the Target
212:             * @param value the value of the Target
213:             */
214:            public void setValue(String value) {
215:                this .value = value;
216:                xpathExpr = null;
217:
218:                if (BODY1_2.equals(value) || BODY.equals(value)) {
219:                    this .value = Target.BODY;
220:                }
221:
222:                if (TARGET_TYPE_VALUE_QNAME.equals(type)
223:                        && TARGET_VALUE_SOAP_BODY.equals(value)) {
224:                    this .value = Target.BODY;
225:                }
226:
227:                if (value != null
228:                        && (value.startsWith("cid:") || value
229:                                .startsWith(MessageConstants.ATTACHMENTREF))) {
230:                    attachment = true;
231:                    if (value.equals("cid:*")) {
232:                        this .value = MessageConstants.PROCESS_ALL_ATTACHMENTS;
233:                    }
234:                }
235:            }
236:
237:            /**
238:             * set the contentOnly flag on the Target
239:             * @param contentOnly the boolean flag indicating content-only when set to true.
240:             */
241:            public void setContentOnly(boolean contentOnly) {
242:                this .contentOnly = contentOnly;
243:            }
244:
245:            /**
246:             *@return true if the contentOnly flag on the Target was set, false otherwise
247:             */
248:            public boolean getContentOnly() {
249:                return contentOnly;
250:            }
251:
252:            /**
253:             *@return the Target value as a String representing an XPath expression
254:             */
255:            public String convertToXPATH() {
256:                if (xpathExpr == null) {
257:                    xpathExpr = convertToXpath(value);
258:                }
259:                return xpathExpr;
260:            }
261:
262:            private String convertToXpath(String qname) {
263:                QName name = QName.valueOf(qname);
264:                if ("".equals(name.getNamespaceURI())) {
265:                    return "//" + name.getLocalPart();
266:                } else {
267:                    return "//*[local-name()='" + name.getLocalPart()
268:                            + "' and namespace-uri()='"
269:                            + name.getNamespaceURI() + "']";
270:                }
271:            }
272:
273:            /**
274:             * Set the Target QName.
275:             */
276:            public void setQName(QName qname) {
277:                this .type = TARGET_TYPE_VALUE_QNAME;
278:                this .value = qname.toString();
279:                this .qname = qname;
280:                this .value = qname.toString();
281:            }
282:
283:            /**
284:             *@return the QName for the Target
285:             */
286:            public QName getQName() {
287:                if (type != TARGET_TYPE_VALUE_QNAME) {
288:                    return null;
289:                }
290:                if (qname == null && value != null) {
291:                    qname = QName.valueOf(value);
292:                }
293:                return qname;
294:            }
295:
296:            /**
297:             * @return true if this Target represents an Attachment
298:             */
299:            public boolean isAttachment() {
300:                return attachment;
301:            }
302:
303:            /**
304:             * returns xpath version to be used if the Target Type is XPATH.
305:             */
306:            public String getXPathVersion() {
307:                return xpathVersion;
308:            }
309:
310:            /**
311:             * sets  xpath version to be used if the Target Type is XPATH.
312:             */
313:
314:            public void setXPathVersion(String version) {
315:                xpathVersion = version;
316:            }
317:
318:            public void setPolicyName(QName policyQName) {
319:                this .policyQName = policyQName;
320:            }
321:
322:            public QName getPolicyQName() {
323:                return policyQName;
324:            }
325:        }
w__w_w__._jav_a2_s__.___c_o_m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.