} }
Files Prepare Run Troubleshooting Related Topics
This package demonstrates the use of the Java Authentication and Authorization Service by validating a username and password, and then, if they are valid, executing the stateless session Trader EJB.
The SampleClient creates a login context that uses the WebLogic Server UsernamePasswordLoginModule and SampleCallbackHandler to validate the user. The example can be run with or without supplying the username and password as parameters. The URL of WebLogic Server is required as a parameter to access the Trader EJB. If a username and password are not supplied, then SampleCallbackHandler prompts the user for both. The supplied URL will be used by SampleCallbackHandler as the location on the WebLogic Server where the user's credentials are validated. If the user is valid, has provided the correct password, and has sufficient permissions to execute the EJB, then SampleClient uses the WebLogic Server Security class weblogic.security.Security.runAs to call SampleAction, which handles the execution of the Trader EJB.
NOTE: The UsernamePasswordLoginModule class is located on the WebLogic Server distribution in the weblogic.jar file.
Directory Location:
MW_HOME/wlserver_10.3/samples/server/examples/src/examples/security/jaas/
(where MW_HOME is the directory containing your WebLogic Server installation)
File Click source files to view code. |
Description |
---|---|
build.xml | An ant build file that contains targets for building and running the example. |
SampleAction.java | This class extends BaseClient, implements PrivilegedAction. |
SampleCallbackHandler.java | This class implements CallbackHandler. |
SampleClient.java | This class provides the sample client for JAAS user authentication. |
sample_jaas.config | Login configuration for the JAAS sample application. |
Before working with this example:
No special configuration is required for this example
Change to the SAMPLES_HOME\server\examples\src\examples\security\jaas directory, where SAMPLES_HOME refers to the main WebLogic Server examples directory, such as d:\Oracle\Middleware\wlserver_10.3\samples.
The ant command builds and deploys the files in the JAAS example as follows:
C:\Oracle\Middleware\wlserver_10.3\samples\server\examples\src\examples\security\jaas>ant run Buildfile: build.xml run: [java] username: weblogic [java] password: ******** [java] URL: t3://localhost:7001 [java] Creating a trader [java] Buying 100 shares of BEAS. [java] Buying 200 shares of MSFT. [java] Buying 300 shares of AMZN. [java] Buying 400 shares of HWP. [java] Selling 100 shares of BEAS. [java] Selling 200 shares of MSFT. [java] Selling 300 shares of AMZN. [java] Selling 400 shares of HWP. [java] Removing the trader BUILD SUCCESSFUL Total time: 6 seconds
(Internet connection required.)