Search in sources :

Example 1 with UsernameChangedException

use of org.jboss.tools.foundation.core.credentials.UsernameChangedException in project jbosstools-openshift by jbosstools.

the class CDKLaunchEnvironmentUtil method createEnvironment.

public static Map<String, String> createEnvironment(IServer server, boolean skipCredentials) {
    CDKServer cdkServer = (CDKServer) server.loadAdapter(CDKServer.class, new NullProgressMonitor());
    boolean passCredentials = cdkServer.passCredentials();
    String pass = null;
    if (passCredentials && !skipCredentials) {
        try {
            pass = cdkServer.getPassword();
        } catch (UsernameChangedException uce) {
            return createEnvironment(server, uce.getPassword(), uce.getUser());
        }
    }
    return createEnvironment(server, pass);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) UsernameChangedException(org.jboss.tools.foundation.core.credentials.UsernameChangedException) CDKServer(org.jboss.tools.openshift.cdk.server.core.internal.adapter.CDKServer)

Example 2 with UsernameChangedException

use of org.jboss.tools.foundation.core.credentials.UsernameChangedException 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;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) UsernameChangedException(org.jboss.tools.foundation.core.credentials.UsernameChangedException) ICredentialDomain(org.jboss.tools.foundation.core.credentials.ICredentialDomain) ControllableServerBehavior(org.jboss.ide.eclipse.as.wtp.core.server.behavior.ControllableServerBehavior) StorageException(org.eclipse.equinox.security.storage.StorageException)

Example 3 with UsernameChangedException

use of org.jboss.tools.foundation.core.credentials.UsernameChangedException in project jbosstools-openshift by jbosstools.

the class CDKLaunchUtility method getUserPass.

private static final String[] getUserPass(IServer server) {
    final CDKServer cdkServer = (CDKServer) server.loadAdapter(CDKServer.class, new NullProgressMonitor());
    String user = cdkServer.getUsername();
    String pass = null;
    try {
        pass = cdkServer.getPassword();
    } catch (UsernameChangedException uce) {
        pass = uce.getPassword();
        user = uce.getUser();
    }
    return new String[] { user, pass };
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) UsernameChangedException(org.jboss.tools.foundation.core.credentials.UsernameChangedException) CDKServer(org.jboss.tools.openshift.cdk.server.core.internal.adapter.CDKServer)

Aggregations

NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 UsernameChangedException (org.jboss.tools.foundation.core.credentials.UsernameChangedException)3 CDKServer (org.jboss.tools.openshift.cdk.server.core.internal.adapter.CDKServer)2 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 StorageException (org.eclipse.equinox.security.storage.StorageException)1 ControllableServerBehavior (org.jboss.ide.eclipse.as.wtp.core.server.behavior.ControllableServerBehavior)1 ICredentialDomain (org.jboss.tools.foundation.core.credentials.ICredentialDomain)1