1 package org.jacorb.security.sas; 2 3 22 23 import org.apache.avalon.framework.logger.Logger; 24 import org.apache.avalon.framework.configuration.Configuration; 25 import org.apache.avalon.framework.configuration.ConfigurationException; 26 27 import org.omg.CORBA.ORB ; 28 import org.omg.CSIIOP.CompoundSecMechList; 29 import org.omg.GSSUP.GSSUPMechOID; 30 import org.omg.GSSUP.InitialContextToken; 31 import org.omg.IOP.Codec ; 32 33 public class GssUpContext 34 implements ISASContext 35 { 36 private Logger logger = null; 37 private static String username = ""; 38 private static String password = ""; 39 protected InitialContextToken initialContextToken = null; 40 41 public void configure(Configuration configuration) 42 throws ConfigurationException 43 { 44 logger = 45 ((org.jacorb.config.Configuration)configuration).getNamedLogger("jacorb.security.sas.GSSUP"); 46 } 47 48 public static void setUsernamePassword(String username, String password) { 49 GssUpContext.username = username; 50 GssUpContext.password = password; 51 } 52 53 public String getMechOID() 54 { 55 return GSSUPMechOID.value.substring(4); 56 } 57 58 61 public byte[] createClientContext(ORB orb, Codec codec, CompoundSecMechList csmList) 62 { 63 byte[] contextToken = GSSUPNameSpi.encode(orb, codec, username, password, new byte[0]); 64 initialContextToken = GSSUPNameSpi.decode(orb, codec, contextToken); 65 return contextToken; 66 } 67 68 71 public String getClientPrincipal() 72 { 73 return username; 74 } 75 76 79 public boolean validateContext(ORB orb, Codec codec, byte[] contextToken) 80 { 81 initialContextToken = GSSUPNameSpi.decode(orb, codec, contextToken); 82 return (initialContextToken != null); 83 } 84 85 88 public String getValidatedPrincipal() { 89 if (initialContextToken == null) return null; 90 return new String (initialContextToken.username); 91 } 92 93 96 public void initClient() { 97 } 98 99 102 public void initTarget() { 103 } 104 } 105 | Popular Tags |