1 package org.jacorb.demo.sas; 2 3 import java.io.BufferedReader ; 4 import java.io.File ; 5 import java.io.FileReader ; 6 7 import org.jacorb.security.sas.GssUpContext; 8 import org.omg.CORBA.ORB ; 9 10 18 19 public class ListGssUpClient { 20 public static void main(String args[]) { 21 if (args.length != 3) { 22 System.out.println("Usage: java demo.sas.GssUpClient <ior_file> <username> <password>"); 23 System.exit(1); 24 } 25 26 try { 27 GssUpContext.setUsernamePassword(args[1], args[2]); 29 30 ORB orb = ORB.init(args, null); 32 33 File f = new File (args[0]); 35 if (!f.exists()) { 36 System.out.println("File " + args[0] + " does not exist."); 37 System.exit(-1); 38 } 39 if (f.isDirectory()) { 40 System.out.println("File " + args[0] + " is a directory."); 41 System.exit(-1); 42 } 43 BufferedReader br = new BufferedReader (new FileReader (f)); 44 org.omg.CORBA.Object obj = orb.string_to_object(br.readLine()); 45 br.close(); 46 SASDemo demo = SASDemoHelper.narrow(obj); 47 48 50 try { 51 demo.printSAS(); 52 } 53 catch (org.omg.CORBA.NO_PERMISSION e) 54 { 55 System.err.println("Login Failed!"); 56 57 GssUpContext.setUsernamePassword("jay", "test"); 59 try { 60 demo.printSAS(); 61 } 62 catch (org.omg.CORBA.NO_PERMISSION ex) 63 { 64 System.err.println("Failed again!"); 65 } 66 } 67 68 System.out.println("Call to server completed"); 69 } catch (Exception ex) { 70 ex.printStackTrace(); 71 } 72 } 73 } 74 | Popular Tags |