Monday, February 22, 2016

Using JavaScript in ADF - Part I

I would like share my experience on using Javascript in ADF. I have seen many times developer makes some common mistake while using Javascript with ADF without properly understanding it. At the time of development, may be all look good in terms of functionality but sometimes it introduces performance and maintenance issues. ADF Faces is an Ajax-enabled rich JavaServer Faces component framework that uses JavaScript to render client-side components, implement rich component functionality, validate user input and convert user data input. ADF exposes public javascript APIs which developer can use instead of directly doing DOM manipulation. DOM manipulation is something which developer should not start with before looking all other options provided by ADF public Javascript APIs.

In ADF, The majority of the UI components are rendered in HTML, that is generated on the server side for the request.  Every ADF UI component is represented by two types of javascript classes - a public component object and an internal peer object. The public objects is used by the developers when programming on the ADF Faces client side. Peer objects help in rendering logic and hide the browser specific DOM implementation code. For every ADF UI component object, there will be the corresponding object in server. But, it's not necessary always to have a ADF javascript object on the client side, we will go in detail on this later.

JS is all about functions and objects. Even functions are objects in JS and you can assign properties to the functions as you do for objects. JS has first-class functions meaning it supports passing functions as arguments to other functions, returning them as the values from other functions, and assigning them to variables. JS supports prototypal inheritance which is different than classical inheritance. Each ADF UI component has a corresponding JS object  and has a root object as AdfObject. Each ADF UI JS object follow the name convention and prefix by "Adf" and the corresponding server component doesn't have the prefix. For Ex: AdfRichPopup

Client Side JS Object Heirarchy


Server Side Java Class Heirarchy



Public methods that are exposed by the component JS object can be used to manipulate the component properties and do operations. For most of the action listeners and events both server side and client side operations exists but it may not be the case everytime. For Ex: To show, hide and cancel a popup both server and client side operation exist. The popupOpening is a client only event that can be canceled. If this event is canceled in a client-side listener, the popup will not be shown. The PopupFetchEvent is one of two server-side popup events but doesn't have a corresponding client event. The custom client event listeners can invoke JavaScript that raises a CustomEvent that is handled by a af:serverListener. See the Javadocs - http://docs.oracle.com/cd/E21764_01/apirefs.1111/e10684/oracle/adf/view/rich/component/rich/RichPopup.html for details.

Enough theory, let's see some examples where we can apply these concepts -  

1. Never use ADF Internal JavaScript objects 
JS doesn't have any package structures like Java classes. Based on the hierarchical object  structure it create package like structure to access the object. ADF Faces  make these things simple by applying the naming conventions and make it look like Java so it's easy to understand. In ADF Faces, two package structures are used: oracle.adf.view.js and oracle.adfinternal.view.js. The oracle.adfinternal.view.js package contains those JavaScript objects that should only be used internally by the ADF Faces component framework. I have seen many times developers using internal packages and then blaming the framework later when it doesn't work when you migrate to new releases or if some patches applied. Changes to internal packages are applied without any notice.

For Ex: AdfPanelStretchLayout




Internal JS Object


 
 2. Finding ADF Component on the Client 

I have seen many times developers using JQuery/JS to find the ADF component by id in the DOM by looking at the generated HTML For Ex: document.getElementById("itemId"). This is not the correct approach because the HTML generated may change based on the ADF UI component implementation.

As I mentioned before, the component hierarchy on the server is same as the hierarchy of ADF Faces components on the client. But, it's not necessary to have the client object for every ADF Faces component but will have the server side generated html. To make sure, client object exist there are two ways to do that -

  • By setting clientComponent=true property on UI Component declaratively using property inspector
  • If the UI component has af:clientListener attached to it then automatically it client object is generated

After making sure ADF client object exist, move on to find the component by Id using ADF Javascript objects. AdfPage.PAGE object exposes three methods to find the component -
  • findComponent
  • findComponentByAbsoluteId
  • findComponentByAbsoluteLocator
Check this blog for details on finding component by Id - https://blogs.oracle.com/groundside/entry/pattern_for_obtaining_adf_component

Reference - http://www.oracle.com/technetwork/developer-tools/jdev/1-2011-javascript-302460.pdf


Wednesday, January 20, 2016

SSO : IBM Tivoli Access Manager(TAM) and Weblogic Server

This post is about configuring Weblogic server to assert the authentication information sent by IBM Security Access Manager(TAM) in HTTP Header. TAM is equivalent of OAM(Oracle Access Manager).
Configuration is the two step process as any other SSO solution -

1. Configure the Asserter that asserts the HTTP header token populated by the access manager
2. Configure the Authenticator that establishes the authenticated Subject in the container. Also, populate the prinicipals/groups for the authenticated Subject.

TAM can be configured to send authentication information to WLS in an HTTP header. TAM can populate two types of encrypted tokens in HTTP header -

iv-user - Contains only the authenticated userID
iv-creds - Contains the authenticated userID and the associated groups

IBM provides a Security Provider jar which includes both Identity Asserter and Authenticator to read the encrypted tokens and assert the user. Download the jar from link. This jar needs to copied to <WL_SERVER_HOME>/server/lib/mbeantypes. For more details on configuring security provider refer Oracle Document.

Configuring TAMIdentityAsserter and selecting iv-user token.
























List and order of configured Security providers -

Thursday, June 11, 2015

SSL Hostname verification in Weblogic Server

While accessing any webservice on SSL, if you get the below error in the logs - 

<Notice> <StdErr> <BEA-000000> <javax.xml.ws.WebServiceException: Failed to access the WSDL at: https://<Host-Name>:<Port>/<Webservice Endpoint>?wsdl. It failed with: [Security:090504]Certificate chain received from <Host-Name>.<Domain-Name> failed hostname verification check. Certificate contained *.<Domain Name> but check expected  <Host-Name>.<Domain-Name>


To Resolve this follow the below steps to disable the host name verification in WLS –

  1. If you have not already done so, in the Change Center of the Administration Console, click Lock & Edit (see Use the Change Center).
  2. In the left pane of the Console, expand Environment and select Servers.
  3. Click the name of the server for which you want to disable host name verification.
  4. Select Configuration > SSL , and click Advanced at the bottom of the page.
  5. Set the Hostname Verification field to None.
  6. Click Save.
  7. To activate these changes, in the Change Center of the Administration Console, click Activate Changes.
    Not all changes take effect immediately—some require a restart (see Use the Change Center).
Note: This is not recommended for Production Environment.

Saturday, February 28, 2015

Passed Oracle Mobile Security Suite 11g Essentials Exam

I am glad to share that I passed the Oracle Mobile Security Suite(OMSS) 11g Essentials Exam. OMSS leverages the technology acquired from the acquisition of Bitzer Mobile. It's a new Mobile Application Management(MAM) solution that comes with many cool features like App Containerization and simplify enterprise mobility. This is going to address BYOD(Bring your own device) initiative that many corporate started following and many more to join.



When I started preparing for exam, I didn't find much documentation other than the Oracle documents. To pass in the exam, just going through the Oracle documentation is enough. Most of the questions are straight forward and directly from the documents. Unlike Oracle other exams, none of the questions asked based on real implementation experience.

Some Useful Links -

OMSS Documentation - http://docs.oracle.com/cd/E52357_01/index.htm
Oracle Webcast - http://medianetwork.oracle.com/video/player/3442504861001
Blogs - http://ptotech.blogspot.com/2014/05/oracle-mobile-and-security-suite-omss.html

Sunday, February 8, 2015

Weblogic Security Exception : Invalid Subject Principals

If you are seeing "Caused by: java.lang.SecurityException: [Security:090398]Invalid Subject: principals" error in weblogic server logs on RMI invocation of EJB(deployed on different Weblogic domain), this means the issue is in domain trust security settings.

Stack trace


Caused by: java.lang.SecurityException: [Security:090398]Invalid Subject: principals
at weblogic.security.service.SecurityServiceManager.seal(SecurityServiceManager.java:833)
at weblogic.security.service.SecurityServiceManager.getSealedSubjectFromWire(SecurityServiceManager.java:522)
at weblogic.rjvm.MsgAbbrevInputStream.getSubject(MsgAbbrevInputStream.java:352)
at weblogic.rmi.internal.BasicServerRef.acceptRequest(BasicServerRef.java:953)
at weblogic.rmi.internal.BasicServerRef.dispatch(BasicServerRef.java:351)

To solve the above issues, enable trust between multiple Weblogic Server Domains and specify same credential in both the weblogic server domains. It can be fixed by -

  • Enabling Cross Domain Security between Weblogic Server Domains
  • Enabling Global Trust

I fixed it by enabling global trust between the weblogic server domains. By default, domain credentials are randomly generated and no two domains will have the same Domain credential. So, replace the generated credential and specify the same domain credential for each of the domains. In this way, identity is passed between WLS domains over an RMI connection without requiring authentication in the second domain.

Note: Don't confuse Domain credential with the credential for login to WLS console


Configuration Steps 


1. Log in to WLS console and click on Lock and Edit (top left pane)



2. In the left pane click on Domain name.



3. Select Security > General on the center pane. Click Advanced link.



4. Enter password in Credential and Confirm Credential fields.



5. Click on Activate Changes in the top left pane.

Wednesday, December 3, 2014

Webgate Installation on Solaris 10 Sparc 64 bit machine

Environment Details

OHS/Webgate (11.1.1.5)
Solaris 10 Sparc 64 bit

OHS/Webgate 11.1.1.5) requires the compiler package gcc 3.3.2 version. This has been clearly stated in Oracle Documentation http://docs.oracle.com/cd/E21764_01/install.1111/e12002/webgate.htm#INOIM75766. By default, Solaris 10 comes with the gcc 3.4.3 libraries. I checked with product development folks and they told me that there was a design decision to change over the compilation from gcc compiler to the native solaris compiler from 11.1.1.7 and  hence the OHS / Webgate product support for other newer versions of gcc are not there and I guess they found some issues with gcc 3.4.3+.

For details check the Oracle Support Document 1460975.1 (Where are the Gcc 3.3.2 64bits Libraries Required by the OAM11g WebGate on Solaris 10 Sparc 64-bit) can be found at: https://support.oracle.com/epmos/faces/DocumentDisplay?id=1460975.1.

libgcc 3.3 package includes both 32 and 64 bit versions of the library files. Unzip and install the libgcc 3.3 package, by default this will install to /usr/local/lib.  Use the files in the /usr/local/lib/sparcv9/ directory as these are the 64 bit versions. The versions installed to /usr/local/lib/ are 32 bit versions.
If the correct version is not used, you will see the below error during installation -
ld.so.1: configureWebGate: fatal: 
/<WG install directory>/access/oblix/tools/configureWebGate/../../../oblix/lib/libstdc++.so.5: 
wrong ELF class: ELFCLASS32





Monday, November 10, 2014

X11 forwarding

This blog is about X11 forwarding. This comes in handy when you want to see the graphical interfaces of X11 programs running on a remote Linux server to be displayed on a local client machine. I am not an Linux expert so it took some time for me to set this up, so I thought of writing it in blog for future references.

Need ?

I came across the need to do X11 forwarding for one of my project. I had a remote access to the linux server and my task was to install one of the Oracle FMW product. During installation, graphical wizards comes for the configuration settings and this is the place where you require X11 forwarding.
When you connect to linux server via SSH and try to run the graphical applications you will get the error - Can't open display. Basically when you SSH in and run a graphical application, it has no location in which to draw the window. To put it another way, there is no display associated with that connection.In order to get the instructions on how to draw the window sent back over the network to our computer the SSH client needs to be configured to request them.

How to solve the problem ?

Problem can be fixed by following 2 steps -
1. Requesting the remote linux server to forward X connections - Configure the SSH client to send the instructions to draw the GUI sent over the network to the client machine.

2. Running an X server on the client machine to listen for the connections - The role of the X server is to make sense of the instructions coming from remote Linux server and translate them into commands that can be drawn by Windows.

Prerequisites 

  • Install putty and configure for SSH.
  • Install Xming server on your Windows PC. You can download it from Sourceforge link.

Configuration Steps

1 Set X11 forwarding in your putty session



2. SSH to the remote Linux server and follow the below steps.

i) Before issuing the su or sudo, request the cookie for the current DISPLAY to connect to your Xming server

$xauth list
host/domain:10 MIT-MAGIC-COOKIE-1 HEX-KEY

For Ex:
$ xauth list
atloraman/unix:10  MIT-MAGIC-COOKIE-1  926b224b5afc20f8db4bf06c0ef6a6c8


Note: Above output will be different for every session

ii) Switch to atladmin or oracle account
    $ su - atladmin

   Export your DISPLAY variable
  $ export DISPLAY=localhost:10.0

iii) Add the output string from the xauth list command above:

$ xauth add displayname protocolname hexkey

For Ex:
$ xauth add atloraman/unix:10  MIT-MAGIC-COOKIE-1  926b224b5afc20f8db4bf06c0ef6a6c8

Run xclock to verify your X11 session is working





iv) When you don't need the access, execute the below command -
xauth remove $DISPLAY