The IDK provides standard methods for encrypting and decrypting credentials stored in the ALI database.
Parameter | Accepted Values |
---|---|
CredentialSettingType | Portal setting type:
|
UsernameParameterName | The setting name for the user name setting (for example, MyAppUserName). |
PasswordParameterName | The setting name for the password setting (e.g., MyAppPassword). |
CredentialEncryptionType | Encryption type:
|
RC2PrivateKey | String of private key for RC2 encryption. |
AESPrivateKey | String of private key for AES encryption. |
Java
// get an ICredentialSetter instance from IPortletContext IPortletContext portletContext = PortletContextFactory.createPortletContext(req, resp); ICredentialSetter cSetter = portletContext.getCredentialSetter(); // set the header type and parameter names cSetter.setCredentialSettingType(SettingType.User); cSetter.setUsernameParameterName("MyAppUserName"); cSetter.setPasswordParameterName("MyAppPassword"); // set the encryption type and key cSetter.setCredentialEncryptionType(EncryptionType.RC2); cSetter.setPrivateKey("skiroblbpauwyryrhfvnmsl"); // set the user name and password cSetter.setUsername(username); cSetter.setPassword(password);
.NET
// get an ICredentialSetter instance from IPortletContext IPortletContext portletContext = PortletContextFactory.CreatePortletContext(req, resp); ICredentialSetter cSetter = portletContext.GetCredentialSetter(); // set the header type and parameter names cSetter.SetCredentialSettingType(SettingType.User); cSetter.SetUsernameParameterName("MyAppUserName"); cSetter.SetPasswordParameterName("MyAppPassword"); // set the encryption type and key cSetter.SetCredentialEncryptionType(EncryptionType.RC2); cSetter.SetPrivateKey("skiroblbpauwyryrhfvnmsl"); // set the user name and password cSetter.SetUsername(username); cSetter.SetPassword(password);
Java
// get an ICredentialProvider instance from IPortletContext IPortletContext portletContext = PortletContextFactory.createPortletContext(req, resp); ICredentialProvider cProvider = portletContext.getCredentialProvider(); // set the header type and parameter names cProvider.setCredentialSettingType(SettingType.User); cProvider.setUsernameParameterName("MyAppUsername"); cProvider.setPasswordParameterName("MyAppPassword"); // set the encryption type and key cProvider.setCredentialEncryptionType(EncryptionType.RC2); cProvider.setPrivateKey("skiroblbpauwyryrhfvnmsl"); // get the username and password String username = cProvider.getUsername(); String password = cProvider.getPassword();
.NET
// get an ICredentialProvider instance from IPortletContext IPortletContext portletContext = PortletContextFactory.CreatePortletContext(req, resp); ICredentialProvider cProvider = portletContext.GetCredentialProvider(); // set the header type and parameter names cProvider.SetCredentialSettingType(SettingType.User); cProvider.SetUsernameParameterName("DCTMUsername"); cProvider.SetPasswordParameterName("DCTMPassword"); // set the encryption type and key cProvider.SetCredentialEncryptionType(EncryptionType.RC2); cProvider.SetPrivateKey("skiroblbpauwyryrhfvnmsl"); // get the username and password String username = cProvider.GetUsername(); String password = cProvider.GetPassword();