Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.jacorb.demo.sas;
  
  import java.io.File;
  import java.io.FileReader;
  
 
This is the client side of the sas demo. It just calls the single operation "printCert()" of the server. As you can see, sas is fully transparent.

Author(s):
Nicolas Noffke
 
 
 public class KerberosClient {
     private static Principal myPrincipal = null;
     private static Subject mySubject = null;
     private static ORB orb = null;
 
     public KerberosClient(String args[]) {
 
         try {
             // initialize the ORB.
              = ORB.init(argsnull);
 
             // get the server
             File f = new File(args[0]);
             if (!f.exists()) {
                 ..println("File " + args[0] + " does not exist.");
                 System.exit(-1);
             }
             if (f.isDirectory()) {
                 ..println("File " + args[0] + " is a directory.");
                 System.exit(-1);
             }
             BufferedReader br = new BufferedReader(new FileReader(f));
             org.omg.CORBA.Object obj = .string_to_object(br.readLine());
             br.close();
             SASDemo demo = SASDemoHelper.narrow(obj);
 
             //call single operation
             demo.printSAS();
             demo.printSAS();
             demo.printSAS();
 
             ..println("Call to server succeeded");
 
             demo.shutdown();
         } catch (Exception ex) {
             ex.printStackTrace();
         }
     }
 
     public static void main(String args[]) {
         if (args.length != 3) {
             ..println("Usage: java demo.sas.KerberosClient <ior_file> <username> <password>");
             System.exit(1);
         }
         // login - with Kerberos
         LoginContext loginContext = null;
         try {
             JaasTxtCalbackHandler txtHandler = new JaasTxtCalbackHandler();
             txtHandler.setMyUsername(args[1]);
             txtHandler.setMyPassword(args[2].toCharArray());
             loginContext = new LoginContext("KerberosClient"txtHandler);
             loginContext.login();
         } catch (LoginException le) {
             ..println("Login error: " + le);
             System.exit(1);
         }
          = loginContext.getSubject();
         ..println("Found principal " + .getName());
 
         // run in privileged mode
         final String[] finalArgs = args;
         try {
             Subject.doAs(new PrivilegedAction() {
                 public Object run() {
                     try {
                         KerberosClient client = new KerberosClient(finalArgs);
                     } catch (Exception e) {
                         ..println("Error running program: "+e);
                     }
                     ..println("Exiting privileged operation");
                     return null;
                 }
             });
         } catch (Exception e) {
             ..println("Error running privileged: "+e);
         }
    }
New to GrepCode? Check out our FAQ X