Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
themeEclipse
import nl.gx.webmanager.services.credentials.CredentialsProviderService;

public class SomeClassThatNeedsTheCustomCredentialsSet {
	....

   OwnedConfigurationService myOwnedConfigurationService;

	private final static String CREDENTIAL_IDENTIFIER = "someCredentialSetIdentier";

	public void doSomething() {
		String username, password;
		CustomCredenentials someCustomCredentials = myCredentialsProviderService.getCredentials(CREDENTIAL_IDENTIFIER);

		if (someCredentials == null) {
			username = myOwnedConfigurationService.getUsername();	
			password = myOwnedConfigurationService.getPassword();
		} else {
			username = someCustomCredentials.getUsername();	
			password = someCustomCredentials.getPassword();
		}
		// Use the credentials
		....
	}
}		


 Depending Depending on the application server being used, a credential provider or -vault may be standard within the application server such as inside IBM WebSphere or another product can be used for this functionality (in case of Tomcat or Jboss) alike CyberArk.

...