Weblogic Authors: Yeshim Deniz, Elizabeth White, Michael Meiner, Michael Bushong, Avi Rosenthal

Related Topics: Weblogic

Weblogic: Article

Extending the Admin Console for Your Custom Security Provider

Incorporate the management of your custom application

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
First, let's look at just adding custom attributes that represent simple data types to the DbSampleAuthenticator xml file and see how to gain access to these values when we want to access the database, both during initialization of WebLogic Server when a datasource is not yet available and afterwards when users are being authenticated when accessing secured resources.

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:

  • DatabaseUser
  • DatabaseUserPassword
  • DatabaseURL
  • DatabaseJDBCDriver
  • DataSourceName

Name = "DatabaseUser"
Type = "java.lang.String"
Writeable = "true"
Default = ""scott""/>

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?
There is, of course, more than one way to access these new attributes. The first is via a JMX call, covered later; and the second is through the Security Provider's LoginModule. The first file to examine and change is DbSampleAuthenticationProviderImpl.java, which is called in the WebLogic Server initialization.

public void initialize(ProviderMBean providermbean,
SecurityServices securityservices)

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
The implementation of the LoginModule will be changed to retrieve the ProviderMBean passed in the Map argument. (see http://edocs/wls/docs81/dvspisec/atn.html#1153042 Implement the JAAS LoginModule Interface). From there, I'll pass the MBean attributes to the method responsible for authenticating the user (see Listings 1 and 2).

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
Now the fun begins; what do we need to accomplish this feat? Not too much, actually. You'll need a Web app with some default values in the web.xml file and a class that is called to return the JSP page the console will use to render in place of the default details page (see Listing 4). In this example, the JSP must be able to look up the Security MBean via JMX and set the attributes so that the LoginModule can still access them later on. You may ask, do I need a custom Web app for each custom security provider? No, this single Web app with the Java class can handle every security provider and is called each time a user is authenticated; it's up to this class to determine which Security MBean is called and either return null, or there is no JSP page to render; or return the JSP page for the console to display. You could have one Authentication provider with a custom JSP page and another with the default console pages.

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
I used the console extension taglib to make the format more consistent with the other default WLS Console pages. I also cheated a little to make this example simple to follow in that I used the same JSP for my form action as I did to render my form. This can definitely be optimized but it will suffice for the purpose of this example.
1.   Get the current attribute values so you can display the values on the form
2.   Show the form and add a submit button 3.   Process the form values and set the MBean attributes

Get the Attributes
In my JSP, I created a small method that I call to populate a HashMap that I use later on to set the default values for my form (see Listing 4; due to space limitations, Listings 4-6 can be found online at www.syscon.com/weblogic/sourcec.cfm). It's fairly easy to get the MBean and to retrieve the current attribute values.

Set the Attributes
This was as straightforward as getting the attributes. You must still get the MBean object, but now you create a new attribute based on the Attribute Name and the new value entered from the form, and then set the attribute. Listing 5 loops through all of the form elements passed in the POST operation and sets those that match the attribute names we want to set.

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.

In this article I tried to demonstrate how to extend the console for Custom Security Providers by adding new MBean attributes and the code needed to access them. There are two ways to extend the functionality of the console for a custom security provider. You can simply add writeable attributes to the SecurityProvider.xml file and, rebuild the Security Provider jar file and the WebLogic Server Console will attempt to render the screen as a details page. Or, you can write your own Web application with a console extension class and custom JSP files for the console to use.

I want to thank Chris Chiodo of the WebLogic Server OA&M team for finding answers to some obtuse questions I had as I developed these examples.

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.

More Stories By Mike Kennedy

Mike Kennedy
Senior Developer Relations Engineer for BEA
Mike has over 18 years of software development experience. He joined BEA's
Profession Services Team in 1999 doing Oracle and J2EE development prior to
joining the Weblogic Server Support Team in April of 2002.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.

@ThingsExpo Stories
Organizations do not need a Big Data strategy; they need a business strategy that incorporates Big Data. Most organizations lack a road map for using Big Data to optimize key business processes, deliver a differentiated customer experience, or uncover new business opportunities. They do not understand what’s possible with respect to integrating Big Data into the business model.
Enterprises have taken advantage of IoT to achieve important revenue and cost advantages. What is less apparent is how incumbent enterprises operating at scale have, following success with IoT, built analytic, operations management and software development capabilities – ranging from autonomous vehicles to manageable robotics installations. They have embraced these capabilities as if they were Silicon Valley startups. As a result, many firms employ new business models that place enormous impor...
SYS-CON Events announced today that Taica will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Taica manufacturers Alpha-GEL brand silicone components and materials, which maintain outstanding performance over a wide temperature range -40C to +200C. For more information, visit http://www.taica.co.jp/english/.
SYS-CON Events announced today that Dasher Technologies will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Dasher Technologies, Inc. ® is a premier IT solution provider that delivers expert technical resources along with trusted account executives to architect and deliver complete IT solutions and services to help our clients execute their goals, plans and objectives. Since 1999, we'v...
Recently, REAN Cloud built a digital concierge for a North Carolina hospital that had observed that most patient call button questions were repetitive. In addition, the paper-based process used to measure patient health metrics was laborious, not in real-time and sometimes error-prone. In their session at 21st Cloud Expo, Sean Finnerty, Executive Director, Practice Lead, Health Care & Life Science at REAN Cloud, and Dr. S.P.T. Krishnan, Principal Architect at REAN Cloud, will discuss how they b...
SYS-CON Events announced today that MIRAI Inc. will exhibit at the Japan External Trade Organization (JETRO) Pavilion at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. MIRAI Inc. are IT consultants from the public sector whose mission is to solve social issues by technology and innovation and to create a meaningful future for people.
SYS-CON Events announced today that TidalScale, a leading provider of systems and services, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. TidalScale has been involved in shaping the computing landscape. They've designed, developed and deployed some of the most important and successful systems and services in the history of the computing industry - internet, Ethernet, operating s...
SYS-CON Events announced today that IBM has been named “Diamond Sponsor” of SYS-CON's 21st Cloud Expo, which will take place on October 31 through November 2nd 2017 at the Santa Clara Convention Center in Santa Clara, California.
Join IBM November 1 at 21st Cloud Expo at the Santa Clara Convention Center in Santa Clara, CA, and learn how IBM Watson can bring cognitive services and AI to intelligent, unmanned systems. Cognitive analysis impacts today’s systems with unparalleled ability that were previously available only to manned, back-end operations. Thanks to cloud processing, IBM Watson can bring cognitive services and AI to intelligent, unmanned systems. Imagine a robot vacuum that becomes your personal assistant tha...
SYS-CON Events announced today that TidalScale will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. TidalScale is the leading provider of Software-Defined Servers that bring flexibility to modern data centers by right-sizing servers on the fly to fit any data set or workload. TidalScale’s award-winning inverse hypervisor technology combines multiple commodity servers (including their ass...
As hybrid cloud becomes the de-facto standard mode of operation for most enterprises, new challenges arise on how to efficiently and economically share data across environments. In his session at 21st Cloud Expo, Dr. Allon Cohen, VP of Product at Elastifile, will explore new techniques and best practices that help enterprise IT benefit from the advantages of hybrid cloud environments by enabling data availability for both legacy enterprise and cloud-native mission critical applications. By rev...
Infoblox delivers Actionable Network Intelligence to enterprise, government, and service provider customers around the world. They are the industry leader in DNS, DHCP, and IP address management, the category known as DDI. We empower thousands of organizations to control and secure their networks from the core-enabling them to increase efficiency and visibility, improve customer service, and meet compliance requirements.
With major technology companies and startups seriously embracing Cloud strategies, now is the perfect time to attend 21st Cloud Expo October 31 - November 2, 2017, at the Santa Clara Convention Center, CA, and June 12-14, 2018, at the Javits Center in New York City, NY, and learn what is going on, contribute to the discussions, and ensure that your enterprise is on the right path to Digital Transformation.
Amazon is pursuing new markets and disrupting industries at an incredible pace. Almost every industry seems to be in its crosshairs. Companies and industries that once thought they were safe are now worried about being “Amazoned.”. The new watch word should be “Be afraid. Be very afraid.” In his session 21st Cloud Expo, Chris Kocher, a co-founder of Grey Heron, will address questions such as: What new areas is Amazon disrupting? How are they doing this? Where are they likely to go? What are th...
SYS-CON Events announced today that N3N will exhibit at SYS-CON's @ThingsExpo, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. N3N’s solutions increase the effectiveness of operations and control centers, increase the value of IoT investments, and facilitate real-time operational decision making. N3N enables operations teams with a four dimensional digital “big board” that consolidates real-time live video feeds alongside IoT sensor data a...
In his Opening Keynote at 21st Cloud Expo, John Considine, General Manager of IBM Cloud Infrastructure, will lead you through the exciting evolution of the cloud. He'll look at this major disruption from the perspective of technology, business models, and what this means for enterprises of all sizes. John Considine is General Manager of Cloud Infrastructure Services at IBM. In that role he is responsible for leading IBM’s public cloud infrastructure including strategy, development, and offering ...
Digital transformation is changing the face of business. The IDC predicts that enterprises will commit to a massive new scale of digital transformation, to stake out leadership positions in the "digital transformation economy." Accordingly, attendees at the upcoming Cloud Expo | @ThingsExpo at the Santa Clara Convention Center in Santa Clara, CA, Oct 31-Nov 2, will find fresh new content in a new track called Enterprise Cloud & Digital Transformation.
Most technology leaders, contemporary and from the hardware era, are reshaping their businesses to do software. They hope to capture value from emerging technologies such as IoT, SDN, and AI. Ultimately, irrespective of the vertical, it is about deriving value from independent software applications participating in an ecosystem as one comprehensive solution. In his session at @ThingsExpo, Kausik Sridhar, founder and CTO of Pulzze Systems, will discuss how given the magnitude of today's applicati...
SYS-CON Events announced today that NetApp has been named “Bronze Sponsor” of SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. NetApp is the data authority for hybrid cloud. NetApp provides a full range of hybrid cloud data services that simplify management of applications and data across cloud and on-premises environments to accelerate digital transformation. Together with their partners, NetApp emp...
Smart cities have the potential to change our lives at so many levels for citizens: less pollution, reduced parking obstacles, better health, education and more energy savings. Real-time data streaming and the Internet of Things (IoT) possess the power to turn this vision into a reality. However, most organizations today are building their data infrastructure to focus solely on addressing immediate business needs vs. a platform capable of quickly adapting emerging technologies to address future ...