Skip to content

WebLogic security authentication for EJB clients

When a Java client needs to connect to a WebLogic Server to access Enterprise JavaBeans (EJBs), it must provide valid security credentials to establish the connection. This authentication process is typically handled through the JNDI InitialContext by setting specific security properties.^[600-developer-java-application-server-weblogic-weblogic-ejb.md]

Configuration Properties

To authenticate a client, the following properties must be set on the Properties object used to create the InitialContext:^[600-developer-java-application-server-weblogic-weblogic-ejb.md]

  • Context.SECURITY_PRINCIPAL: Specifies the username, for example, weblogic.
  • Context.SECURITY_CREDENTIALS: Specifies the password associated with the principal.

Implementation Example

The following code snippet demonstrates how to configure these properties. In this example, the client connects to a local server on port 8080 using the username "weblogic" and the password "1qaz2wsx".^[600-developer-java-application-server-weblogic-weblogic-ejb.md]

Properties prop = new Properties();
prop.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
prop.put(Context.PROVIDER_URL, "t3://localhost:8080");
prop.put(Context.SECURITY_PRINCIPAL, "weblogic");
prop.put(Context.SECURITY_CREDENTIALS, "1qaz2wsx");

InitialContext ctx = new InitialContext(prop);

Once the InitialContext is established, the authenticated client can perform JNDI lookups to invoke remote EJB methods.^[600-developer-java-application-server-weblogic-weblogic-ejb.md]

Sources