001: package org.jacorb.security.sas;
002:
003: /*
004: * JacORB - a free Java ORB
005: *
006: * Copyright (C) 2002-2004 Gerald Brose
007: *
008: * This library is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU Library General Public
010: * License as published by the Free Software Foundation; either
011: * version 2 of the License, or (at your option) any later version.
012: *
013: * This library is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
016: * Library General Public License for more details.
017: *
018: * You should have received a copy of the GNU Library General Public
019: * License along with this library; if not, write to the Free
020: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
021: */
022:
023: import java.io.InputStream;
024: import java.io.OutputStream;
025: import java.security.Provider;
026:
027: import org.ietf.jgss.ChannelBinding;
028: import org.ietf.jgss.GSSCredential;
029: import org.ietf.jgss.GSSException;
030: import org.ietf.jgss.MessageProp;
031: import org.ietf.jgss.Oid;
032:
033: import sun.security.jgss.spi.GSSContextSpi;
034: import sun.security.jgss.spi.GSSCredentialSpi;
035: import sun.security.jgss.spi.GSSNameSpi;
036:
037: /**
038: * This is the GSS-API Sercurity Provider Interface (SPI) for the GSSUP Context
039: *
040: * @author David Robison
041: * @version $Id: GSSUPContextSpi.java,v 1.10 2004/05/06 12:40:01 nicolas Exp $
042: */
043:
044: public final class GSSUPContextSpi implements GSSContextSpi {
045: private Provider provider = null;
046: private Oid mechOid = null;
047: private int lifetime;
048: private boolean mutualAuth = false;
049: private boolean relayDet = false;
050: private boolean sequenceDet = false;
051: private boolean credDeleg = false;
052: private boolean anonymity = false;
053: private boolean conf = false;
054: private boolean integ = false;
055: private boolean established = false;
056: private ChannelBinding channelBinding = null;
057:
058: private GSSNameSpi targetName;
059: private GSSCredentialSpi sourceCred;
060:
061: public GSSUPContextSpi(Provider provider, Oid mechOid,
062: GSSNameSpi nameSpi, GSSCredentialSpi credSpi, int lifetime) {
063: this .provider = provider;
064: this .mechOid = mechOid;
065: this .targetName = nameSpi;
066: this .sourceCred = credSpi;
067: this .lifetime = lifetime;
068: }
069:
070: public Provider getProvider() {
071: return provider;
072: }
073:
074: public void requestLifetime(int lifetime) throws GSSException {
075: this .lifetime = lifetime;
076: }
077:
078: public void requestMutualAuth(boolean tf) throws GSSException {
079: mutualAuth = tf;
080: }
081:
082: public void requestReplayDet(boolean tf) throws GSSException {
083: relayDet = tf;
084: }
085:
086: public void requestSequenceDet(boolean tf) throws GSSException {
087: sequenceDet = false;
088: }
089:
090: public void requestCredDeleg(boolean tf) throws GSSException {
091: credDeleg = tf;
092: }
093:
094: public void requestAnonymity(boolean tf) throws GSSException {
095: anonymity = tf;
096: }
097:
098: public void requestConf(boolean tf) throws GSSException {
099: conf = tf;
100: }
101:
102: public void requestInteg(boolean tf) throws GSSException {
103: integ = tf;
104: }
105:
106: public void setChannelBinding(ChannelBinding cb)
107: throws GSSException {
108: channelBinding = cb;
109: }
110:
111: public boolean getCredDelegState() {
112: return credDeleg;
113: }
114:
115: public boolean getMutualAuthState() {
116: return mutualAuth;
117: }
118:
119: public boolean getReplayDetState() {
120: return relayDet;
121: }
122:
123: public boolean getSequenceDetState() {
124: return sequenceDet;
125: }
126:
127: public boolean getAnonymityState() {
128: return anonymity;
129: }
130:
131: public boolean isTransferable() throws GSSException {
132: return true;
133: }
134:
135: public boolean isProtReady() {
136: return false;
137: }
138:
139: public boolean getConfState() {
140: return conf;
141: }
142:
143: public boolean getIntegState() {
144: return integ;
145: }
146:
147: public int getLifetime() {
148: return lifetime;
149: }
150:
151: public boolean isEstablished() {
152: return established;
153: }
154:
155: public GSSNameSpi getSrcName() throws GSSException {
156: return sourceCred.getName();
157: }
158:
159: public GSSNameSpi getTargName() throws GSSException {
160: return targetName;
161: }
162:
163: public Oid getMech() throws GSSException {
164: return mechOid;
165: }
166:
167: public GSSCredentialSpi getDelegCred() throws GSSException {
168: return null;
169: }
170:
171: public byte[] initSecContext(InputStream inStream, int inLen)
172: throws GSSException {
173: established = true;
174: return sourceCred.getName().toString().getBytes();
175: }
176:
177: public byte[] acceptSecContext(InputStream inStream, int inLen)
178: throws GSSException {
179: established = true;
180: try {
181: byte[] inBytes = new byte[inStream.available()];
182: inStream.read(inBytes);
183: GSSNameSpi sourceName = new GSSUPNameSpi(provider, mechOid,
184: inBytes, null);
185: sourceCred = new GSSUPCredentialSpi(provider, mechOid,
186: sourceName, GSSCredential.DEFAULT_LIFETIME,
187: GSSCredential.DEFAULT_LIFETIME,
188: GSSCredential.ACCEPT_ONLY);
189: } catch (Exception e) {
190: // logger.error("Error acceptSecContext: " + e);
191: }
192: return null;
193: }
194:
195: public int getWrapSizeLimit(int i1, boolean b1, int i2)
196: throws GSSException {
197: return 0;
198: }
199:
200: public void wrap(InputStream inStream, OutputStream outStream,
201: MessageProp mp) throws GSSException {
202: }
203:
204: public byte[] wrap(byte[] b, int i1, int i2, MessageProp mp)
205: throws GSSException {
206: return null;
207: }
208:
209: public int wrap(byte[] b1, int i1, int i2, byte[] b2, int i3,
210: MessageProp mp) throws GSSException {
211: return 0;
212: }
213:
214: public void wrap(byte[] b, int i1, int i2, OutputStream outStream,
215: MessageProp mp) throws GSSException {
216: }
217:
218: public void unwrap(InputStream inStream, OutputStream outStream,
219: MessageProp mp) throws GSSException {
220: }
221:
222: public byte[] unwrap(byte[] b, int i1, int i2, MessageProp mp)
223: throws GSSException {
224: return null;
225: }
226:
227: public int unwrap(byte[] b1, int i1, int i2, byte[] b2, int i3,
228: MessageProp mp) throws GSSException {
229: return 0;
230: }
231:
232: public int unwrap(InputStream inStream, byte[] b, int i1,
233: MessageProp mp) throws GSSException {
234: return 0;
235: }
236:
237: public void getMIC(InputStream inStream, OutputStream outStream,
238: MessageProp mp) throws GSSException {
239: }
240:
241: public byte[] getMIC(byte[] b1, int i1, int i2, MessageProp mp)
242: throws GSSException {
243: return null;
244: }
245:
246: public void verifyMIC(InputStream inStream1, InputStream inStream2,
247: MessageProp mp) throws GSSException {
248: }
249:
250: public void verifyMIC(byte[] b1, int i1, int i2, byte[] b2, int i3,
251: int i4, MessageProp mp) throws GSSException {
252: }
253:
254: public byte[] export() throws GSSException {
255: return null;
256: }
257:
258: public void dispose() throws GSSException {
259: channelBinding = null;
260: provider = null;
261: mechOid = null;
262: }
263: }
|