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
BnkToTheFuture.com is the largest online investment platform for investing in FinTech, Bitcoin and Blockchain companies. We believe the future of finance looks very different from the past and we aim to invest and provide trading opportunities for qualifying investors that want to build a portfolio in the sector in compliance with international financial regulations.
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...
Imagine if you will, a retail floor so densely packed with sensors that they can pick up the movements of insects scurrying across a store aisle. Or a component of a piece of factory equipment so well-instrumented that its digital twin provides resolution down to the micrometer.
In his keynote at 18th Cloud Expo, Andrew Keys, Co-Founder of ConsenSys Enterprise, provided an overview of the evolution of the Internet and the Database and the future of their combination – the Blockchain. Andrew Keys is Co-Founder of ConsenSys Enterprise. He comes to ConsenSys Enterprise with capital markets, technology and entrepreneurial experience. Previously, he worked for UBS investment bank in equities analysis. Later, he was responsible for the creation and distribution of life settle...
Product connectivity goes hand and hand these days with increased use of personal data. New IoT devices are becoming more personalized than ever before. In his session at 22nd Cloud Expo | DXWorld Expo, Nicolas Fierro, CEO of MIMIR Blockchain Solutions, will discuss how in order to protect your data and privacy, IoT applications need to embrace Blockchain technology for a new level of product security never before seen - or needed.
Leading companies, from the Global Fortune 500 to the smallest companies, are adopting hybrid cloud as the path to business advantage. Hybrid cloud depends on cloud services and on-premises infrastructure working in unison. Successful implementations require new levels of data mobility, enabled by an automated and seamless flow across on-premises and cloud resources. In his general session at 21st Cloud Expo, Greg Tevis, an IBM Storage Software Technical Strategist and Customer Solution Architec...
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...
Coca-Cola’s Google powered digital signage system lays the groundwork for a more valuable connection between Coke and its customers. Digital signs pair software with high-resolution displays so that a message can be changed instantly based on what the operator wants to communicate or sell. In their Day 3 Keynote at 21st Cloud Expo, Greg Chambers, Global Group Director, Digital Innovation, Coca-Cola, and Vidya Nagarajan, a Senior Product Manager at Google, discussed how from store operations and ...
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...
"IBM is really all in on blockchain. We take a look at sort of the history of blockchain ledger technologies. It started out with bitcoin, Ethereum, and IBM evaluated these particular blockchain technologies and found they were anonymous and permissionless and that many companies were looking for permissioned blockchain," stated René Bostic, Technical VP of the IBM Cloud Unit in North America, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Conventi...
When shopping for a new data processing platform for IoT solutions, many development teams want to be able to test-drive options before making a choice. Yet when evaluating an IoT solution, it’s simply not feasible to do so at scale with physical devices. Building a sensor simulator is the next best choice; however, generating a realistic simulation at very high TPS with ease of configurability is a formidable challenge. When dealing with multiple application or transport protocols, you would be...
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 ...
We are given a desktop platform with Java 8 or Java 9 installed and seek to find a way to deploy high-performance Java applications that use Java 3D and/or Jogl without having to run an installer. We are subject to the constraint that the applications be signed and deployed so that they can be run in a trusted environment (i.e., outside of the sandbox). Further, we seek to do this in a way that does not depend on bundling a JRE with our applications, as this makes downloads and installations rat...
Widespread fragmentation is stalling the growth of the IIoT and making it difficult for partners to work together. The number of software platforms, apps, hardware and connectivity standards is creating paralysis among businesses that are afraid of being locked into a solution. EdgeX Foundry is unifying the community around a common IoT edge framework and an ecosystem of interoperable components.
DX World EXPO, LLC, a Lighthouse Point, Florida-based startup trade show producer and the creator of "DXWorldEXPO® - Digital Transformation Conference & Expo" has announced its executive management team. The team is headed by Levent Selamoglu, who has been named CEO. "Now is the time for a truly global DX event, to bring together the leading minds from the technology world in a conversation about Digital Transformation," he said in making the announcement.
In this strange new world where more and more power is drawn from business technology, companies are effectively straddling two paths on the road to innovation and transformation into digital enterprises. The first path is the heritage trail – with “legacy” technology forming the background. Here, extant technologies are transformed by core IT teams to provide more API-driven approaches. Legacy systems can restrict companies that are transitioning into digital enterprises. To truly become a lead...
Digital Transformation (DX) is not a "one-size-fits all" strategy. Each organization needs to develop its own unique, long-term DX plan. It must do so by realizing that we now live in a data-driven age, and that technologies such as Cloud Computing, Big Data, the IoT, Cognitive Computing, and Blockchain are only tools. In her general session at 21st Cloud Expo, Rebecca Wanta explained how the strategy must focus on DX and include a commitment from top management to create great IT jobs, monitor ...
"Cloud Academy is an enterprise training platform for the cloud, specifically public clouds. We offer guided learning experiences on AWS, Azure, Google Cloud and all the surrounding methodologies and technologies that you need to know and your teams need to know in order to leverage the full benefits of the cloud," explained Alex Brower, VP of Marketing at Cloud Academy, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clar...
The IoT Will Grow: In what might be the most obvious prediction of the decade, the IoT will continue to expand next year, with more and more devices coming online every single day. What isn’t so obvious about this prediction: where that growth will occur. The retail, healthcare, and industrial/supply chain industries will likely see the greatest growth. Forrester Research has predicted the IoT will become “the backbone” of customer value as it continues to grow. It is no surprise that retail is ...