Skip to main content

developerWorks >  WebSphere  >  Forums  >  Portal and Portlet Development  >  developerWorks

Getting Password stored in Portlet credential vault    Point your RSS reader here for a feed of the latest messages in this thread


Tags for this thread: 

     

 
 

My developerWorks
 Welcome, Guest
Sign in or register
This question is not answered.

Permlink Replies: 1 - Pages: 1 - Last Post: Nov 4, 2009 1:20 PM Last Post By: syphax213
sara123

Posts: 2
Registered: Nov 03, 2009 08:22:22 AM
Getting Password stored in Portlet credential vault
Posted: Nov 03, 2009 08:45:06 AM
 
Click to report abuse...   Click to reply to this thread Reply
Hi,

I am storing the User ID and Password from my Portal page to the Credential Vault. While retreiving back the password from credential vault, I am getting it in some encrypted/encoded format. For example if i send the value "ew12345" as password I am getting back "[C@46effee5" from the credential vault.

I want to know how to get the original password or how to decode this password to my original password that I initially stored in credential vault:

I am using the following code to set the password to credential vault:

ObjectID segmentID = vaultService.getDefaultUserCredentialSegmentId();
Map descripMap = new Hashtable();
Map keywordMap = new Hashtable();
int secretType = vaultService.SECRET_TYPE_USERID_STRING_PASSWORD_STRING;
boolean active = false;
boolean portletPrivate = true;

CredentialSlotConfig slot= vaultService.createCredentialSlot("SSO1", segmentID,descripMap, keywordMap, secretType, active, portletPrivate, request);

vaultService.setCredentialSecretUserPassword(slot.getSlotId(),"ev12345","ev12345".toCharArray(), request);
pre.store();


I am using the following code to retrieve the password back from credential vault:


credential=(UserPasswordPassiveCredential)vaultService.getCredential(slotid, "UserPasswordPassive", new HashMap(), request);
String userID = credential.getUserId());
String password = credential.getPassword().toString()); // This returns encoded pwd



Kindly let me know how to get the original password / password in decoded format from credential vault. Its very urgent.....

Thanks,
Saravanan T
syphax213

Posts: 66
Registered: Oct 12, 2007 12:34:26 PM
Re: Getting Password stored in Portlet credential vault
Posted: Nov 04, 2009 01:20:53 PM   in response to: sara123 in response to: sara123's post
 
Click to report abuse...   Click to reply to this thread Reply
Here is some code that I wrote to get this value in the legacy API:

public static void getCredential(PortletRequest portletRequest, WorkloadIndexPortletSessionBean sessionBean, StringBuffer userid, StringBuffer password)
throws PortletException
{
if(4 == sessionBean.getSecretType())
{
Subject subject = vaultService.getUserSubject(portletRequest);
if(subject != null)
{
userid.append(getPrincipalFromSubject(subject, "com.ibm.wps.sso.UserIdPrincipal"));
password.append(getPrincipalFromSubject(subject, "com.ibm.wps.sso.PasswordCredential"));
}
} else
{
String slotId = getSlotId(portletRequest, sessionBean, false);
if(slotId != null)
{
UserPasswordPassiveCredential credential = (UserPasswordPassiveCredential)vaultService.getCredential(slotId, "UserPasswordPassive", new HashMap(), portletRequest);
if(credential != null)
{
userid.append(credential.getUserId());
password.append(String.valueOf(credential.getPassword()));
}
}
}
}

You can also look at this for some direction:
http://www.ibm.com/developerworks/websphere/library/techarticles/0211_konduru/konduru.html

  • Matt Munse

The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
 Tags
Help

Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular type of content or application that you're viewing.

My tags shows your tags for this particular type of content or application that you're viewing.

 

MoreLess 


Point your RSS reader here for a feed of the latest messages in all forums