Search in sources :

Example 11 with ConnectionInfo

use of org.ow2.proactive.authentication.ConnectionInfo in project scheduling by ow2-proactive.

the class SchedulerClientTest method testPushFileWithNonAdminUserPwdShouldSucceed.

@Test(timeout = MAX_WAIT_TIME)
public void testPushFileWithNonAdminUserPwdShouldSucceed() throws Exception {
    File tmpFile = testFolder.newFile();
    Files.write("non_admin_user_push_file_contents".getBytes(), tmpFile);
    ISchedulerClient client = SchedulerClient.createInstance();
    client.init(new ConnectionInfo(getRestServerUrl(), getNonAdminLogin(), getNonAdminLoginPassword(), null, true));
    client.pushFile("USERSPACE", "/test_non_admin_user_push_file", "tmpfile.tmp", tmpFile.getAbsolutePath());
    String destDirPath = URI.create(client.getUserSpaceURIs().get(0)).getPath();
    File destFile = new File(destDirPath, "test_non_admin_user_push_file/tmpfile.tmp");
    assertTrue(Files.equal(tmpFile, destFile));
}
Also used : ISchedulerClient(org.ow2.proactive.scheduler.rest.ISchedulerClient) ConnectionInfo(org.ow2.proactive.authentication.ConnectionInfo) File(java.io.File) Test(org.junit.Test)

Example 12 with ConnectionInfo

use of org.ow2.proactive.authentication.ConnectionInfo in project scheduling by ow2-proactive.

the class SmartProxyImpl method init.

@Override
public void init(ConnectionInfo connectionInfo) throws SchedulerException, LoginException {
    this.connectionInfo = connectionInfo;
    if (connectionInfo.getCredentialFile() != null) {
        try {
            Credentials credentials = Credentials.getCredentials(connectionInfo.getCredentialFile().getAbsolutePath());
            init(connectionInfo.getUrl(), credentials);
        } catch (KeyException e) {
            throw new LoginException(e.getMessage());
        }
    } else {
        CredData cred = new CredData(CredData.parseLogin(connectionInfo.getLogin()), CredData.parseDomain(connectionInfo.getLogin()), connectionInfo.getPassword());
        init(connectionInfo.getUrl(), cred);
    }
}
Also used : CredData(org.ow2.proactive.authentication.crypto.CredData) LoginException(javax.security.auth.login.LoginException) Credentials(org.ow2.proactive.authentication.crypto.Credentials) KeyException(java.security.KeyException)

Aggregations

ConnectionInfo (org.ow2.proactive.authentication.ConnectionInfo)9 ISchedulerClient (org.ow2.proactive.scheduler.rest.ISchedulerClient)4 File (java.io.File)2 KeyException (java.security.KeyException)2 Test (org.junit.Test)2 CredData (org.ow2.proactive.authentication.crypto.CredData)2 PublicKey (java.security.PublicKey)1 TimeoutException (java.util.concurrent.TimeoutException)1 LoginException (javax.security.auth.login.LoginException)1 HttpClient (org.apache.http.client.HttpClient)1 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)1 ApacheHttpClient4Engine (org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine)1 ResteasyProviderFactory (org.jboss.resteasy.spi.ResteasyProviderFactory)1 Before (org.junit.Before)1 UserData (org.ow2.proactive.authentication.UserData)1 Credentials (org.ow2.proactive.authentication.crypto.Credentials)1 HttpClientBuilder (org.ow2.proactive.http.HttpClientBuilder)1 SchedulerAuthenticationInterface (org.ow2.proactive.scheduler.common.SchedulerAuthenticationInterface)1 InternalSchedulerException (org.ow2.proactive.scheduler.common.exception.InternalSchedulerException)1 JobCreationException (org.ow2.proactive.scheduler.common.exception.JobCreationException)1