Monday, April 8, 2013

ADF Password management with WebLogic

Many times we have needed to include password management for our customers which for a portal is generally viewed as "standard functionality". This usually includes... forgot my password, reset my password and hey, register me, I want to be a new user.

Of course, just for fun, this functionality is not "standard" or even provided for WebCenter Portal projects or for ADF custom applications, so we generally have to build the functionality from scratch for the customer. Well not from scratch all the time, as if you follow this post, you will be able to create reusable (configurable) password management components for your next application.

So for now, this post will lead you through the wiring of ADF and the OOTB WebLogic LDAP credential store together. For production or semi-serious deployments you would not use the WebLogic defaultAuthenticator from myRealm, instead sensibly wiring up your corporate LDAP (AD, OID, whatever) to WebLogic.

So lets get started, and thanks must also go to Aaron Rapp for his Java super class code. You will need to go grab that before you start this tutorial. http://adf-lessons-learnt.blogspot.com.au/

1. Create a new ADF application


2. Create a new Java Class from the View Controller



3. Name the new class, leave all other options as is.




4. Paste in Aarons code after the super class closing } from http://adf-lessons-learnt.blogspot.com.au/

Use ctl-enter to resolve any dependencies (which adds items to the import list)


 5. Create the datacontrol from the java bean


6. Create a new ADF task flow for each password activity; change password, reset password and register new user.


7. Name it

8. Add a view to the page and name it

9.Double click to create a JSFF, name it etc. Then drag and drop the data control item onto the jsff. Create an ADF Parameter form.


10. Edit the form fields labels as shown, or type what you want.



11. Your form should look like this.


12. We need to add security now. Right click on the JSFF and add view level security to the application roles.


13. Save everything

Now we need to deploy the ADF application as an ADF Jar file for inclusion by other ADF or WebCenter application.

Create an ADF Jar by selecting the project Properties > deployment, and then create a new deployment profile. Make sure it is of type: ADF library JAR file


14. Select ViewController > Deploy to deploy as the ADF Jar file



15. Create or open your target application.
Create a new File System Connection to a shared folder where you copied the deployed ADF JAR file to.



16. Create a new ADF Libs folder. Project properties > Libraries & Classpath > Add Library > New



17. Give it a name eg ADF_Libs and add the shared libs dir from before. You may want to select the "deployed by default" checkbox, as this will package the ADF JAR in with your parent project and deploy them as a single item to WebLogic. leave them unchecked if you use a separate runtime library reference



18. Create a new parent page. eg changePassword.jspx
Open up the file system connect so you can see your task flows



19. Drag and drop one onto the page. Select region as the drop type. Choose to add the library to the project.



20. Add security to your page and remember to add it to your taskflow. You need to make sure your resource Type = task Flow and show task flows imported... is also selected.



21. Also remember that if this is a WebCenter application you need to add security entries to your pages.xml file to make the page visible.



22. Deploy and enjoy.

If you run your app you can now create a new WebLogic scoped user, change the users password and reset the users password.
A colleague of mine extended the last feature by including a CAPTCHA component in the ADF form as well to weed out the bots from the humans.