KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.jacorb.demo.sas;
2
3 import org.jacorb.security.sas.GssUpContext;
4 import org.omg.CORBA.ORB JavaDoc;
5 import org.omg.IOP.Codec JavaDoc;
6
7 public final class ListGssUpContext extends GssUpContext
8 {
9     private final String JavaDoc[][] auth_data = { { "jay", "test"} };
10     
11     public boolean validateContext(ORB JavaDoc orb, Codec JavaDoc 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         // Get username
26
StringBuffer JavaDoc ubuff = new StringBuffer JavaDoc();
27         for (int i=0; i < uname.length; i++) ubuff.append((char)uname[i]);
28         String JavaDoc username = ubuff.toString();
29         
30         // Get Password
31
StringBuffer JavaDoc buff = new StringBuffer JavaDoc();
32         for (int i=0; i < pswd.length; i++) buff.append((char)pswd[i]);
33         String JavaDoc password = buff.toString();
34         
35         System.out.println("---------> " + username + ", " + password);
36         
37         // Verify versus cached data
38
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