use of org.jboss.tools.foundation.core.credentials.ICredentialDomain in project jbosstools-openshift by jbosstools.
the class CDKServer method getUsername.
public String getUsername() {
ControllableServerBehavior beh = (ControllableServerBehavior) getServer().loadAdapter(ControllableServerBehavior.class, new NullProgressMonitor());
Object user2 = beh.getSharedData(CDKServerBehaviour.PROP_CACHED_USER);
if (user2 instanceof String)
return (String) user2;
String user = getServer().getAttribute(PROP_USERNAME, (String) null);
if (user == null) {
ICredentialDomain domain = CredentialService.getCredentialModel().getDomain(CredentialService.REDHAT_ACCESS);
user = domain.getDefaultUsername();
}
return user;
}
use of org.jboss.tools.foundation.core.credentials.ICredentialDomain in project jbosstools-openshift by jbosstools.
the class CDKServer method getPassword.
public String getPassword() throws UsernameChangedException {
ControllableServerBehavior beh = (ControllableServerBehavior) getServer().loadAdapter(ControllableServerBehavior.class, new NullProgressMonitor());
Object pw = beh.getSharedData(CDKServerBehaviour.PROP_CACHED_PASSWORD);
if (pw instanceof String)
return (String) pw;
ICredentialDomain domain = CredentialService.getCredentialModel().getDomain(CredentialService.REDHAT_ACCESS);
String user = getUsername();
if (user != null && domain != null) {
try {
return domain.getCredentials(user);
} catch (StorageException se) {
CDKCoreActivator.getDefault().getLog().log(new Status(IStatus.ERROR, CDKCoreActivator.PLUGIN_ID, se.getMessage(), se));
} catch (UsernameChangedException uce) {
if (uce.getSaveCredentials()) {
saveChangedCredentials(uce);
}
throw uce;
}
}
return null;
}
Aggregations