Source Code Cross Referenced for EncryptionPolicy.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: EncryptionPolicy.java,v 1.5 2007/05/03 01:23:02 venu 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.util.Iterator;
030:        import java.util.ArrayList;
031:
032:        import com.sun.xml.wss.impl.policy.MLSPolicy;
033:        import com.sun.xml.wss.impl.PolicyTypeUtil;
034:
035:        /**
036:         *  Objects of this class  represent a policy for Encrypting parts of a SOAP Message. The
037:         *  Message Parts to be encrypted and the Data Encryption Algorithm to be used are
038:         *  captured as FeatureBindings of this Policy. The exact Key to be used is to be represented
039:         *  as a distinct KeyBinding for this policy instance.
040:         *
041:         *  Allowed KeyBindings for an EncryptionPolicy include the following :
042:         * <UL>
043:         *   <LI>AuthenticationTokenPolicy.X509CertificateBinding
044:         *   <LI>AuthenticationTokenPolicy.SAMLAssertionBinding
045:         *   <LI>SymmetricKeyBinding
046:         * </UL>
047:         */
048:        public class EncryptionPolicy extends WSSKeyBindingExtension {
049:
050:            /*
051:             * Feature Bindings
052:             *
053:             * (1) EncryptionPolicy.FeatureBinding
054:             *
055:             * Key Bindings
056:             *
057:             * (1) X509CertificateBinding
058:             * (2) SymmetricKeyBinding
059:             * (3) SAMLAssertionBinding
060:             */
061:
062:            /**
063:             * default constructor
064:             */
065:            public EncryptionPolicy() {
066:                setPolicyIdentifier(PolicyTypeUtil.ENCRYPTION_POLICY_TYPE);
067:                this ._featureBinding = new FeatureBinding();
068:            }
069:
070:            /**
071:             * Equals operator
072:             * @param policy <code>WSSPolicy</code> to be compared for equality
073:             * @return true if the policy is equal to this policy
074:             */
075:            public boolean equals(WSSPolicy policy) {
076:                boolean _assert = false;
077:
078:                try {
079:                    return equalsIgnoreTargets(policy);
080:                    /*EncryptionPolicy sPolicy = (EncryptionPolicy) policy;
081:                     
082:                    _assert = ((WSSPolicy) getFeatureBinding()).equals (
083:                                 (WSSPolicy) sPolicy.getFeatureBinding()) &&
084:                    getKeyBinding().equals ((WSSPolicy) sPolicy.getKeyBinding());
085:                     */
086:                } catch (Exception cce) {
087:                }
088:
089:                return _assert;
090:            }
091:
092:            /*
093:             * Equality comparision ignoring the Targets
094:             * @param policy the policy to be compared for equality
095:             * @return true if the argument policy is equal to this
096:             */
097:            public boolean equalsIgnoreTargets(WSSPolicy policy) {
098:                boolean _assert = false;
099:
100:                try {
101:                    if (PolicyTypeUtil.encryptionPolicy(policy))
102:                        return true;
103:
104:                    //EncryptionPolicy sPolicy = (EncryptionPolicy) policy;
105:                    //TODO : Uncomment it
106:                    //_assert = getKeyBinding().equals((WSSPolicy) sPolicy.getKeyBinding());
107:                } catch (Exception cce) {
108:                }
109:
110:                return _assert;
111:            }
112:
113:            /**
114:             * clone operator
115:             * @return a clone of this EncryptionPolicy
116:             */
117:            public Object clone() {
118:                EncryptionPolicy ePolicy = new EncryptionPolicy();
119:
120:                try {
121:                    WSSPolicy fBinding = (WSSPolicy) getFeatureBinding();
122:                    WSSPolicy kBinding = (WSSPolicy) getKeyBinding();
123:
124:                    if (fBinding != null)
125:                        ePolicy.setFeatureBinding((MLSPolicy) fBinding.clone());
126:
127:                    if (kBinding != null)
128:                        ePolicy.setKeyBinding((MLSPolicy) kBinding.clone());
129:                } catch (Exception e) {
130:                }
131:
132:                return ePolicy;
133:            }
134:
135:            /**
136:             * @return the type of the policy
137:             */
138:            public String getType() {
139:                return PolicyTypeUtil.ENCRYPTION_POLICY_TYPE;
140:            }
141:
142:            /**
143:             * A class representing FeatureBindings for an EncryptionPolicy
144:             * The FeatureBinding would contain information about the MessageParts
145:             * to be Encrypted, The data encryption algorithm to be used.
146:             */
147:            public static class FeatureBinding extends WSSPolicy {
148:
149:                /*
150:                 * Feature Bindings
151:                 *
152:                 * (1) SignaturePolicy
153:                 * (2) EncryptionPolicy
154:                 * (3) AuthenticationTokenPolicy
155:                 *
156:                 * Key Bindings
157:                 *
158:                 * (1) X509CertificateBinding
159:                 * (2) SymmetricKeyBinding
160:                 * (3) SAMLAssertionBinding
161:                 */
162:
163:                String _dataEncryptionAlgorithm = "";
164:                ArrayList _targets = new ArrayList();
165:                boolean standAloneRefList = false;
166:                boolean targetIsIssuedToken = false;
167:
168:                /**
169:                 *default constructor
170:                 */
171:                public FeatureBinding() {
172:                    setPolicyIdentifier(PolicyTypeUtil.ENCRYPTION_POLICY_FEATUREBINDING_TYPE);
173:                }
174:
175:                /**
176:                 * @return the DataEncryptionAlgorithm
177:                 */
178:                public String getDataEncryptionAlgorithm() {
179:                    return _dataEncryptionAlgorithm;
180:                }
181:
182:                /**
183:                 * set the DataEncryptionAlgorithm to be used
184:                 * @param algorithm the DataEncryptionAlgorithm
185:                 */
186:                public void setDataEncryptionAlgorithm(String algorithm) {
187:                    if (isReadOnly()) {
188:                        throw new RuntimeException(
189:                                "Can not set DateEncryptionAlgorithm : Policy is ReadOnly");
190:                    }
191:                    this ._dataEncryptionAlgorithm = algorithm;
192:                }
193:
194:                /**
195:                 * @return Target collection
196:                 */
197:                public ArrayList getTargetBindings() {
198:                    return _targets;
199:                }
200:
201:                /**
202:                 * @param target EncryptionTarget
203:                 */
204:                public void addTargetBinding(EncryptionTarget target) {
205:                    if (isReadOnly()) {
206:                        throw new RuntimeException(
207:                                "Can not add Target : Policy is ReadOnly");
208:                    }
209:                    _targets.add(target);
210:                }
211:
212:                /*
213:                 * @param target Target
214:                 */
215:                public void addTargetBinding(Target target) {
216:                    if (isReadOnly()) {
217:                        throw new RuntimeException(
218:                                "Can not add Target : Policy is ReadOnly");
219:                    }
220:                    _targets.add(new EncryptionTarget(target));
221:                }
222:
223:                /**
224:                 * @param targets ArrayList of all targets to be removed
225:                 */
226:                public void removeTargetBindings(ArrayList targets) {
227:                    if (isReadOnly()) {
228:                        throw new RuntimeException(
229:                                "Can not remove Target : Policy is ReadOnly");
230:                    }
231:                    _targets.removeAll(targets);
232:                }
233:
234:                /**
235:                 * Equals operator
236:                 * @return true if the binding is equal to this Encryption Policy
237:                 */
238:                public boolean equals(WSSPolicy policy) {
239:
240:                    try {
241:                        FeatureBinding fBinding = (FeatureBinding) policy;
242:                        boolean b1 = _targets.equals(fBinding
243:                                .getTargetBindings());
244:                        if (!b1)
245:                            return false;
246:                    } catch (Exception e) {
247:                    }
248:
249:                    return true;
250:                }
251:
252:                /*
253:                 * Equality comparision ignoring the Targets
254:                 * @param policy the policy to be compared for equality
255:                 * @return true if the argument policy is equal to this
256:                 */
257:                public boolean equalsIgnoreTargets(WSSPolicy policy) {
258:                    return true;
259:                }
260:
261:                /**
262:                 * clone operator
263:                 * @return a clone of this EncryptionPolicy.FeatureBinding
264:                 */
265:                public Object clone() {
266:                    FeatureBinding fBinding = new FeatureBinding();
267:
268:                    try {
269:                        ArrayList list = new ArrayList();
270:
271:                        Iterator i = getTargetBindings().iterator();
272:                        while (i.hasNext())
273:                            list.add(((EncryptionTarget) i.next()).clone());
274:
275:                        ((ArrayList) fBinding.getTargetBindings()).addAll(list);
276:
277:                        WSSPolicy kBinding = (WSSPolicy) getKeyBinding();
278:                        fBinding.setDataEncryptionAlgorithm(this 
279:                                .getDataEncryptionAlgorithm());
280:                        if (kBinding != null)
281:                            fBinding
282:                                    .setKeyBinding((MLSPolicy) kBinding.clone());
283:                    } catch (Exception e) {
284:                    }
285:
286:                    return fBinding;
287:                }
288:
289:                /**
290:                 * @return the type of the policy
291:                 */
292:                public String getType() {
293:                    return PolicyTypeUtil.ENCRYPTION_POLICY_FEATUREBINDING_TYPE;
294:                }
295:
296:                public boolean encryptsIssuedToken() {
297:                    return targetIsIssuedToken;
298:                }
299:
300:                public void encryptsIssuedToken(boolean flag) {
301:                    targetIsIssuedToken = flag;
302:                }
303:
304:                public boolean getUseStandAloneRefList() {
305:                    return standAloneRefList;
306:                }
307:
308:                public void setUseStandAloneRefList(boolean value) {
309:                    this.standAloneRefList = value;
310:                }
311:            }
312:        }
w_w_w__.j_a__v___a___2__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.