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

Related Topics: Weblogic

Weblogic: Article

JAAS Fundamentals

JAAS Fundamentals

Security is any mechanism that can be used to protect and validate resources. There are many security models that can be used to protect the data. The security model may use encryption, access control, or several other security methods. Authorization, or access control, has different security services that may be used to protect the resources. One method may be the Java Authentication and Authorization Service (JAAS), and another is Windows 2000 Active Directory. This article focuses on the JAAS security service.

Two of the most basic security mechanisms are authentication and authorization. Authentication is simply the identification of an entity. Authorization is the decision process for granting the entity access rights to any data resources or information. The JDK 1.4 comes standard with services that provide both authentication and authorization. These services are called the Java Authentication and Authorization Service (JAAS).

JAAS defines authentication mechanisms through a configuration file; code is not needed to define the mechanism. The authentication mechanism requires parameters in order to identify a user. The parameters used to authenticate a user, such as a name and password for each authentication mechanism, are known as a Principal. A Subject is who I am, but I may use a Principal, my driver's license, to authenticate myself to a cop, and use another Principal, my passport, to authenticate myself to the border patrol. Authorization will only occur after authentication because users must be identified before they are given access to protected resources. The JAAS framework will wrap authentication modules specified by the configuration file. A successful authentication process will return a Subject containing Principals. The Principals returned by the authentication mechanisms will be used for the authorization process.

JAAS will start with a LoginContext class to find the entries in the configuration file that will initialize the appropriate Login-Modules (see Figure 1). The configuration file will contain any initialization parameters that the LoginContext does not specify. The LoginContext will also pass the Login Module a CallbackHandler. The CallbackHandler will call back to the application to request any additional authentication information. For example, if a LoginContext did not specify a username and password through the creation of a CallbackHandler, and the LoginModule requires the information, the LoginModule will use the CallbackHandler to call the LoginContext back to get the information required.

The LoginContext may also pass the Subject to the LoginModule for the Principals to use to log in.

After the initialization of the LoginModule when the LoginContext is created, the LoginContext may call the login( ) method (see Figure 2), which will authenticate the Subject. The login process may go through a daisy chain of LoginModules, each requiring a different type of Principal based on the configuration. The configuration can specify LoginModules that are optional but not required. The LoginModule will complete a two-phase login process. The first phase is when the login( ) method of the LoginModule will get called from the login process. The second phase is when the commit( ), or abort( ), method is called to finish the login process. The commit( ) process is called from the login process when all other LoginModules complete their login( ) method. Then the last LoginModule ( ) will perform its commit, then the next, and so on. The abort method will perform any cleanup if the login( ) method did not complete successfully. If all of the required commit( ) methods completed successfully, then the login process completed successfully.

The authorization process requires the Principals established during the login process, so it is no surprise that the authorization is normally accomplished in the Subject class. The Subject class performs authorization using a PrivilegedAction class. An extended PrivilegedAction class wraps the resources that are to have the access control. Whether or not the Principal has permission to access a resource is defined in a security policy file. The Java security manager will read the appropriate security policy file and parse the permissions and Principals. The security manager will then grant or deny the resources in the Privileged Action based on these permissions and principals. If the permission for the resource is not allowed for a specific Principal, then an access exception is thrown.

Using JAAS with WebLogic
WebLogic Application Server (WLS) 7.0 does not redefine or change JAAS. JAAS remains the same regardless, but it is an extensible framework. WLS 7.0 includes its own authentication and authorization mechanisms that do not require a policy file. The configuration file will define the WLS LoginModule to be used to wrap the WLS authentication mechanism. The WLS LoginModule normally requires a username, password, and URL to point to the appropriate WLS server. WLS 7.0 also contains an authorization mechanism from mapping resources to roles. Because WLS 7.0 has an authorization mechanism implemented in the WebLogic security framework, policy files and the Java security manager do not have to be defined. A weblogic.security.Security class is required when using calling the Privileged Action.

WebLogic 7.0 comes with an example of how to perform JAAS-based authentication and authorization from a Java client application to make calls to an EJB that has access restrictions enabled on its methods. The example is a slight modification of the Sun example found at http://java.sun.com/j2se/1.4/docs/guide/security/ jaas/JAASRefGuide.html#Sample.

This example includes a JAAS configuration file, which specifies the class name of the LoginModule used to perform authentication of the EJB client; a CallbackHandler used to gather the client credentials and the URL of the authentication server; a PrivilegedAction, which contains the code that performs the EJB access; and a client application that creates a LoginContext, calls the login method, and invokes the PrivilegedAction through the weblogic.security.Security.runAs method. The flow of this example application is diagrammed in Figure 3. You can refer to the full example by looking in $WL_HOME/weblogic700/samples/server/src/ examples/security/jaas. The remainder of this article will refer to this example to discuss JAAS-based authentication and authorization in WLS from remote clients and to compare that with server-side components such as servlets.

Java Client Authentication
Authentication of a stand-alone Java client is used by client applications that need to directly access EJBs or JMS Destinations located on a WebLogic Server. The client-side example, supplied by BEA with the WLS 7.0 release, uses a JAAS policy file, sample_jaas.config, to specify a single LoginModule, weblogic.security.auth.login.UsernamePasswordLoginModule, to the application. Here are the contents of this file:

Sample {
required debug=false;

The code for the UsernamePasswordLoginModule is not included in the example package, but the class file is located in weblogic.jar. Details of the code can be found at http://edocs.bea.com/wls/ docs70/security/intro.html#1047392 .

It uses the weblogic.security.auth.Authenticate class, a WebLogic-specific class, to perform the actual authentication to a WebLogic server instance that is specified to the LoginModule through a URLCallback. The application's CallbackHandler supplies the URL of the server that will perform the authentication through the server's configured Authentication Provider.

The LoginModule passes a NameCallback and a PasswordCallback to the CallbackHandler to acquire the username and password of the client initiating the application. Once the user is authenticated, the LoginModule populates the Subject passed to it by the LoginContext. The application then retrieves the authenticated Subject using the LoginContext.getSubject method. The Subject holds the WebLogic Principals - which can be a WLSUser or WLSGroup - which will be used for authorization when the Subject is passed to the Security.runAs method. The entire JAAS authentication sequence is initiated by the application when it instantiates a LoginContext and calls the LoginContext.login() method. The LoginContext locates a Configuration object that loads the configuration information found in the JAAS policy file. It uses the Configuration to create an instance of the LoginModule that will be used for the authentication sequence.

// Create LoginContext; specify username/password login module
loginContext = new LoginContext
("Sample", new SampleCallbackHandler(username, password, url));

This instantiation of the LoginContext will locate and instantiate a LoginModule found in the Configuration, using the name "Sample" to locate the LoginModule in the Configuration, and pass the SampleCallbackHandler to its initialize method. From the entry in the sample_jaas.config file, you can see that the LoginContext will instantiate an instance of UsernamePasswordLoginModule to perform the authentication.

The WebLogic documentation states that the use of the weblogic.jndi.Environment class is deprecated in the WLS 7.0 release. However, the LoginModule supplied with the example uses the weblogic.jndi.Environment object to perform the authentication by passing the Environment, which contains the username, password, and URL of the server, to the Authenticate.authenticate method. This apparent contradiction is a good opportunity to plug the advantages of the pluggable nature of the LoginModule. The mechanism of the example LoginModule, the use of the Authenticate class, is not visible to the client application attempting to authenticate itself to the WebLogic server. Since the LoginModule is an instance of a Pluggable Authentication Module (PAM), it can be replaced or rewritten without affecting the client application. This is a good example of how the pluggable nature of a LoginModule prevents the development of brittle application code.

The Authenticate.authenticate method makes a connection to the WebLogic server specified in the URL and passes the Subject and the Environment, which holds the credentials, to the server to be authenticated by the Authentication provider configured for the WebLogic Security Realm of the server. The Authentication provider configured in the server's security realm also implements a LoginModule. The implementation of the Authentication provider can perform the authentication using any number of technologies, such as LDAP or a relational database. If the authentication succeeds, the Authentication provider adds the authenticated Principal(s) to the Subject. Before it adds the Principal to the Subject it makes a request to the Principal Validator to digitally sign the Principal. This prevents potentially malicious clients from tampering with the Principal embedded in the returned Subject in an attempt to circumvent authorization checks when the Subject is returned via a Security.runAs call. The Principal Validator is consulted during authorization to ensure that the returned Subject is the same one that was digitally signed during authentication.

Browser-Based Authentication
Many, if not most, WebLogic-based applications are accessed through browser-based clients. These applications are generally composed of servlets, JSPs, and EJBs. Authentication to these applications is specified as BASIC or FORM in the element of the web.xml deployment descriptor of the Web application that will present the initial access page of the application. For example:


When one of these methods is used to authenticate a Web client, the Web container calls to the WebLogic Security Framework, on behalf of the client, to access the Authentication provider. This mechanism results in the creation of a JAAS Subject, which contains an authenticated Principal, that is stored within an internal session object. Subsequent requests from the client are authorized by locating the Subject in the internal session using the session id passed in a cookie in the HttpRequest. The point here is that resource containers on WebLogic, such as the Web container, use JAAS-based authentication as well by calling the Authentication provider on behalf of the Web client to get a Subject populated with an authenticated Principal. The LoginModule used by the Authentication provider is not configured in a JAAS configuration file as it is in the Java client example. The Authentication provider is configured by adding it to the active Security Realm through the administration console. The default Authentication provider and LoginModule configured for WLS 7.0, out-of-the-box, use an embedded LDAP server. The server-side LoginModule that authenticates the Web-based client is the same LoginModule that is used to authenticate a Java client application when the client-side UsernamePasswordLoginModule calls the Authenticate.authenticate method passing the Subject and Environment objects. The Subject is not passed back to the Web client, but rather is kept by the Web container in an internal session object and is later referenced by the session id.

JAAS-Based Authorization
While authorization in WLS does not use the JAAS Subject.doAs method, it is JAAS Subject based. Applications that require access to protected WebLogic resources request access to them through the weblogic.security.Security.runAs method. A Subject and PrivilegedAction are passed to this WLS Security Framework method to perform a task involving a WebLogic resource.

WebLogic Resources
Unlike Java system resources that are protected through security policies found in the Java security policy file, WebLogic resources are protected by WebLogic security policies that are specified by the association of a WebLogic role with a WebLogic resource. A WebLogic resource is defined as a structured object that represents a server-side entity that can be protected from unauthorized access. Examples of WebLogic resources are EJB methods, servlets, and JMS Destinations. See the WebLogic 7.0 documentation at http://edocs.bea.com/wls/docs70/ dvspisec/atz.html#1134702 for examples of the types of WebLogic resources that can be protected using WebLogic roles.

WebLogic Roles
WebLogic roles, found in WLS 7.0, are used to replace ACL-based authorization found in previous releases of WebLogic. A role is defined by the WLS documentation as an abstract, logical collection of users similar to a group. Roles are different from groups because they are dynamically updated based on username, group membership, and time of day. Roles are used with resources to create WebLogic security policies. JAAS-based security policies are defined in the Java security policy file by granting Permissions to codebases, signers, and Principals. Associating a WebLogic role with a WebLogic resource creates a WebLogic security policy. WebLogic does not consult a Java policy file to apply security policies. A user who is in the role defined by a security policy for a resource at the time an access decision for the resource is made is allowed to access the resource.

WebLogic roles can be global, which associates them with all WebLogic resources, or scoped, which associates them with a specific WebLogic resource. Global roles are declared using the administrative console. Security policies are created dynamically, using scoped roles, for Web applications and EJBs through the use of deployment descriptors. These roles are declared and associated with the resource in the web.xml file for Web application components and in the ejb-jar.xml file for EJBs using the <security-role> element. The declared roles are granted to Principals through the vendor-specific deployment descriptors, weblogic.xml, and weblogic-ejb-jar.xml respectively, using the <security-role-assignment> element. Dynamic roles may be configured in the console too, but the deployment descriptors of the components are not updated with the console modifications. The Role Mapper does the work of associating the roles granted to the principals at deployment time.

WebLogic Authorization
Authorization of the Java client application is initiated when the application attempts to execute a PrivilegedAction through the Security.runAs method (see Figure 4). The application passes the authenticated Subject and the PrivilegedAction to the WebLogic security framework when it calls this method. In the WLS example, an EJB method is invoked from a PrivilegedAction, SampleAction.java, using the authenticated Subject as the identity of the caller. The EJB container on the server receives the request from the client-side EJB stub in the context of the PrivilegedAction, which propagates the authenticated Subject to the EJB container with the method invocation. The EJB container calls to the Security Framework on the server to determine if the Subject is allowed to access the EJB method. This activates the Authorization provider and the Role Mapper to make a decision regarding the Subject's access to the EJB method being called. The Role Mapper determines what Roles are held by the Principals in the Subject. The Authorization provider determines if the Roles held by the Principals allow access to the method. If access is allowed, the container proceeds with the method invocation. It should be noted that before the authorization process begins, the Principal Validator validates that the Principals in the passed Subject have not been tampered with since authentication.

Browser-based clients are authorized by the same mechanism on the server. The difference is that the Subject is kept on the server by the Web container rather than being passed from the client application. The browser sends the session id in a cookie and the Web container locates the subject in an internal session before calling to the security framework to perform authorization.

The JAAS mechanisms of authentication and authorization, defined by the JAAS specification and implemented in JDK 1.4, use the Java SecurityManager, the AccessController, LoginModules, and Subjects to perform authentication and authorization checks. These mechanisms, used to protect system resources and properties, are configured using the Java security and policy files. WebLogic uses JAAS LoginModules and Subjects to perform authentication and authorization; however, the Configuration is not specified with, or retrieved from, the Java security and policy files.

Security providers that are configured through the WebLogic console implement the roles of the Java SecurityManager and AccessController in a WebLogic server. These security providers control access to WebLogic resources using security policies that are defined by the association WebLogic roles and WebLogic resources. Roles may be configured through the console or through deployment descriptors. A WebLogic authentication provider uses LoginModules and Subjects to establish the identity of a user. An authenticated Subject is used by a WebLogic Authorization provider to grant or deny access to WebLogic resources based on the security policies defined for those resources and the roles held by the Principals in the authenticated Subject.

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
SYS-CON Events announced today that Evatronix 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. Evatronix SA offers comprehensive solutions in the design and implementation of electronic systems, in CAD / CAM deployment, and also is a designer and manufacturer of advanced 3D scanners for professional applications.
SYS-CON Events announced today that Synametrics Technologies will exhibit at SYS-CON's 22nd International Cloud Expo®, which will take place on June 5-7, 2018, at the Javits Center in New York, NY. Synametrics Technologies is a privately held company based in Plainsboro, New Jersey that has been providing solutions for the developer community since 1997. Based on the success of its initial product offerings such as WinSQL, Xeams, SynaMan and Syncrify, Synametrics continues to create and hone inn...
Cloud Expo | DXWorld Expo have announced the conference tracks for Cloud Expo 2018. Cloud Expo will be held June 5-7, 2018, at the Javits Center in New York City, and November 6-8, 2018, at the Santa Clara Convention Center, Santa Clara, CA. Digital Transformation (DX) is a major focus with the introduction of DX Expo within the program. Successful transformation requires a laser focus on being data-driven and on using all the tools available that enable transformation if they plan to survive ov...
A strange thing is happening along the way to the Internet of Things, namely far too many devices to work with and manage. It has become clear that we'll need much higher efficiency user experiences that can allow us to more easily and scalably work with the thousands of devices that will soon be in each of our lives. Enter the conversational interface revolution, combining bots we can literally talk with, gesture to, and even direct with our thoughts, with embedded artificial intelligence, whic...
To get the most out of their data, successful companies are not focusing on queries and data lakes, they are actively integrating analytics into their operations with a data-first application development approach. Real-time adjustments to improve revenues, reduce costs, or mitigate risk rely on applications that minimize latency on a variety of data sources. In his session at @BigDataExpo, Jack Norris, Senior Vice President, Data and Applications at MapR Technologies, reviewed best practices to ...
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 ...
With tough new regulations coming to Europe on data privacy in May 2018, Calligo will explain why in reality the effect is global and transforms how you consider critical data. EU GDPR fundamentally rewrites the rules for cloud, Big Data and IoT. In his session at 21st Cloud Expo, Adam Ryan, Vice President and General Manager EMEA at Calligo, examined the regulations and provided insight on how it affects technology, challenges the established rules and will usher in new levels of diligence arou...
In his session at 21st Cloud Expo, Raju Shreewastava, founder of Big Data Trunk, provided a fun and simple way to introduce Machine Leaning to anyone and everyone. He solved a machine learning problem and demonstrated an easy way to be able to do machine learning without even coding. Raju Shreewastava is the founder of Big Data Trunk (www.BigDataTrunk.com), a Big Data Training and consulting firm with offices in the United States. He previously led the data warehouse/business intelligence and B...
"Digital transformation - what we knew about it in the past has been redefined. Automation is going to play such a huge role in that because the culture, the technology, and the business operations are being shifted now," stated Brian Boeggeman, VP of Alliances & Partnerships at Ayehu, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
"Evatronix provides design services to companies that need to integrate the IoT technology in their products but they don't necessarily have the expertise, knowledge and design team to do so," explained Adam Morawiec, VP of Business Development at Evatronix, in this SYS-CON.tv interview at @ThingsExpo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
The 22nd International Cloud Expo | 1st DXWorld Expo has announced that its Call for Papers is open. Cloud Expo | DXWorld Expo, to be held June 5-7, 2018, at the Javits Center in New York, NY, brings together Cloud Computing, Digital Transformation, Big Data, Internet of Things, DevOps, Machine Learning and WebRTC to one location. With cloud computing driving a higher percentage of enterprise IT budgets every year, it becomes increasingly important to plant your flag in this fast-expanding busin...
In his Opening Keynote at 21st Cloud Expo, John Considine, General Manager of IBM Cloud Infrastructure, led attendees through the exciting evolution of the cloud. He looked 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 m...
Nordstrom is transforming the way that they do business and the cloud is the key to enabling speed and hyper personalized customer experiences. In his session at 21st Cloud Expo, Ken Schow, VP of Engineering at Nordstrom, discussed some of the key learnings and common pitfalls of large enterprises moving to the cloud. This includes strategies around choosing a cloud provider(s), architecture, and lessons learned. In addition, he covered some of the best practices for structured team migration an...
No hype cycles or predictions of a gazillion things here. IoT is here. You get it. You know your business and have great ideas for a business transformation strategy. What comes next? Time to make it happen. In his session at @ThingsExpo, Jay Mason, an Associate Partner of Analytics, IoT & Cybersecurity at M&S Consulting, presented a step-by-step plan to develop your technology implementation strategy. He also discussed the evaluation of communication standards and IoT messaging protocols, data...
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, discussed how they built...
22nd International Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, and co-located with the 1st DXWorld Expo will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud ...
22nd International Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, and co-located with the 1st DXWorld Expo will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud ...
DevOps at Cloud Expo – being held June 5-7, 2018, at the Javits Center in New York, NY – announces that its Call for Papers is open. Born out of proven success in agile development, cloud computing, and process automation, DevOps is a macro trend you cannot afford to miss. From showcase success stories from early adopters and web-scale businesses, DevOps is expanding to organizations of all sizes, including the world's largest enterprises – and delivering real results. Among the proven benefits,...
@DevOpsSummit at Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, is co-located with 22nd Cloud Expo | 1st DXWorld Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The widespread success of cloud computing is driving the DevOps revolution in enterprise IT. Now as never before, development teams must communicate and collaborate in a dynamic, 24/7/365 environment. There is no time to wait...
SYS-CON Events announced today that T-Mobile exhibited at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. As America's Un-carrier, T-Mobile US, Inc., is redefining the way consumers and businesses buy wireless services through leading product and service innovation. The Company's advanced nationwide 4G LTE network delivers outstanding wireless experiences to 67.4 million customers who are unwilling to compromise on qua...