1 7 package org.jboss.security.jndi; 8 9 import org.jboss.security.SimplePrincipal; 10 import org.jnp.interfaces.NamingContextFactory; 11 12 import javax.naming.Context ; 13 import javax.naming.NamingException ; 14 import java.security.Principal ; 15 import java.util.Hashtable ; 16 17 32 public class JndiLoginInitialContextFactory extends NamingContextFactory 33 { 34 36 45 public Context getInitialContext(Hashtable env) 46 throws NamingException 47 { 48 Object credentials = env.get(Context.SECURITY_CREDENTIALS); 50 Object principal = env.get(Context.SECURITY_PRINCIPAL); 51 Principal securityPrincipal = null; 52 if( principal instanceof Principal ) 54 { 55 securityPrincipal = (Principal) principal; 56 } 57 else 58 { 59 String username = principal.toString(); 61 securityPrincipal = new SimplePrincipal(username); 62 } 63 SecurityAssociationActions.setPrincipalInfo(securityPrincipal, credentials); 65 Context iniCtx = super.getInitialContext(env); 67 return iniCtx; 68 } 69 70 } 71 | Popular Tags |