Search in sources :

Example 1 with LazyCredentialsPrompter

use of org.jboss.tools.openshift.core.LazyCredentialsPrompter in project jbosstools-openshift by jbosstools.

the class ConnectionFactory method create.

@Override
public Connection create(String url) {
    if (StringUtils.isEmpty(url)) {
        return null;
    }
    try {
        LazySSLCertificateCallback sslCertCallback = new LazySSLCertificateCallback();
        IClient client = new ClientBuilder(url).sslCertificateCallback(sslCertCallback).withMaxRequests(ConnectionProperties.MAX_REQUESTS).withMaxRequestsPerHost(ConnectionProperties.MAX_REQUESTS).build();
        return new Connection(client, new LazyCredentialsPrompter());
    } catch (OpenShiftException e) {
        OpenShiftCoreActivator.pluginLog().logInfo(NLS.bind("Could not create OpenShift connection: Malformed url {0}", url), e);
        return null;
    }
}
Also used : LazySSLCertificateCallback(org.jboss.tools.openshift.core.LazySSLCertificateCallback) OpenShiftException(com.openshift.restclient.OpenShiftException) IConnection(org.jboss.tools.openshift.common.core.connection.IConnection) IClient(com.openshift.restclient.IClient) LazyCredentialsPrompter(org.jboss.tools.openshift.core.LazyCredentialsPrompter) ClientBuilder(com.openshift.restclient.ClientBuilder)

Example 2 with LazyCredentialsPrompter

use of org.jboss.tools.openshift.core.LazyCredentialsPrompter in project jbosstools-openshift by jbosstools.

the class LazyCredentialsPrompterTest method setup.

@Before
public void setup() throws MalformedURLException {
    when(client.getBaseURL()).thenReturn(new URL("https://localhost:8443"));
    this.lazyPrompter = spy(new LazyCredentialsPrompter());
    this.connection = new Connection(client.getBaseURL().toString(), lazyPrompter, null);
    when(permissiveExtensionPrompter.promptAndAuthenticate(connection, null)).thenReturn(true);
    when(denyingExtensionPrompter.promptAndAuthenticate(connection, null)).thenReturn(true);
}
Also used : Connection(org.jboss.tools.openshift.core.connection.Connection) LazyCredentialsPrompter(org.jboss.tools.openshift.core.LazyCredentialsPrompter) URL(java.net.URL) Before(org.junit.Before)

Aggregations

LazyCredentialsPrompter (org.jboss.tools.openshift.core.LazyCredentialsPrompter)2 ClientBuilder (com.openshift.restclient.ClientBuilder)1 IClient (com.openshift.restclient.IClient)1 OpenShiftException (com.openshift.restclient.OpenShiftException)1 URL (java.net.URL)1 IConnection (org.jboss.tools.openshift.common.core.connection.IConnection)1 LazySSLCertificateCallback (org.jboss.tools.openshift.core.LazySSLCertificateCallback)1 Connection (org.jboss.tools.openshift.core.connection.Connection)1 Before (org.junit.Before)1