Using security
If you are using a credential vault with your WebSphere® Portal, you can configure your HATS portlets to work with the credential vault. HATS provides a Web Express Logon plug-in called WebSphere® Portal Credential Vault Credential Mapper. This plug-in appears in the Add Credential Mapper plug-in window only for a portlet project. This plug-in retrieves a passive user-password credential from a vault slot.
- com.ibm.hats.portlet.cv.CredentialVaultHelper
- com.ibm.hats.portlet.cv.UserPasswordCredential
public static CredentialVaultHelper getInstance();
public static String generateSlotName(String vaultId,String hostDestination,String hostAppId);
public String getSlotId(PortletRequest portletRequest, String slotName, int slotType);
public void setCredential(String slotId,UserPasswordCredential credential,PortletRequest portletRequest);
public UserPasswordCredential getCredential(String slotId,PortletRequest portletRequest);public UserPasswordCredential();
public UserPasswordCredential(String user,char[] password);
public void setUser(String user);
public void setPassword(char[] password);
public void setPassword(String password);
public String getUser();
public String getPassword();Refer to the HATS API References (Javadoc) in the HATS documentation at https://www.ibm.com/docs/en/hats/9.7.0?topic=hats-api-references-javadoc for detailed information about the com.ibm.hats.portlet.cv.CredentialVaultHelper and com.ibm.hats.portlet.cv.UserPasswordCredential classes.
You are responsible for creating and populating the vault slot for your users. The Web Express Logon plug-in can be used directly with credentials created using the setCredential() method of the com.ibm.hats.portlet.cv.CredentialVaultHelper class, because it observes the same naming convention for the slots. The vault slot name can be generated using the generateSlotName() method of the com.ibm.hats.portlet.cv.CredentialVaultHelper class, where you pass in the plug-in parameter SLOT_ID, the host name, and the application name (use null if the application name is not applicable, for example, when connecting to an IBM® i server). Note that the generated slot name is the SLOT_ID concatenated using spaces with the host name, then the application name. The three elements of the slot name are encoded to replace spaces with underscores. The actual vault slot ID can then be retrieved using the getSlotId() method of the com.ibm.hats.portlet.cv.CredentialVaultHelper class, where you pass in the PortletRequest, the slot name, and the SLOT_TYPE. Note that if the SLOT_TYPE is 2 or 3, the slot ID is equal to the slot name.
You can populate the vault slot with credentials that are specified in your business logic or retrieved from another source. If you want to use the Portal user ID, you can retrieve it using the WebSphere® Portal Network Security plug-in. This plug-in appears in the Add Network Security plug-in window only for a portlet project.
| Network Security plug-in | Credential Mapper plug-in |
|---|---|
| WebSphere® Portal NS plug-in | Any supplied or custom CM plug-in or WebSphere® Portal Credential Vault CM plug-in |
| None | WebSphere® Portal Credential Vault CM plug-in |
| Custom NS plug-in | Custom CM plug-in |
- If the host credentials have already been supplied, show the user the first screen to be displayed after authentication. This might be the screen that appears at the end of the Web Express Logon logon macro.
- If the host credentials have not already been supplied, use the
getCredential() method of the com.ibm.hats.portlet.cv.CredentialVaultHelper
class to request the user’s credentials from the vault.
- If the credentials are received successfully (the method does
not return null), do the following:
- Set the global variable to show that the user’s host credentials have been supplied.
- Run the Web Express Logon logon macro.
- If getCredential() returns null, do the following:
- Present a sign-on screen to request the user’s information. This can be a transformed host screen or an HTML page you have created for this purpose.
- Store the input in global variables and add it to the vault.
- If the credentials are received successfully (the method does
not return null), do the following: