1 package org.jacorb.demo.sas; 2 3 import java.io.FileWriter ; 4 import java.io.PrintWriter ; 5 6 import org.jacorb.security.sas.SASInitializer; 7 import org.omg.CORBA.ORB ; 8 import org.omg.PortableServer.POA ; 9 10 19 20 public class Server extends SASDemoPOA 21 { 22 23 private ORB orb; 24 25 public Server(ORB orb) 26 { 27 this.orb = orb; 28 } 29 30 34 public void printSAS() 35 { 36 try 37 { 38 org.omg.PortableInterceptor.Current current = (org.omg.PortableInterceptor.Current ) orb.resolve_initial_references( "PICurrent" ); 39 org.omg.CORBA.Any anyName = current.get_slot( SASInitializer.sasPrincipalNamePIC ); 40 String name = anyName.extract_string(); 41 System.out.println("printSAS for user " + name); 42 } 43 catch (Exception e) 44 { 45 System.out.println("printSAS Error: " + e); 46 } 47 } 48 49 public static void main( String [] 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 orb = ORB.init( args, null ); 60 POA poa = (POA ) orb.resolve_initial_references( "RootPOA" ); 61 poa.the_POAManager().activate(); 62 org.omg.CORBA.Object demo = poa.servant_to_reference( new Server( orb )); 63 PrintWriter pw = new PrintWriter ( new FileWriter ( args[ 0 ] )); 64 pw.println( orb.object_to_string( demo )); 65 pw.flush(); 66 pw.close(); 67 orb.run(); 68 } 69 catch( Exception e ) 70 { 71 e.printStackTrace(); 72 } 73 } 74 } 75 | Popular Tags |