KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > security > sas > GSSUPContextSpi


1 package org.jacorb.security.sas;
2
3 /*
4  * JacORB - a free Java ORB
5  *
6  * Copyright (C) 2002-2004 Gerald Brose
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the Free
20  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */

22
23 import java.io.InputStream JavaDoc;
24 import java.io.OutputStream JavaDoc;
25 import java.security.Provider JavaDoc;
26
27 import org.ietf.jgss.ChannelBinding JavaDoc;
28 import org.ietf.jgss.GSSCredential JavaDoc;
29 import org.ietf.jgss.GSSException JavaDoc;
30 import org.ietf.jgss.MessageProp JavaDoc;
31 import org.ietf.jgss.Oid JavaDoc;
32
33 import sun.security.jgss.spi.GSSContextSpi;
34 import sun.security.jgss.spi.GSSCredentialSpi;
35 import sun.security.jgss.spi.GSSNameSpi;
36
37 /**
38  * This is the GSS-API Sercurity Provider Interface (SPI) for the GSSUP Context
39  *
40  * @author David Robison
41  * @version $Id: GSSUPContextSpi.java,v 1.10 2004/05/06 12:40:01 nicolas Exp $
42  */

43
44 public final class GSSUPContextSpi
45     implements GSSContextSpi
46 {
47     private Provider JavaDoc provider = null;
48     private Oid JavaDoc mechOid = null;
49     private int lifetime;
50     private boolean mutualAuth = false;
51     private boolean relayDet = false;
52     private boolean sequenceDet = false;
53     private boolean credDeleg = false;
54     private boolean anonymity = false;
55     private boolean conf = false;
56     private boolean integ = false;
57     private boolean established = false;
58     private ChannelBinding JavaDoc channelBinding = null;
59
60     private GSSNameSpi targetName;
61     private GSSCredentialSpi sourceCred;
62
63     public GSSUPContextSpi(Provider JavaDoc provider,
64                            Oid JavaDoc mechOid,
65                            GSSNameSpi nameSpi,
66                            GSSCredentialSpi credSpi,
67                            int lifetime)
68     {
69         this.provider = provider;
70         this.mechOid = mechOid;
71         this.targetName = nameSpi;
72         this.sourceCred = credSpi;
73         this.lifetime = lifetime;
74     }
75
76     public Provider JavaDoc getProvider()
77     {
78         return provider;
79     }
80
81     public void requestLifetime(int lifetime)
82         throws GSSException JavaDoc
83     {
84         this.lifetime = lifetime;
85     }
86
87     public void requestMutualAuth(boolean tf) throws GSSException JavaDoc
88     {
89         mutualAuth = tf;
90     }
91
92     public void requestReplayDet(boolean tf) throws GSSException JavaDoc
93     {
94         relayDet = tf;
95     }
96
97     public void requestSequenceDet(boolean tf) throws GSSException JavaDoc
98     {
99         sequenceDet = false;
100     }
101
102     public void requestCredDeleg(boolean tf) throws GSSException JavaDoc
103     {
104         credDeleg = tf;
105     }
106
107     public void requestAnonymity(boolean tf) throws GSSException JavaDoc
108     {
109         anonymity = tf;
110     }
111
112     public void requestConf(boolean tf) throws GSSException JavaDoc
113     {
114         conf = tf;
115     }
116
117     public void requestInteg(boolean tf) throws GSSException JavaDoc
118     {
119         integ = tf;
120     }
121
122     public void setChannelBinding(ChannelBinding JavaDoc cb) throws GSSException JavaDoc
123     {
124         channelBinding = cb;
125     }
126
127     public boolean getCredDelegState()
128     {
129         return credDeleg;
130     }
131
132     public boolean getMutualAuthState()
133     {
134         return mutualAuth;
135     }
136
137     public boolean getReplayDetState()
138     {
139         return relayDet;
140     }
141
142     public boolean getSequenceDetState()
143     {
144         return sequenceDet;
145     }
146
147     public boolean getAnonymityState()
148     {
149         return anonymity;
150     }
151
152     public boolean isTransferable() throws GSSException JavaDoc
153     {
154         return true;
155     }
156
157     public boolean isProtReady()
158     {
159         return false;
160     }
161
162     public boolean getConfState()
163     {
164         return conf;
165     }
166
167     public boolean getIntegState()
168     {
169         return integ;
170     }
171
172     public int getLifetime()
173     {
174         return lifetime;
175     }
176
177     public boolean isEstablished()
178     {
179         return established;
180     }
181
182     public GSSNameSpi getSrcName() throws GSSException JavaDoc
183     {
184         return sourceCred.getName();
185     }
186
187     public GSSNameSpi getTargName() throws GSSException JavaDoc
188     {
189         return targetName;
190     }
191
192     public Oid JavaDoc getMech() throws GSSException JavaDoc
193     {
194         return mechOid;
195     }
196
197     public GSSCredentialSpi getDelegCred() throws GSSException JavaDoc
198     {
199         return null;
200     }
201
202     public byte[] initSecContext(InputStream JavaDoc inStream, int inLen)
203         throws GSSException JavaDoc
204     {
205         established = true;
206         return sourceCred.getName().toString().getBytes();
207     }
208
209     public byte[] acceptSecContext(InputStream JavaDoc inStream, int inLen)
210         throws GSSException JavaDoc
211     {
212         established = true;
213         try
214         {
215             byte[] inBytes = new byte[inStream.available()];
216             inStream.read(inBytes);
217             GSSNameSpi sourceName =
218                 new GSSUPNameSpi(provider, mechOid, inBytes, null);
219             sourceCred =
220                 new GSSUPCredentialSpi(provider,
221                                        mechOid,
222                                        sourceName,
223                                        GSSCredential.DEFAULT_LIFETIME,
224                                        GSSCredential.DEFAULT_LIFETIME,
225                                        GSSCredential.ACCEPT_ONLY);
226         }
227         catch (Exception JavaDoc e)
228         {
229             // logger.error("Error acceptSecContext: " + e);
230
}
231         return null;
232     }
233
234     public int getWrapSizeLimit(int i1, boolean b1, int i2) throws GSSException JavaDoc
235     {
236         return 0;
237     }
238
239     public void wrap(InputStream JavaDoc inStream, OutputStream JavaDoc outStream, MessageProp JavaDoc mp) throws GSSException JavaDoc
240     {
241     }
242
243     public byte[] wrap(byte[] b, int i1, int i2, MessageProp JavaDoc mp) throws GSSException JavaDoc
244     {
245         return null;
246     }
247
248     public int wrap(byte[] b1, int i1, int i2, byte[] b2, int i3, MessageProp JavaDoc mp) throws GSSException JavaDoc
249     {
250         return 0;
251     }
252
253     public void wrap(byte[] b, int i1, int i2, OutputStream JavaDoc outStream, MessageProp JavaDoc mp) throws GSSException JavaDoc
254     {
255     }
256
257     public void unwrap(InputStream JavaDoc inStream, OutputStream JavaDoc outStream, MessageProp JavaDoc mp) throws GSSException JavaDoc
258     {
259     }
260
261     public byte[] unwrap(byte[] b, int i1, int i2, MessageProp JavaDoc mp) throws GSSException JavaDoc
262     {
263         return null;
264     }
265
266     public int unwrap(byte[] b1, int i1, int i2, byte[] b2, int i3, MessageProp JavaDoc mp) throws GSSException JavaDoc
267     {
268         return 0;
269     }
270
271     public int unwrap(InputStream JavaDoc inStream, byte[] b, int i1, MessageProp JavaDoc mp) throws GSSException JavaDoc
272     {
273         return 0;
274     }
275
276     public void getMIC(InputStream JavaDoc inStream, OutputStream JavaDoc outStream, MessageProp JavaDoc mp) throws GSSException JavaDoc
277     {
278     }
279
280     public byte[] getMIC(byte[] b1, int i1, int i2, MessageProp JavaDoc mp) throws GSSException JavaDoc
281     {
282         return null;
283     }
284
285     public void verifyMIC(InputStream JavaDoc inStream1, InputStream JavaDoc inStream2, MessageProp JavaDoc mp) throws GSSException JavaDoc
286     {
287     }
288
289     public void verifyMIC(byte[] b1, int i1, int i2, byte[] b2, int i3, int i4, MessageProp JavaDoc mp) throws GSSException JavaDoc
290     {
291     }
292
293     public byte[] export() throws GSSException JavaDoc
294     {
295         return null;
296     }
297
298     public void dispose() throws GSSException JavaDoc
299     {
300         channelBinding = null;
301         provider = null;
302         mechOid = null;
303     }
304 }
305
Popular Tags