ICredentialSetter
is an interface for encrypting and setting the username and password for a backend application on a PortletResponse
. It provides methods for configuring the credential location and type if a config file cannot be used. In most cases a config file should be used, and the values in the config file will override anything set via the Set methods in the interface. This interface does not work with the Credential Vault. It is intended for use by portlets that communicate with older portal versions and encrypt and decrypt their password settings. Using ICredentialProvider
allows a portlet developer to set the username and password in the response headers in 3 lines of code, no matter how that information is being written. It also allows: the method of credential passing to change, upgrading from a 5.0.x Portal to a 6.0.x Portal, changing encryption methods, or even changing the encryption key; without ever having to change your code or re-compile. Only settings in the web.config file would need to be updated. The following example code shows how easy it is to write the username and password when using a config file: // Get an ICredentialSetter instance from the IPortletContext IPortletContext portletContext = PortletContextFactory.CreatePortletContext(req, resp); ICredentialSetter cSetter = portletContext.GetCredentialSetter(); // set the username and password cSetter.SetUsername(username); cSetter.SetPassword(password);
ICredentialSetter
can still save a developer from having to deal with his/her own cipher utilities. It is necessary to configure all the parameters that indicate how the credentials are being passed to the portlet. The following example code writes the username and password when they are being stored as user prefs with the parameter names DCTMUsername and DCTMPassword, and the password is RC2 encrypted: // Get an ICredentialSetter instance from the IPortletContext IPortletContext portletContext = PortletContextFactory.CreatePortletContext(req, resp); ICredentialSetter cSetter = portletContext.GetCredentialSetter(); // set the header type and parameter names; these values could normally be // read from the config file cSetter.SetCredentialSettingType(SettingType.User); cSetter.SetUsernameParameterName("DCTMUsername"); cSetter.SetPasswordParameterName("DCTMPassword"); // set the encryption type and key; these values could normally be // read from the config file cSetter.SetCredentialEncryptionType(EncryptionType.RC2); cSetter.SetPrivateKey("skiroblbpauwyryrhfvnmsl"); // set the username and password cSetter.SetUsername(username); cSetter.SetPassword(password);
For a list of all members of this type, see ICredentialSetter Members.
Namespace: Plumtree.Remote.Portlet
Assembly: edk (in edk.dll)
ICredentialSetter Members | Plumtree.Remote.Portlet Namespace