1 package org.jacorb.demo.sas; 2 3 import org.jacorb.security.sas.GssUpContext; 4 import org.omg.CORBA.ORB ; 5 import org.omg.IOP.Codec ; 6 7 public final class ListGssUpContext extends GssUpContext 8 { 9 private final String [][] auth_data = { { "jay", "test"} }; 10 11 public boolean validateContext(ORB orb, Codec codec, byte[] contextToken) 12 { 13 boolean b = super.validateContext(orb, codec, contextToken); 14 if (b) 15 { 16 return validateUsernamePassword(initialContextToken.username, initialContextToken.password); 17 } 18 return b; 19 } 20 21 private boolean validateUsernamePassword(byte[] uname, byte[] pswd) 22 { 23 System.out.println("validating..."); 24 25 StringBuffer ubuff = new StringBuffer (); 27 for (int i=0; i < uname.length; i++) ubuff.append((char)uname[i]); 28 String username = ubuff.toString(); 29 30 StringBuffer buff = new StringBuffer (); 32 for (int i=0; i < pswd.length; i++) buff.append((char)pswd[i]); 33 String password = buff.toString(); 34 35 System.out.println("---------> " + username + ", " + password); 36 37 boolean valid = false; 39 for (int i=0; i < auth_data.length; i++) 40 { 41 if (auth_data[i][0].equals(username)) 42 { 43 if (auth_data[i][1].equals(password)) valid = true; 44 break; 45 } 46 } 47 return valid; 48 } 49 } | Popular Tags |