KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > demo > sas > Server


1 package org.jacorb.demo.sas;
2
3 import java.io.FileWriter JavaDoc;
4 import java.io.PrintWriter JavaDoc;
5
6 import org.jacorb.security.sas.SASInitializer;
7 import org.omg.CORBA.ORB JavaDoc;
8 import org.omg.PortableServer.POA JavaDoc;
9
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
23     private ORB JavaDoc orb;
24
25     public Server(ORB JavaDoc orb)
26     {
27         this.orb = orb;
28     }
29
30     /**
31      * This method is from the IDL--interface. It prints out the
32      * received client cert (if available).
33      */

34     public void printSAS()
35     {
36         try
37         {
38             org.omg.PortableInterceptor.Current JavaDoc current = (org.omg.PortableInterceptor.Current JavaDoc) orb.resolve_initial_references( "PICurrent" );
39             org.omg.CORBA.Any JavaDoc anyName = current.get_slot( SASInitializer.sasPrincipalNamePIC );
40             String JavaDoc name = anyName.extract_string();
41             System.out.println("printSAS for user " + name);
42         }
43         catch (Exception JavaDoc e)
44         {
45             System.out.println("printSAS Error: " + e);
46         }
47     }
48
49     public static void main( String JavaDoc[] args )
50     {
51         if( args.length != 1 )
52         {
53             System.out.println( "Usage: java demo.sas.GssUpServer <ior_file>" );
54             System.exit( -1 );
55         }
56
57         try
58         {
59             ORB JavaDoc orb = ORB.init( args, null );
60             POA JavaDoc poa = (POA JavaDoc) orb.resolve_initial_references( "RootPOA" );
61             poa.the_POAManager().activate();
62             org.omg.CORBA.Object JavaDoc demo = poa.servant_to_reference( new Server( orb ));
63             PrintWriter JavaDoc pw = new PrintWriter JavaDoc( new FileWriter JavaDoc( args[ 0 ] ));
64             pw.println( orb.object_to_string( demo ));
65             pw.flush();
66             pw.close();
67             orb.run();
68         }
69         catch( Exception JavaDoc e )
70         {
71             e.printStackTrace();
72         }
73     }
74 }
75
Popular Tags