View Javadoc

1   /*
2    * Copyright 2001-2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.apache.geronimo.ews.ws4j2ee.context.security.impl;
18  
19  import org.apache.geronimo.ews.ws4j2ee.context.security.SecurityContext4J2EE;
20  
21  import javax.security.auth.callback.CallbackHandler;
22  import javax.security.cert.X509Certificate;
23  
24  /***
25   * @author Rajith Priyanga (rpriyanga@yahoo.com)
26   * @date Apr 6, 2004
27   */
28  public class SecurityContext4J2EEImpl implements SecurityContext4J2EE {
29  
30      private String nonce = null;
31      private String created = null;
32      private String username = null;
33      private char[] pwd = null;
34  
35      private X509Certificate x509Cert = null;
36      private byte[] kerberosTicket = null;
37  
38      private boolean privacy = false;
39      private boolean integrity = false;
40      private boolean isPwdDigested = false;
41      private CallbackHandler cbh;
42  
43      public SecurityContext4J2EEImpl() {
44      }
45  
46      /***
47       * @see org.apache.geranimo.ews.ws4j2ee.context.security.SecurityContext4J2EE#sufficientIntegrity()
48       */
49      public boolean sufficientIntegrity() {
50          // TODO 
51          return false;
52      }
53  
54      /***
55       * @see org.apache.geranimo.ews.ws4j2ee.context.security.SecurityContext4J2EE#sufficientPrivacy()
56       */
57      public boolean sufficientPrivacy() {
58          // TODO 
59          return false;
60      }
61  
62      /***
63       * @see org.apache.geranimo.ews.ws4j2ee.context.security.SecurityContext4J2EE#getNonce()
64       */
65      public String getNonce() {
66          return this.nonce;
67      }
68  
69      /***
70       * @see org.apache.geranimo.ews.ws4j2ee.context.security.SecurityContext4J2EE#getCreated()
71       */
72      public String getCreated() {
73          return this.created;
74      }
75  
76      /***
77       * @see org.apache.geranimo.ews.ws4j2ee.context.security.SecurityContext4J2EE#getPasswordDigest()
78       */
79      public char[] getPasswordDigest() {
80          if (this.isPwdDigested)
81              return this.pwd;
82          else
83              return null;
84      }
85  
86      /***
87       * @see org.apache.geranimo.ews.ws4j2ee.context.security.SecurityContext4J2EE#getPasswordText()
88       */
89      public char[] getPasswordText() {
90          if (this.isPwdDigested)
91              return null;
92          else
93              return this.pwd;
94      }
95  
96      /***
97       * @see org.apache.geranimo.ews.ws4j2ee.context.security.SecurityContext4J2EE#getUsername()
98       */
99      public String getUsername() {
100         return this.username;
101     }
102 
103     /***
104      * Sets the created.
105      *
106      * @param created The created to set
107      */
108     public void setCreated(String created) {
109         this.created = created;
110     }
111 
112     /***
113      * Sets the integrity.
114      *
115      * @param integrity The integrity to set
116      */
117     public void setIntegritySufficient(boolean sufficient) {
118         this.integrity = sufficient;
119     }
120 
121     /***
122      * Sets the nonce.
123      *
124      * @param nonce The nonce to set
125      */
126     public void setNonce(String nonce) {
127         this.nonce = nonce;
128     }
129 
130     /***
131      * Sets the privacy.
132      *
133      * @param privacy The privacy to set
134      */
135     public void setPrivacySufficient(boolean sufficient) {
136         this.privacy = sufficient;
137     }
138 
139     /***
140      * Sets the username.
141      *
142      * @param username The username to set
143      */
144     public void setUsername(String username) {
145         this.username = username;
146     }
147 
148     /***
149      * @see org.apache.geranimo.ews.ws4j2ee.context.security.SecurityContext4J2EE#getX509Certificate()
150      */
151     public X509Certificate getX509Certificate() {
152         return this.x509Cert;
153     }
154 
155     /***
156      * @see org.apache.geranimo.ews.ws4j2ee.context.security.SecurityContext4J2EE#getKerberoseTicket()
157      */
158     public byte[] getKerberoseTicket() {
159         return this.kerberosTicket;
160     }
161 
162     /***
163      * Sets the kerberosTicket.
164      *
165      * @param kerberosTicket The kerberosTicket to set
166      */
167     public void setKerberosTicket(byte[] kerberosTicket) {
168         this.kerberosTicket = kerberosTicket;
169     }
170 
171     /***
172      * Sets the x509Cert.
173      *
174      * @param x509Cert The x509Cert to set
175      */
176     public void setX509Certificate(X509Certificate x509Cert) {
177         this.x509Cert = x509Cert;
178     }
179 
180     /***
181      * Sets the pwdDigest.
182      *
183      * @param pwdDigest The pwdDigest to set
184      */
185     public void setPasswordDigested(boolean isPwdDigested) {
186         this.isPwdDigested = isPwdDigested;
187     }
188 
189     /***
190      * @return boolean
191      */
192     public boolean isPasswordDigested() {
193         return isPwdDigested;
194     }
195 
196     /***
197      * Sets the pwd.
198      *
199      * @param pwd The pwd to set
200      */
201     public void setPassword(char[] password) {
202         this.pwd = password;
203     }
204 
205     /***
206      * @see org.apache.geranimo.ews.ws4j2ee.context.security.SecurityContext4J2EE#getPWDCallbackHandler4J2EE()
207      */
208     public CallbackHandler getPWDCallbackHandler4J2EE() {
209         return this.cbh;
210     }
211 
212     public void setPWDCallbackHandler4J2EE(CallbackHandler callbackHandler) {
213         this.cbh = callbackHandler;
214     }
215 
216 }