Source Code Cross Referenced for SymmetricKeyBinding.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: SymmetricKeyBinding.java,v 1.4 2006/10/04 15:43:19 kumarjayanti 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 com.sun.xml.wss.impl.policy.MLSPolicy;
030:        import com.sun.xml.wss.impl.MessageConstants;
031:        import javax.crypto.SecretKey;
032:        import javax.crypto.spec.SecretKeySpec;
033:
034:        import com.sun.xml.wss.impl.PolicyTypeUtil;
035:
036:        /**
037:         * A policy representing a SymmetricKey that can be used as the
038:         * KeyBinding for a SignaturePolicy or an EncryptionPolicy.
039:         */
040:        public class SymmetricKeyBinding extends KeyBindingBase {
041:
042:            /*
043:             * Feature Binding
044:             * Key Binding
045:             */
046:
047:            String _keyAlgorithm = MessageConstants._EMPTY;
048:
049:            String _keyIdentifier = MessageConstants._EMPTY;
050:
051:            String _certAlias = MessageConstants._EMPTY;
052:
053:            boolean _useReceivedSecret = false;
054:
055:            SecretKey _secretKey = null;
056:
057:            /**
058:             * Default constructor
059:             */
060:            public SymmetricKeyBinding() {
061:                setPolicyIdentifier(PolicyTypeUtil.SYMMETRIC_KEY_TYPE);
062:            }
063:
064:            /**
065:             * @param keyIdentifier identifier for Key
066:             * @param keyAlgorithm Key Algorithm
067:             */
068:            public SymmetricKeyBinding(String keyIdentifier, String keyAlgorithm) {
069:                this ();
070:
071:                this ._keyIdentifier = keyIdentifier;
072:                this ._keyAlgorithm = keyAlgorithm;
073:            }
074:
075:            /**
076:             * set the key identifier for the symmetric key
077:             * @param keyIdentifier
078:             */
079:            public void setKeyIdentifier(String keyIdentifier) {
080:                this ._keyIdentifier = keyIdentifier;
081:            }
082:
083:            /**
084:             * @return key identifier for the symmetric key
085:             */
086:            public String getKeyIdentifier() {
087:                return this ._keyIdentifier;
088:            }
089:
090:            public void setCertAlias(String certAlias) {
091:                this ._certAlias = certAlias;
092:            }
093:
094:            public String getCertAlias() {
095:                return this ._certAlias;
096:            }
097:
098:            public void setUseReceivedSecret(boolean useReceivedSecret) {
099:                this ._useReceivedSecret = useReceivedSecret;
100:            }
101:
102:            public boolean getUseReceivedSecret() {
103:                return this ._useReceivedSecret;
104:            }
105:
106:            /**
107:             * set the Key Algorithm of the Symmetric Key
108:             * @param keyAlgorithm
109:             */
110:            public void setKeyAlgorithm(String keyAlgorithm) {
111:                this ._keyAlgorithm = keyAlgorithm;
112:            }
113:
114:            /**
115:             * @return keyAlgorithm for the Symmetric Key
116:             */
117:            public String getKeyAlgorithm() {
118:                return this ._keyAlgorithm;
119:            }
120:
121:            /**
122:             * Set the symmetric key
123:             * @param secretKey the SecretKey
124:             */
125:            public void setSecretKey(SecretKey secretKey) {
126:                this ._secretKey = secretKey;
127:            }
128:
129:            /**
130:             * @return SecretKey the symmetric key
131:             */
132:            public SecretKey getSecretKey() {
133:                return this ._secretKey;
134:            }
135:
136:            /**
137:             * Create and set the KeyBinding for this WSSPolicy to an X509CertificateBinding
138:             * @return a new X509CertificateBinding as a KeyBinding for this WSSPolicy
139:             * @see SignaturePolicy
140:             * @see EncryptionPolicy
141:             * @see AuthenticationTokenPolicy
142:             */
143:            public MLSPolicy newX509CertificateKeyBinding() {
144:                if (isReadOnly()) {
145:                    throw new RuntimeException(
146:                            "Can not create X509CertificateKeyBinding : Policy is Readonly");
147:                }
148:                this ._keyBinding = new AuthenticationTokenPolicy.X509CertificateBinding();
149:                return _keyBinding;
150:            }
151:
152:            /**
153:             * @param policy the policy to be compared for equality
154:             * @return true if the argument policy is equal to this
155:             */
156:            public boolean equals(WSSPolicy policy) {
157:
158:                boolean assrt = false;
159:
160:                try {
161:                    SymmetricKeyBinding skBinding = (SymmetricKeyBinding) policy;
162:
163:                    boolean b1 = _keyIdentifier.equals("") ? true
164:                            : _keyIdentifier.equals(skBinding
165:                                    .getKeyIdentifier());
166:
167:                    boolean b2 = _keyAlgorithm.equals("") ? true
168:                            : _keyAlgorithm.equals(skBinding.getKeyAlgorithm());
169:
170:                    boolean b3 = _certAlias.equals("") ? true : _certAlias
171:                            .equals(skBinding.getCertAlias());
172:
173:                    boolean b4 = (_useReceivedSecret == false) ? true
174:                            : (_useReceivedSecret == skBinding
175:                                    .getUseReceivedSecret());
176:                    boolean b5 = (this ._keyBinding.equals(policy._keyBinding));
177:
178:                    assrt = b1 && b2 && b3 && b4 && b5;
179:                } catch (Exception e) {
180:                }
181:
182:                return assrt;
183:            }
184:
185:            /*
186:             * Equality comparision ignoring the Targets
187:             * @param policy the policy to be compared for equality
188:             * @return true if the argument policy is equal to this
189:             */
190:            public boolean equalsIgnoreTargets(WSSPolicy binding) {
191:                return equals(binding);
192:            }
193:
194:            /**
195:             * Clone operator
196:             * @return clone of this policy
197:             */
198:            public Object clone() {
199:                SymmetricKeyBinding skBinding = new SymmetricKeyBinding();
200:
201:                try {
202:                    skBinding.setUUID(this .getUUID());
203:                    skBinding.setKeyIdentifier(_keyIdentifier);
204:                    skBinding.setKeyAlgorithm(_keyAlgorithm);
205:                    skBinding.setCertAlias(_certAlias);
206:                    skBinding.setUseReceivedSecret(_useReceivedSecret);
207:
208:                    SecretKeySpec ky0 = (SecretKeySpec) _secretKey;
209:                    if (ky0 != null) {
210:                        SecretKeySpec key = new SecretKeySpec(ky0.getEncoded(),
211:                                ky0.getAlgorithm());
212:                        skBinding.setSecretKey(key);
213:                    }
214:
215:                    if (this ._keyBinding != null) {
216:                        if (this ._keyBinding instanceof  AuthenticationTokenPolicy.X509CertificateBinding) {
217:                            skBinding
218:                                    .setKeyBinding((AuthenticationTokenPolicy.X509CertificateBinding) ((AuthenticationTokenPolicy.X509CertificateBinding) this ._keyBinding)
219:                                            .clone());
220:                        }
221:                    }
222:
223:                } catch (Exception e) {
224:                    // log
225:                }
226:
227:                return skBinding;
228:            }
229:
230:            /**
231:             * @return the type of the policy
232:             */
233:            public String getType() {
234:                return PolicyTypeUtil.SYMMETRIC_KEY_TYPE;
235:            }
236:
237:            public String toString() {
238:                return PolicyTypeUtil.SYMMETRIC_KEY_TYPE + "::"
239:                        + getKeyAlgorithm() + "::" + _keyIdentifier;
240:            }
241:        }
ww_w_.__jav__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.