| 52 | import org.ietf.jgss.*; |
| 53 | |
| 54 | public class gssServer { |
| 55 | |
| 56 | private static int server_port = 11115; |
| 57 | private static String serviceName = "service@host"; |
| 58 | |
| 59 | private static GSSName name = null; |
| 60 | private static GSSCredential cred = null; |
| 61 | private static GSSManager mgr = GSSManager.getInstance(); |
| 62 | |
| 63 | public static void main(String argv[]) throws Exception |
| 64 | { |
| 65 | System.out.println("Starting GSS-API Server Example"); |
| 66 | |
| 67 | /* set up a shutdown hook to release GSSCredential storage |
| 68 | when the user terminates the server with Ctrl+C */ |
| 69 | Runtime.getRuntime().addShutdownHook(new Thread() { |
| 70 | @Override |
| 71 | public void run() { |
| 72 | try { |
| 73 | cred.dispose(); |
| 74 | } catch (GSSException e) { |
| 75 | System.out.println("Couldn't free GSSCredential storage"); |
| 76 | } |
| 77 | System.out.println("Freed GSSCredential storage"); |
| 78 | } |
| 79 | }); |
| 80 | |
| 81 | ServerSocket serverSocket = null; |
| 82 | Socket clientSocket = null; |
| 83 | OutputStream clientOut = null; |
| 84 | InputStream clientIn = null; |
| 85 | |
| 86 | /* create server socket */ |
| 87 | try { |
| 88 | serverSocket = new ServerSocket(server_port); |
| 89 | } catch (IOException e) { |
| 90 | System.out.println("Error on port: " + server_port + ", " + e); |
| 91 | System.exit(1); |
| 92 | } |
| 93 | |
| 94 | /* set up GSS-API name, credential */ |
| 95 | name = mgr.createName(serviceName, GSSName.NT_HOSTBASED_SERVICE); |
| 96 | cred = mgr.createCredential(name, GSSCredential.INDEFINITE_LIFETIME, |
| 97 | (Oid) null, GSSCredential.ACCEPT_ONLY); |
| 98 | |
| 99 | while(true) |
| 100 | { |
| 101 | byte[] inToken = null; |
| 102 | byte[] outToken = null; |
| 103 | byte[] buffer; |
| 104 | int err = 0; |
| 105 | |
| 106 | GSSName peer; |
| 107 | MessageProp supplInfo = new MessageProp(true); |
| 108 | |
| 109 | try { |
| 110 | System.out.println("\nwaiting for client connection" |
| 111 | + "-----------------------------"); |
nothing calls this directly
no test coverage detected