JAAS Authentication in a Client
We already have seen many examples of how a Java client authenticates itself to WebLogic Server. In most cases, the client submits a username-password combination as its credentials when setting up the JNDI context:
Hashtable env = new Hashtable( ); env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory"); env.put(Context.PROVIDER_URL, "t3://10.0.10.10:7001"); env.put(Context.SECURITY_PRINCIPAL, "system"); env.put(Context.SECURITY_CREDENTIALS, "12341234"); Context ctx = new InitialContext(env); // use the JNDI context as "system" user ...
WebLogic also lets you build Java clients that can use the more standard approach to authentication using JAAS. Even though JAAS authentication is somewhat more long-winded than traditional JNDI-based authentication, your clients will be more portable. Because of the pluggable nature of the JAAS framework, it should enable you to benefit from future changes to the authentication technology without changes to the client code.
Anatomy of a JAAS Client
A JAAS client involves the interplay among a number of classes and interfaces, as shown in Figure 17-5. Let’s examine how these different objects interact during JAAS-style authentication:
This represents the goal of the authentication sequence. Once a client has been authenticated, it obtains a
Subjectinstance that is populated with all of the principals that map to the client.
This is responsible for populating the