org.jclouds.domain.Credentials类的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(10.0k)|赞(0)|评价(0)|浏览(239)

本文整理了Java中org.jclouds.domain.Credentials类的一些代码示例,展示了Credentials类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Credentials类的具体详情如下:
包路径:org.jclouds.domain.Credentials
类名称:Credentials

Credentials介绍

暂无

代码示例

代码示例来源:origin: jclouds/legacy-jclouds

public void testSubClassEquals() {
   Credentials creds = new Credentials("user", "pass");
   assertEquals(creds, new Credentials("user", "pass") {
   });
  }
}

代码示例来源:origin: jclouds/legacy-jclouds

public void testWhenCredentialsAlreadyPresentReturnsSame() {
 @SuppressWarnings("unchecked")
 Map<String, Credentials> credstore = createMock(Map.class);
 Credentials expected = new Credentials("root", null);
 ValueOfConfigurationKeyOrNull config = createMock(ValueOfConfigurationKeyOrNull.class);
 expect(credstore.containsKey("image")).andReturn(true);
 expect(credstore.get("image")).andReturn(expected);
 replay(config);
 replay(credstore);
 GetLoginForProviderFromPropertiesAndStoreCredentialsOrReturnNull fn = new GetLoginForProviderFromPropertiesAndStoreCredentialsOrReturnNull(
    "provider", config, credstore);
 assertEquals(fn.get(), expected);
 verify(config);
 verify(credstore);
}

代码示例来源:origin: jclouds/legacy-jclouds

@Test
public void testWithSingleDomainname() {
 LoginResponse response = createMock(LoginResponse.class);
 SessionClient client = createMock(SessionClient.class);
 expect(client.loginUserInDomainWithHashOfPassword(eq("User"), eq("Domain"), (String) anyObject())).andReturn(response);
 replay(client);
 LoginWithPasswordCredentials obj = new LoginWithPasswordCredentials(client);
 Credentials cred = new Credentials("Domain/User", "koffiedik");
 obj.load(cred);
}

代码示例来源:origin: apache/jclouds

public void testDefaultDifferentAcrossMultipleInjectors() throws IOException {
 Injector injector = createInjector();
 Map<String, ByteSource> map = getMap(injector);
 put(map, getStore(injector), "test", new Credentials("user", "pass"));
 Map<String, Credentials> anotherStore = getStore(createInjector());
 assertEquals(anotherStore.size(), 0);
 assertFalse(anotherStore.containsKey("test"));
}

代码示例来源:origin: apache/jclouds

/**
* We do not support just supplying the projectNumber, as this causes confusion when using oauth. OAuth JWT requires
* the whole email for the ISS field. This is better than confusing users with instructions like "Use the email,
* except if using bearer token. Then, you don't need the entire email, just put in the numeric id part of it."
*/
public void justProjectIdIsInvalid() throws Exception {
 server.enqueue(jsonResponse("/project.json"));
 try {
   fn().apply(new Credentials(projectNumber, credential));
   fail();
 } catch (IllegalArgumentException e) {
   assertEquals(e.getMessage(), String.format("Client email %s is malformed. Should be %s", projectNumber,
      new GoogleComputeEngineApiMetadata().getIdentityName()));
 }
 assertEquals(server.getRequestCount(), 0);
}

代码示例来源:origin: jclouds/legacy-jclouds

@BeforeTest
protected void setUpInjector() throws IOException {
 utils = FormSignerTest.injector(new Credentials("identity", "credential")).getInstance(AWSUtils.class);
 command = createMock(HttpCommand.class);
 expect(command.getCurrentRequest()).andReturn(createMock(HttpRequest.class)).atLeastOnce();
 replay(command);
}

代码示例来源:origin: apache/jclouds

public void testCredentialsAreLoadedOnRightAlgoAndCredentials() {
 Properties propertied = OAuthTestUtils.defaultProperties(new Properties());
 Credentials validCredentials = new Credentials(propertied.getProperty("oauth.identity"),
     propertied.getProperty("oauth.credential"));
 PrivateKeySupplier supplier = new PrivateKeySupplier(Suppliers.ofInstance(validCredentials),
    new PrivateKeyForCredentials());
 assertNotNull(supplier.get());
}

代码示例来源:origin: jclouds/legacy-jclouds

@SuppressWarnings("unchecked")
 public T build() {
   return (T) new Credentials(identity, credential);
 }
}

代码示例来源:origin: org.jclouds/jclouds-antcontrib

@SuppressWarnings("unchecked")
@Override
public ComputeServiceContext load(URI from) {
 Properties props = new Properties();
 props.putAll(projectProvider.get().getProperties());
 Set<Module> modules = ImmutableSet.<Module> of(new AntLoggingModule(projectProvider.get(),
      ComputeServiceConstants.COMPUTE_LOGGER), new JschSshClientModule());
 // adding the properties to the factory will allow us to pass
 // alternate endpoints
 String provider = from.getHost();
 Credentials creds = Credentials.parse(from);
 return ContextBuilder.newBuilder(provider)
            .credentials(creds.identity, creds.credential)
            .modules(modules)
            .overrides(props).buildView(ComputeServiceContext.class);
}

代码示例来源:origin: apache/jclouds

public void testWhenCredentialsAlreadyPresentReturnsSame() {
 @SuppressWarnings("unchecked")
 Map<String, Credentials> credstore = createMock(Map.class);
 Credentials expected = new Credentials("root", null);
 ValueOfConfigurationKeyOrNull config = createMock(ValueOfConfigurationKeyOrNull.class);
 expect(credstore.containsKey("image")).andReturn(true);
 expect(credstore.get("image")).andReturn(expected);
 replay(config);
 replay(credstore);
 GetLoginForProviderFromPropertiesAndStoreCredentialsOrReturnNull fn = new GetLoginForProviderFromPropertiesAndStoreCredentialsOrReturnNull(
    "provider", config, credstore);
 assertEquals(fn.get(), expected);
 verify(config);
 verify(credstore);
}

代码示例来源:origin: jclouds/legacy-jclouds

@Test
  public void testWithNoDomainname() {
    LoginResponse response = createMock(LoginResponse.class);
    SessionClient client = createMock(SessionClient.class);

    expect(client.loginUserInDomainWithHashOfPassword(eq("User"), eq(""), (String) anyObject())).andReturn(response);
    replay(client);

    LoginWithPasswordCredentials obj = new LoginWithPasswordCredentials(client);
    Credentials cred = new Credentials("User", "koffiedik");

    obj.load(cred);
  }
}

代码示例来源:origin: apache/jclouds

@BeforeTest
protected void setUpInjector() throws IOException {
 utils = FormSignerV2Test.injector(new Credentials("identity", "credential")).getInstance(AWSUtils.class);
 command = createMock(HttpCommand.class);
 expect(command.getCurrentRequest()).andReturn(createMock(HttpRequest.class)).atLeastOnce();
 replay(command);
}

代码示例来源:origin: org.jclouds/jclouds-core

@SuppressWarnings("unchecked")
 public T build() {
   return (T) new Credentials(identity, credential);
 }
}

代码示例来源:origin: jclouds/legacy-jclouds

public void testWhenCredentialsNotPresentAndProviderPropertyHasUser() {
 @SuppressWarnings("unchecked")
 Map<String, Credentials> credstore = createMock(Map.class);
 Credentials expected = new Credentials("ubuntu", null);
 ValueOfConfigurationKeyOrNull config = createMock(ValueOfConfigurationKeyOrNull.class);
 expect(credstore.containsKey("image")).andReturn(false);
 expect(config.apply("provider.image.login-user")).andReturn("ubuntu");
 expect(config.apply("provider.image.authenticate-sudo")).andReturn(null);
 expect(config.apply("jclouds.image.authenticate-sudo")).andReturn(null);
 expect(credstore.put("image", expected)).andReturn(null);
 replay(config);
 replay(credstore);
 GetLoginForProviderFromPropertiesAndStoreCredentialsOrReturnNull fn = new GetLoginForProviderFromPropertiesAndStoreCredentialsOrReturnNull(
    "provider", config, credstore);
 assertEquals(fn.get(), expected);
 verify(config);
 verify(credstore);
}

代码示例来源:origin: apache/jclouds

public void testSubClassEquals() {
   Credentials creds = new Credentials("user", "pass");
   assertEquals(creds, new Credentials("user", "pass") {
   });
  }
}

代码示例来源:origin: apache/jclouds

@Test
public void testWithSingleDomainname() {
 LoginResponse response = createMock(LoginResponse.class);
 SessionApi client = createMock(SessionApi.class);
 expect(client.loginUserInDomainWithHashOfPassword(eq("User"), eq("Domain"), (String) anyObject())).andReturn(response);
 replay(client);
 LoginWithPasswordCredentials obj = new LoginWithPasswordCredentials(client);
 Credentials cred = new Credentials("Domain/User", "koffiedik");
 obj.load(cred);
}

代码示例来源:origin: com.amysta.jclouds/jclouds-core

@SuppressWarnings("unchecked")
 public T build() {
   return (T) new Credentials(identity, credential);
 }
}

代码示例来源:origin: jclouds/legacy-jclouds

public void testWhenCredentialsNotPresentAndProviderPropertyHasUserAndPassword() {
 @SuppressWarnings("unchecked")
 Map<String, Credentials> credstore = createMock(Map.class);
 Credentials expected = new Credentials("ubuntu", "password");
 ValueOfConfigurationKeyOrNull config = createMock(ValueOfConfigurationKeyOrNull.class);
 expect(credstore.containsKey("image")).andReturn(false);
 expect(config.apply("provider.image.login-user")).andReturn("ubuntu:password");
 expect(config.apply("provider.image.authenticate-sudo")).andReturn(null);
 expect(config.apply("jclouds.image.authenticate-sudo")).andReturn(null);
 expect(credstore.put("image", expected)).andReturn(null);
 replay(config);
 replay(credstore);
 GetLoginForProviderFromPropertiesAndStoreCredentialsOrReturnNull fn = new GetLoginForProviderFromPropertiesAndStoreCredentialsOrReturnNull(
    "provider", config, credstore);
 assertEquals(fn.get(), expected);
 verify(config);
 verify(credstore);
}

代码示例来源:origin: jclouds/legacy-jclouds

@Test
public void testProviderMetadataWithCredentialsSetSupplier() {
 ContextBuilder withCredsSupplier = testContextBuilder().credentialsSupplier(
    ofInstance(new Credentials("foo", "BAR")));
 Credentials creds = withCredsSupplier.buildInjector()
    .getInstance(Key.get(new TypeLiteral<Supplier<Credentials>>() {
    }, Provider.class)).get();
 assertEquals(creds, new Credentials("foo", "BAR"));
}

代码示例来源:origin: apache/jclouds

@Test
  public void testWithNoDomainname() {
    LoginResponse response = createMock(LoginResponse.class);
    SessionApi client = createMock(SessionApi.class);

    expect(client.loginUserInDomainWithHashOfPassword(eq("User"), eq(""), (String) anyObject())).andReturn(response);
    replay(client);

    LoginWithPasswordCredentials obj = new LoginWithPasswordCredentials(client);
    Credentials cred = new Credentials("User", "koffiedik");

    obj.load(cred);
  }
}

相关文章

Credentials类方法