ICredentialProvider
is an interface for retrieving the username and password for a backend application that were sent to the portlet in the headers. 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 this interface. Using ICredentialProvider
allows a portlet developer to retrieve the username and password from the headers in 3 lines of code, no matter how that information is being passed. It also allows: the method of credential passing to change, switching from basic auth to a preference value, upgrading from a 5.0.x Portal to a 6.0.x Portal, making use of the Plumtree Credential Vault, 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 retrieve the username and password when using a config file: // Get an ICredentialProvider instance from the IPortletContext IPortletContext portletContext = PortletContextFactory.CreatePortletContext(req, resp); ICredentialProvider cProvider = portletContext.GetCredentialProvider(); // get the username and password String username = cProvider.GetUsername(); String password = cProvider.GetPassword();
ICredentialProvider
can still save a developer from having to deal with his/her own cipher utilities. Extracting the username and password when they are passed from the Credential Vault in version 6.0.x still requires very few lines of code, as illustrated in the following example code: // Get an ICredentialProvider instance from the IPortletContext IPortletContext portletContext = PortletContextFactory.CreatePortletContext(req, resp); ICredentialProvider cProvider = portletContext.GetCredentialProvider(); // set the RSA private key used to decrypt the password; this value could // normally be read from the config file cProvider.SetPrivateKey(rsaPrivateKeyString); // get the username and password String username = cProvider.GetUsername(); String password = cProvider.GetPassword();
// Get an ICredentialProvider instance from the IPortletContext IPortletContext portletContext = PortletContextFactory.CreatePortletContext(req, resp); ICredentialProvider cProvider = portletContext.GetCredentialProvider(); // set the header type and parameter names; these values could normally be // read from the config file cProvider.SetCredentialSettingType(SettingType.User); cProvider.SetUsernameParameterName("DCTMUsername"); cProvider.SetPasswordParameterName("DCTMPassword"); // set the encryption type and key; these values could normally be // read from the config file cProvider.SetCredentialEncryptionType(EncryptionType.RC2); cProvider.SetPrivateKey("skiroblbpauwyryrhfvnmsl"); // get the username and password String username = cProvider.GetUsername(); String password = cProvider.GetPassword();
For a list of all members of this type, see ICredentialProvider Members.
Namespace: Plumtree.Remote.Portlet
Assembly: edk (in edk.dll)
ICredentialProvider Members | Plumtree.Remote.Portlet Namespace