01: package org.jacorb.demo.sas;
02:
03: import java.io.FileWriter;
04: import java.io.PrintWriter;
05:
06: import org.jacorb.security.sas.SASInitializer;
07: import org.omg.CORBA.ORB;
08: import org.omg.PortableServer.POA;
09:
10: /**
11: * This is the server part of the sas demo. It demonstrates
12: * how to get access to the certificates that the client sent
13: * for mutual authentication. The certificate chain can be
14: * accessed via the Security Level 2 interfaces.
15: *
16: * @author Nicolas Noffke
17: * @version $Id: Server.java,v 1.2 2004/02/05 10:49:54 nick.cross Exp $
18: */
19:
20: public class Server extends SASDemoPOA {
21:
22: private ORB orb;
23:
24: public Server(ORB orb) {
25: this .orb = orb;
26: }
27:
28: /**
29: * This method is from the IDL--interface. It prints out the
30: * received client cert (if available).
31: */
32: public void printSAS() {
33: try {
34: org.omg.PortableInterceptor.Current current = (org.omg.PortableInterceptor.Current) orb
35: .resolve_initial_references("PICurrent");
36: org.omg.CORBA.Any anyName = current
37: .get_slot(SASInitializer.sasPrincipalNamePIC);
38: String name = anyName.extract_string();
39: System.out.println("printSAS for user " + name);
40: } catch (Exception e) {
41: System.out.println("printSAS Error: " + e);
42: }
43: }
44:
45: public static void main(String[] args) {
46: if (args.length != 1) {
47: System.out
48: .println("Usage: java demo.sas.GssUpServer <ior_file>");
49: System.exit(-1);
50: }
51:
52: try {
53: ORB orb = ORB.init(args, null);
54: POA poa = (POA) orb.resolve_initial_references("RootPOA");
55: poa.the_POAManager().activate();
56: org.omg.CORBA.Object demo = poa
57: .servant_to_reference(new Server(orb));
58: PrintWriter pw = new PrintWriter(new FileWriter(args[0]));
59: pw.println(orb.object_to_string(demo));
60: pw.flush();
61: pw.close();
62: orb.run();
63: } catch (Exception e) {
64: e.printStackTrace();
65: }
66: }
67: }
|