|
|
YOUR FEEDBACK
Did you read today's front page stories & breaking news?
SYS-CON.TV |
TOP THREE LINKS YOU MUST CLICK ON Administration
Extending the Admin Console for Your Custom Security Provider
By: Mike Kennedy
Digg This!
Extending the functionality of the WebLogic Server Admin Console provides you with the ability to incorporate the management of your custom application into one central location. We'll look at what is involved in modifying a Custom Security Provider available on dev2dev by adding MBean attributes to manage the TxDataSource, DatabaseUser, DatabaseUserPassword, DatabaseDriver, and DatabaseURL that are currently hard coded into the custom security provider MBean. There are two ways to extend the console: one is to have the WebLogic Server console attempt to render a details screen based on custom MBean attributes added to the DbSampleAuthenticator.xml file used to create the MBean. The second is to create a web app containing the class file and JSPs that the console will display when the custom security provider MBean is invoked. I'll discuss both in detail.
Adding Simple Data Types I'll start by adding onto an example found at http://dev2dev/codelibrary/code/sec_rdbms.jsp. The first thing is to add the attributes to the MBean so we can access them through either the command line with weblogic.Admin, or JMX code in a JavaBean or a JSP.
In the DbSampleAuthenticator.xml file, add the following writeable String attributes:
Once you have added the attributes, you can run ant against the build.xml found in the root directory. Many things happen in this build.xml and it may be worth your while to examine this file more closely as MBeans are created, jar'd, and copied to the $WL_HOME/server/lib/mbeantypes directory. If WebLogic Server is already running, it must be restarted for the custom MBeans to be recognized. Once WebLogic Server is running, you should see a screen similar to that in Figure 1, a new Custom Security Authenticator in the console named DbSampleAuthenticator. (Note: this is WebLogic Server 8.1.) When you select DbSampleAuthenticator, you should see a screen similar to that in Figure 2. After the DbSampleAuthenticator has been created and you select the Details tab, you should see Figure 3. If you look at the Java code generated for DbSampleAuthenticatorMBean, you'll see the getters and setters for the various attributes you added. (How exactly do we access these new MBean Attributes? To better understand how the MBeanMaker works, refer to Developing Security Providers for Weblogic Server [http://edocs/wls/docs81/dvspisec/ design.html#1171038]).
How Do We Pass This MBean Around?
public void initialize(ProviderMBean providermbean, We'll modify the AppConfigurationEntry getConfiguration, called here by public AppConfigurationEntry getLoginModuleConfiguration(). A configuration options map is passed to the LoginModule, a perfect place to add our new MBean so the attributes can be accessed later on. This is all we need to do to pass the MBean to the LoginModule's initialize method. Now I'll look at how to access the attributes.
Accessing the MBean's Attributes That's it to get the MBean attributes! To see how these are used, look at DbSampleAuthenticatorDatabase.java, where we use the driver, userid, password, and URL to get a database connection when WebLogic Server initializes when JNDI is not set up and the JDBC datasource cannot be accessed.
Extending the Console so the Custom Page is Displayed That's all we need to do to determine which MBean is called when you click on the custom or any other security provider, this class is called and you can either override the default generated page or return your own. Now when you click on the DbSampleAuthenticator link, Figure 4 should be displayed.
Creating the JSP
Get the Attributes
Set the Attributes The last thing to note is that since the JSP instantiates the MBean, you will need to import the MBean class, DbSampleAuthenticatorMBean, which means that the class examples.db.security.providers.authentication. DbSampleAuthenticatorMBean must be in the web-app/WEB-INF/classes directory. To set the MBeans from the command line, use Listing 6.
Conclusion
Acknowledgment Even though this example makes use of a TxDataSource, we [BEA] do not support the use of WLS resources by security providers. Any operation which goes through a WLS protected resource, such as a connection pool, is prohibited. You can and should directly access the database via JDBC. BEA WEBLOGIC LATEST STORIES
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK BREAKING NEWS FROM THE WIRES
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||