Debian Codegraph @

gss/src/main/java/org/globus/gsi/gssapi/net/impl/GSIGssSocket.java

raw
1 /*
2 * Copyright 1999-2010 University of Chicago
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
5 * compliance with the License. You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software distributed under the License is
10 * distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11 * express or implied.
12 *
13 * See the License for the specific language governing permissions and limitations under the License.
14 */
15 package org.globus.gsi.gssapi.net.impl;
16
17 import java.net.Socket;
18 import java.io.IOException;
19
20 import org.globus.gsi.gssapi.net.GssSocket;
21
22 import org.ietf.jgss.GSSContext;
23
24 public class GSIGssSocket extends GssSocket {
25
26 public GSIGssSocket(String host, int port, GSSContext context)
27 throws IOException {
28 super(host, port, context);
29 }
30
31 public GSIGssSocket(Socket socket, GSSContext context) {
32 super(socket, context);
33 }
34
35 public void setWrapMode(int mode) {
36 this.mode = mode;
37 }
38
39 public int getWrapMode() {
40 return this.mode;
41 }
42
43 protected void writeToken(byte [] token)
44 throws IOException {
45 if (this.out == null) {
46 if (this.mode == -1) {
47 if (this.in != null) {
48 this.mode = ((GSIGssInputStream)in).getWrapMode();
49 }
50 }
51 this.out = new GSIGssOutputStream(this.socket.getOutputStream(),
52 this.context,
53 this.mode);
54 }
55 ((GSIGssOutputStream)this.out).writeToken(token);
56 }
57
58 protected byte[] readToken()
59 throws IOException {
60 if (this.in == null) {
61 this.in = new GSIGssInputStream(this.socket.getInputStream(),
62 this.context);
63 }
64 return ((GSIGssInputStream)this.in).readHandshakeToken();
65 }
66
67 }