Source Code Cross Referenced for SignatureTarget.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: SignatureTarget.java,v 1.5 2007/03/27 10:46:04 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 java.security.spec.AlgorithmParameterSpec;
030:        import java.util.Iterator;
031:        import java.util.ArrayList;
032:
033:        import com.sun.xml.wss.impl.MessageConstants;
034:
035:        /**
036:         * Objects of this class represent a Signature Target that can be part of
037:         * the FeatureBinding for a SignaturePolicy (refer SignaturePolicy.FeatureBinding).
038:         */
039:        public class SignatureTarget extends Target implements  Cloneable {
040:
041:            String _digestAlgorithm = "";
042:
043:            ArrayList _transforms = new ArrayList();
044:
045:            private boolean isOptimized = false;
046:
047:            private String xpathVersion = "";
048:
049:            /**
050:             * Default constructor
051:             */
052:            public SignatureTarget() {
053:            }
054:
055:            /**
056:             * Constructor that takes a Target
057:             */
058:            public SignatureTarget(Target target) {
059:                this .setEnforce(target.getEnforce());
060:                this .setType(target.getType());
061:                this .setValue(target.getValue());
062:                this .setContentOnly(target.getContentOnly());
063:                this ._digestAlgorithm = MessageConstants.SHA1_DIGEST;
064:            }
065:
066:            /**
067:             * @param digest Digest Algorithm to be used for this Target
068:             * @param transform Transform Algorithm to applied on this Target
069:             */
070:            public SignatureTarget(String digest, String transform) {
071:                this ._digestAlgorithm = digest;
072:                this ._transforms.add(new Transform(transform));
073:            }
074:
075:            /**
076:             * @return Digest Algorithm for this Target
077:             */
078:            public String getDigestAlgorithm() {
079:                return _digestAlgorithm;
080:            }
081:
082:            /**
083:             * @return Collection of Transform Algorithms
084:             */
085:            public ArrayList getTransforms() {
086:                return _transforms;
087:            }
088:
089:            /**
090:             * set the Digest Algorithm to be used for this Target
091:             * @param digest Digest Algorithm
092:             */
093:            public void setDigestAlgorithm(String digest) {
094:                if (isBSP()
095:                        && (digest.intern() != MessageConstants.SHA1_DIGEST)) {
096:                    throw new RuntimeException(
097:                            "Does not meet BSP requirement 5420 for Digest Algorithm");
098:                }
099:                this ._digestAlgorithm = digest;
100:            }
101:
102:            /**
103:             * Add a Transform for this Target
104:             * @param transform Transform
105:             */
106:            public void addTransform(Transform transform) {
107:                String transformStr = transform.getTransform();
108:                if (isBSP()
109:                        && ((transformStr != MessageConstants.TRANSFORM_C14N_EXCL_OMIT_COMMENTS)
110:                                && (transformStr != MessageConstants.ATTACHMENT_COMPLETE_TRANSFORM_URI)
111:                                && (transformStr != MessageConstants.ATTACHMENT_CONTENT_ONLY_TRANSFORM_URI)
112:                                && (transformStr != MessageConstants.STR_TRANSFORM_URI) && (transformStr != MessageConstants.TRANSFORM_FILTER2))) {
113:                    throw new RuntimeException(
114:                            "Does not meet BSP requirement 5423 for signature transforms");
115:                }
116:                this ._transforms.add(transform);
117:            }
118:
119:            /**
120:             * @return a new instance of Signatuer Transform
121:             */
122:            public Transform newSignatureTransform() {
123:                return new Transform();
124:            }
125:
126:            /**
127:             * Equals operator
128:             * @param target SignatureTarget
129:             * @return true if the target argument is equal to this Target
130:             */
131:            public boolean equals(SignatureTarget target) {
132:
133:                boolean b1 = _digestAlgorithm.equals("") ? true
134:                        : _digestAlgorithm.equals(target.getDigestAlgorithm());
135:
136:                boolean b2 = _transforms.equals(target.getTransforms());
137:
138:                return b1 && b2;
139:            }
140:
141:            /**
142:             * clone operator
143:             * @return a clone of this SignatureTarget
144:             */
145:            public Object clone() {
146:                SignatureTarget target = new SignatureTarget();
147:
148:                try {
149:                    ArrayList list = target.getTransforms();
150:
151:                    target.setDigestAlgorithm(_digestAlgorithm);
152:                    target.setValue(this .getValue());
153:                    target.setType(this .getType());
154:                    target.setContentOnly(this .getContentOnly());
155:                    target.setEnforce(this .getEnforce());
156:
157:                    Iterator i = _transforms.iterator();
158:                    while (i.hasNext()) {
159:                        Transform transform = (Transform) i.next();
160:                        list.add(transform.clone());
161:                    }
162:                } catch (Exception e) {
163:                }
164:
165:                return target;
166:            }
167:
168:            /**
169:             * This class represents a Transform that can appear on a SignatureTarget.
170:             */
171:            public static class Transform {
172:
173:                String _transform = "";
174:
175:                // List _canonicalizationParameters = new ArrayList();
176:
177:                AlgorithmParameterSpec _algorithmParameters = null;
178:
179:                private boolean disableInclusivePrefix = false;
180:
181:                /**
182:                 * Default constructor
183:                 */
184:                public Transform() {
185:                }
186:
187:                /**
188:                 * Constructor
189:                 * @param algorithm the Transform Algorithm
190:                 */
191:                public Transform(String algorithm) {
192:                    this ._transform = algorithm;
193:                }
194:
195:                /**
196:                 * @return Algorithm Parameters for the Transform Algorithm
197:                 */
198:                public AlgorithmParameterSpec getAlgorithmParameters() {
199:                    return this ._algorithmParameters;
200:                }
201:
202:                /**
203:                 * set Algorithm Parameters
204:                 * @param param the list of parameters for the Transform Algorithm
205:                 */
206:                public void setAlgorithmParameters(AlgorithmParameterSpec param) {
207:                    this ._algorithmParameters = param;
208:                }
209:
210:                /**
211:                 * set the transform Algorithm
212:                 * @param algorithm
213:                 */
214:                public void setTransform(String algorithm) {
215:                    this ._transform = algorithm;
216:                }
217:
218:                /**
219:                 * @return the transform Algorithm
220:                 */
221:                public String getTransform() {
222:                    return this ._transform;
223:                }
224:
225:                public boolean getDisableInclusivePrefix() {
226:                    return this .disableInclusivePrefix;
227:                }
228:
229:                public void setDisbaleInclusivePrefix(
230:                        boolean disableInclusivePrefix) {
231:                    this .disableInclusivePrefix = disableInclusivePrefix;
232:                }
233:
234:                /**
235:                 * equals operator
236:                 * @param transform the transform to be compared for equality
237:                 * @return true if the argument transform is equal to this transform
238:                 */
239:                public boolean equals(Transform transform) {
240:
241:                    boolean b1 = _transform.equals("") ? true : _transform
242:                            .equals(transform.getTransform());
243:                    if (!b1)
244:                        return false;
245:
246:                    boolean b2 = _algorithmParameters.equals(transform
247:                            .getAlgorithmParameters());
248:                    if (!b2)
249:                        return false;
250:
251:                    return true;
252:                }
253:
254:                /**
255:                 * clone operator
256:                 * @return a clone of this Transform
257:                 */
258:                public Object clone() {
259:                    Transform transform = new Transform(_transform);
260:
261:                    /*
262:                    List params = new ArrayList();
263:                    Iterator i  = getCanonicalizationParameters().iterator();
264:                    while (i.hasNext()) params.add(i.next());
265:                     
266:                    transform.getCanonicalizationParameters().addAll(params);
267:                     */
268:                    //NOTE: shallow copy here
269:                    //TODO: should change this since we support DynamicPolicy
270:                    //TODO: Need to handle clone;
271:                    transform.setAlgorithmParameters(_algorithmParameters);
272:                    return transform;
273:                }
274:            }
275:
276:            public boolean isIsOptimized() {
277:                return isOptimized;
278:            }
279:
280:            public void setIsOptimized(boolean isOptimized) {
281:                this .isOptimized = isOptimized;
282:            }
283:
284:            public void setXPathVersion(String version) {
285:                this .xpathVersion = version;
286:            }
287:
288:            public String getXPathVersion() {
289:                return xpathVersion;
290:            }
291:        }
ww_w.__j_a_v___a2__s.co___m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.