When you are not using LDAP and you have to change user password with verifying old password the only option left is by using WAS Programatic Login.you can reset new password by Puma API and verify the old password by WAS Authentication, the below code is working fine for me.
PortletServiceHome psh = null;
try {
if (psh == null) {
javax.naming.Context ctx = new javax.naming.InitialContext();
psh = (PortletServiceHome) ctx.lookup("portletservice/com.ibm.portal.um.portletservice.PumaHome");
}
} catch (NamingException e) {
e.printStackTrace();
}
HashMap userAttrs = new HashMap();
String oldPwd = request.getParameter("OLD_PASSWORD");
String pwd1 = request.getParameter("PASSWORD");
String pwd2 = request.getParameter("PASSWORD_CONFIRM");
try
{
PumaHome service=(PumaHome) psh.getPortletService(PumaHome.class);
PumaLocator pLocator=service.getLocator();
PumaController pc = service.getController();
com.ibm.wps.puma.User vuser = (com.ibm.wps.puma.User)request.getAttribute("com.ibm.portal.puma.request-user");
String userid = vuser.getUserID();
if( pwd1 != null && oldPwd != null )
{
//verify password
LoginContext lc = null;
Subject subject = null;
System.out.println("old pwd::"+oldPwd);
try {
lc = new LoginContext("WSLogin",
new WSCallbackHandlerImpl(userid, oldPwd));
} catch (LoginException le) {
System.out.println("Cannot create LoginContext. " + le.getMessage());
} catch(SecurityException se) {
System.out.println("Security Exception. " + se.getMessage());
}
try {
lc.login();
subject = lc.getSubject();
System.out.println("loged in");
passwordVerification = true;
com.ibm.websphere.security.auth.WSSubject.setRunAsSubject(subject);
} catch(LoginException le) {
passwordVerification = false;
System.out.println("Fails to create Subject. " + le.getMessage());
}
if(passwordVerification)
{
userAttrs.put("uid", userid);
userAttrs.put("password", pwd1);
List userList = pLocator.findUsersByAttribute("uid", userid);
User editUser = (User)userList.get(0);
pc.setAttributes(editUser, userAttrs);
passwordChanged = true;
}
Monday, June 27, 2011
Thursday, June 9, 2011
Tuesday, June 7, 2011
Inter Portlet Communication in JSR -168 by RAD 7.5,Portlet Wiring.
1.First create a new portlet project or use existing one,The source and target portlet should be in same workspace.
2.Create Portlet IPC1 & IPC2.
3.Create Source and Target Portlets as shown below.
Select The Data Type For Source Portlet, as shown below.
Similarly make a cooperative target portlet, as shown.
As for source portlet, select Data Type for target portlet.
Then in the source portlet JSP use the Cooperative Source Trigger to create an event on click,
After setting the event use
if(actionValue != null && "TargetAction".equals(actionValue)) {
String input = request.getParameter("inputProperty");
session.setAttribute("input", input,session.PORTLET_SCOPE);
}
in target portlet process action to fetch the value that you have set in the scope.
After that you can use bean or session to render the value from process action to targer portlet jsp.
Then deploy the portlet, and add them on a page, Then edit page layout and do the WIRING between source and target portlets. as shown below.
Now your Inter Portlet communication is done.you can put the value in the source portlet and after clicking submit value will be shown on target portlet.
On submitting the output will be:-
For any help or issue please contact me at sanjeetsinghmerhal@gmail.com.
Please follow me if material is useful for you.
Thanks
2.Create Portlet IPC1 & IPC2.
3.Create Source and Target Portlets as shown below.
Select The Data Type For Source Portlet, as shown below.
Similarly make a cooperative target portlet, as shown.
As for source portlet, select Data Type for target portlet.
Then in the source portlet JSP use the Cooperative Source Trigger to create an event on click,
After setting the event use
if(actionValue != null && "TargetAction".equals(actionValue)) {
String input = request.getParameter("inputProperty");
session.setAttribute("input", input,session.PORTLET_SCOPE);
}
in target portlet process action to fetch the value that you have set in the scope.
After that you can use bean or session to render the value from process action to targer portlet jsp.
Then deploy the portlet, and add them on a page, Then edit page layout and do the WIRING between source and target portlets. as shown below.
Now your Inter Portlet communication is done.you can put the value in the source portlet and after clicking submit value will be shown on target portlet.
On submitting the output will be:-
For any help or issue please contact me at sanjeetsinghmerhal@gmail.com.
Please follow me if material is useful for you.
Thanks
Subscribe to:
Posts (Atom)