当前位置: 首页>>代码示例>>Java>>正文


Java Credentials类代码示例

本文整理汇总了Java中org.jclouds.domain.Credentials的典型用法代码示例。如果您正苦于以下问题:Java Credentials类的具体用法?Java Credentials怎么用?Java Credentials使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Credentials类属于org.jclouds.domain包,在下文中一共展示了Credentials类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: get

import org.jclouds.domain.Credentials; //导入依赖的package包/类
@Override
public Credentials get() {
    if (getIdentity() == null || getIdentity().trim().isEmpty() || getCredential() == null || getCredential().trim().isEmpty()) {
        DefaultAWSCredentialsProviderChain chain = new DefaultAWSCredentialsProviderChain();

        AWSCredentials cred = chain.getCredentials();

        if (cred instanceof BasicSessionCredentials) {
            BasicSessionCredentials sesCred = (BasicSessionCredentials)cred;

            return new SessionCredentials.Builder()
                .identity(sesCred.getAWSAccessKeyId())
                .credential(sesCred.getAWSSecretKey())
                .sessionToken(sesCred.getSessionToken())
                .build();
        } else {
            return new Credentials.Builder<>()
                .identity(cred.getAWSAccessKeyId())
                .credential(cred.getAWSSecretKey())
                .build();
        }
    }

    return super.get();
}
 
开发者ID:hekate-io,项目名称:hekate,代码行数:26,代码来源:AwsCredentialsSupplier.java

示例2: DimensionDataCloudControllerComputeService

import org.jclouds.domain.Credentials; //导入依赖的package包/类
@Inject
protected DimensionDataCloudControllerComputeService(ComputeServiceContext context, Map<String, Credentials> credentialStore,
                                                     @Memoized Supplier<Set<? extends Image>> images, @Memoized Supplier<Set<? extends Hardware>> sizes,
                                                     @Memoized Supplier<Set<? extends Location>> locations, ListNodesStrategy listNodesStrategy,
                                                     GetImageStrategy getImageStrategy, GetNodeMetadataStrategy getNodeMetadataStrategy,
                                                     CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy, RebootNodeStrategy rebootNodeStrategy,
                                                     DestroyNodeStrategy destroyNodeStrategy, ResumeNodeStrategy startNodeStrategy,
                                                     SuspendNodeStrategy stopNodeStrategy, Provider<TemplateBuilder> templateBuilderProvider,
                                                     @Named("DEFAULT") Provider<TemplateOptions> templateOptionsProvider,
                                                     @Named(TIMEOUT_NODE_RUNNING) Predicate<AtomicReference<NodeMetadata>> nodeRunning,
                                                     @Named(TIMEOUT_NODE_TERMINATED) Predicate<AtomicReference<NodeMetadata>> nodeTerminated,
                                                     @Named(TIMEOUT_NODE_SUSPENDED) Predicate<AtomicReference<NodeMetadata>> nodeSuspended,
                                                     InitializeRunScriptOnNodeOrPlaceInBadMap.Factory initScriptRunnerFactory,
                                                     RunScriptOnNode.Factory runScriptOnNodeFactory, InitAdminAccess initAdminAccess,
                                                     PersistNodeCredentials persistNodeCredentials, Timeouts timeouts,
                                                     @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor,
                                                     CleanupServer cleanupServer,
                                                     Optional<ImageExtension> imageExtension,
                                                     Optional<SecurityGroupExtension> securityGroupExtension) {
   super(context, credentialStore, images, sizes, locations, listNodesStrategy, getImageStrategy,
            getNodeMetadataStrategy, runNodesAndAddToSetStrategy, rebootNodeStrategy, destroyNodeStrategy,
            startNodeStrategy, stopNodeStrategy, templateBuilderProvider, templateOptionsProvider, nodeRunning,
            nodeTerminated, nodeSuspended, initScriptRunnerFactory, initAdminAccess, runScriptOnNodeFactory,
            persistNodeCredentials, timeouts, userExecutor, imageExtension, securityGroupExtension);
   this.cleanupServer = checkNotNull(cleanupServer, "cleanupServer");
}
 
开发者ID:cloudsoft,项目名称:amp-dimensiondata,代码行数:27,代码来源:DimensionDataCloudControllerComputeService.java

示例3: updateGceCredentialsIfValid

import org.jclouds.domain.Credentials; //导入依赖的package包/类
@Override
public boolean updateGceCredentialsIfValid(String jsonFilePath) throws KaramelException {
  if (jsonFilePath.isEmpty() || jsonFilePath == null) {
    return false;
  }
  try {
    Credentials credentials = GceLauncher.readCredentials(jsonFilePath);
    GceContext context = GceLauncher.validateCredentials(credentials);
    Confs confs = Confs.loadKaramelConfs();
    confs.put(Settings.GCE_JSON_KEY_FILE_PATH, jsonFilePath);
    confs.writeKaramelConfs();
    clusterService.registerGceContext(context);
  } catch (Throwable ex) {
    throw new KaramelException(ex.getMessage());
  }
  return true;
}
 
开发者ID:karamelchef,项目名称:karamel,代码行数:18,代码来源:KaramelApiImpl.java

示例4: getCredentialFromFile

import org.jclouds.domain.Credentials; //导入依赖的package包/类
/**
 * Reads credential info from {@link #credentialPath} and returns in a string format.
 *
 * @return Credential in {@code String} representation.
 * @throws IgniteSpiException In case of error.
 */
private String getCredentialFromFile() throws IgniteSpiException {
    try {
        String fileContents = Files.toString(new File(credentialPath), Charsets.UTF_8);

        if (provider.equals("google-compute-engine")) {
            Supplier<Credentials> credentialSupplier = new GoogleCredentialsFromJson(fileContents);

            return credentialSupplier.get().credential;
        }

        return fileContents;
    }
    catch (IOException e) {
        throw new IgniteSpiException("Failed to retrieve the private key from the file: " + credentialPath, e);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:23,代码来源:TcpDiscoveryCloudIpFinder.java

示例5: AWSEC2CreateNodesInGroupThenAddToSet

import org.jclouds.domain.Credentials; //导入依赖的package包/类
@Inject
protected AWSEC2CreateNodesInGroupThenAddToSet(
      AWSEC2Api client,
      @Named("ELASTICIP") LoadingCache<RegionAndName, String> elasticIpCache,
      @Named(TIMEOUT_NODE_RUNNING) Predicate<AtomicReference<NodeMetadata>> nodeRunning,
      @Named(PROPERTY_EC2_GENERATE_INSTANCE_NAMES) boolean generateInstanceNames,
      CreateKeyPairPlacementAndSecurityGroupsAsNeededAndReturnRunOptions createKeyPairAndSecurityGroupsAsNeededAndReturncustomize,
      PresentSpotRequestsAndInstances instancePresent,
      Function<RunningInstance, NodeMetadata> runningInstanceToNodeMetadata,
      LoadingCache<RunningInstance, Optional<LoginCredentials>> instanceToCredentials,
      Map<String, Credentials> credentialStore, ComputeUtils utils,
      SpotInstanceRequestToAWSRunningInstance spotConverter) {
   super(client, elasticIpCache, nodeRunning, createKeyPairAndSecurityGroupsAsNeededAndReturncustomize,
         instancePresent, runningInstanceToNodeMetadata, instanceToCredentials, credentialStore, utils);
   this.client = checkNotNull(client, "client");
   this.spotConverter = checkNotNull(spotConverter, "spotConverter");
}
 
开发者ID:apache,项目名称:stratos,代码行数:18,代码来源:AWSEC2CreateNodesInGroupThenAddToSet.java

示例6: OSSApiImpl

import org.jclouds.domain.Credentials; //导入依赖的package包/类
@Inject
public OSSApiImpl(
      @Provider final Supplier<Credentials> creds,
      RegionIdsSupplier regions) {
   this.identity = creds.get().identity;
   this.credential = creds.get().credential;
   this.regions = regions.get();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-jclouds,代码行数:9,代码来源:OSSApiImpl.java

示例7: ECSComputeService

import org.jclouds.domain.Credentials; //导入依赖的package包/类
@Inject
protected ECSComputeService(
      ComputeServiceContext context,
      ECSComputeServiceAdapter client,
      Map<String, Credentials> credentialStore,
      @Memoized Supplier<Set<? extends Image>> images,
      Supplier<Set<? extends Hardware>> hardwareProfiles,
      @Memoized Supplier<Set<? extends Location>> locations,
      ListNodesStrategy listNodesStrategy,
      GetImageStrategy getImageStrategy,
      GetNodeMetadataStrategy getNodeMetadataStrategy,
      CreateNodesInGroupThenAddToSet runNodesAndAddToSetStrategy,
      RebootNodeStrategy rebootNodeStrategy,
      DestroyNodeStrategy destroyNodeStrategy,
      ResumeNodeStrategy resumeNodeStrategy,
      SuspendNodeStrategy suspendNodeStrategy,
      @Named("ECS") Provider<TemplateBuilder> templateBuilderProvider,
      @Named("ECS") Provider<TemplateOptions> templateOptionsProvider,
      @Named(TIMEOUT_NODE_RUNNING) Predicate<AtomicReference<NodeMetadata>> nodeRunning,
      @Named(TIMEOUT_NODE_TERMINATED) Predicate<AtomicReference<NodeMetadata>> nodeTerminated,
      @Named(TIMEOUT_NODE_SUSPENDED) Predicate<AtomicReference<NodeMetadata>> nodeSuspended,
      Factory initScriptRunnerFactory,
      InitAdminAccess initAdminAccess,
      org.jclouds.compute.callables.RunScriptOnNode.Factory runScriptOnNodeFactory,
      PersistNodeCredentials persistNodeCredentials,
      Timeouts timeouts,
      @Named(Constants.PROPERTY_USER_THREADS) ListeningExecutorService userExecutor,
      Optional<ImageExtension> imageExtension,
      Optional<SecurityGroupExtension> securityGroupExtension) {
   super(context, credentialStore, images, hardwareProfiles, locations, listNodesStrategy, getImageStrategy,
         getNodeMetadataStrategy, runNodesAndAddToSetStrategy, rebootNodeStrategy, destroyNodeStrategy, resumeNodeStrategy,
         suspendNodeStrategy, templateBuilderProvider, templateOptionsProvider, nodeRunning, nodeTerminated, nodeSuspended,
         initScriptRunnerFactory, initAdminAccess, runScriptOnNodeFactory, persistNodeCredentials, timeouts, userExecutor,
         imageExtension, securityGroupExtension);
   this.client = client;
}
 
开发者ID:aliyun-beta,项目名称:aliyun-jclouds,代码行数:37,代码来源:ECSComputeService.java

示例8: ServerWithNatRuleToNodeMetadata

import org.jclouds.domain.Credentials; //导入依赖的package包/类
@Inject
ServerWithNatRuleToNodeMetadata(@Memoized Supplier<Set<? extends Location>> locations,
                           GroupNamingConvention.Factory namingConvention, OsImageToImage osImageToImage,
                           OsImageToHardware osImageToHardware, Map<String, Credentials> credentialStore) {
    this.nodeNamingConvention = checkNotNull(namingConvention, "namingConvention").createWithoutPrefix();
    this.locations = checkNotNull(locations, "locations");
    this.osImageToImage = checkNotNull(osImageToImage, "osImageToImage");
    this.osImageToHardware = checkNotNull(osImageToHardware, "osImageToHardware");
    this.credentialStore = checkNotNull(credentialStore, "credentialStore cannot be null");
}
 
开发者ID:cloudsoft,项目名称:amp-dimensiondata,代码行数:11,代码来源:ServerWithNatRuleToNodeMetadata.java

示例9: getCredentialFromFile

import org.jclouds.domain.Credentials; //导入依赖的package包/类
public String getCredentialFromFile(String provider, String credentialPath) throws IllegalArgumentException {
    try {
        String fileContents = Files.toString(new File(credentialPath), Charsets.UTF_8);

        if (provider.equals(GOOGLE_COMPUTE_ENGINE)) {
            Supplier<Credentials> credentialSupplier = new GoogleCredentialsFromJson(fileContents);
            return credentialSupplier.get().credential;
        }

        return fileContents;
    } catch (IOException e) {
        throw new InvalidConfigurationException("Failed to retrieve the private key from the file: " + credentialPath, e);
    }
}
 
开发者ID:hazelcast,项目名称:hazelcast-jclouds,代码行数:15,代码来源:ComputeServiceBuilder.java

示例10: newContextBuilder

import org.jclouds.domain.Credentials; //导入依赖的package包/类
public ContextBuilder newContextBuilder(final String cloudProvider, final String identity,
                                        final String credential, final String roleName) {
    try {
        if (roleName != null && (identity != null || credential != null)) {
            throw new InvalidConfigurationException("IAM role is configured,"
                    + " identity or credential property is not allowed.");
        }
        if (roleName != null && !cloudProvider.equals(AWS_EC2)) {
            throw new InvalidConfigurationException("IAM role is only supported with aws-ec2,"
                    + " your cloud provider is " + cloudProvider);
        }
        if (cloudProvider.equals(AWS_EC2) && roleName != null) {
            Supplier<Credentials> credentialsSupplier = new Supplier<Credentials>() {
                @Override
                public Credentials get() {
                    return new IAMRoleCredentialSupplierBuilder().
                            withRoleName(roleName).build();
                }
            };
            return ContextBuilder.newBuilder(cloudProvider).credentialsSupplier(credentialsSupplier);
        } else {
            checkNotNull(identity, "Cloud provider identity is not set");
            checkNotNull(credential, "Cloud provider credential is not set");
            return ContextBuilder.newBuilder(cloudProvider).credentials(identity, credential);
        }
    } catch (NoSuchElementException e) {
        throw new InvalidConfigurationException("Unrecognized cloud-provider [" + cloudProvider + "]");
    }
}
 
开发者ID:hazelcast,项目名称:hazelcast-jclouds,代码行数:30,代码来源:ComputeServiceBuilder.java

示例11: CreateAndConnectVSphereClient

import org.jclouds.domain.Credentials; //导入依赖的package包/类
@Inject
public CreateAndConnectVSphereClient(Function<Supplier<NodeMetadata>, ServiceInstance> providerContextToCloud,
                                     Factory runScriptOnNodeFactory,
                                     @Provider Supplier<URI> providerSupplier,
                                     @Provider Supplier<Credentials> credentials) {

   this.credentials = checkNotNull(credentials, "credentials is needed");
   this.providerSupplier = checkNotNull(providerSupplier, "endpoint to vSphere node or vCenter server is needed");
}
 
开发者ID:igreenfield,项目名称:jcloud-vsphere,代码行数:10,代码来源:CreateAndConnectVSphereClient.java

示例12: getTenantId

import org.jclouds.domain.Credentials; //导入依赖的package包/类
public String getTenantId(VimInstance vimInstance) throws VimDriverException {
  log.debug(
      "Finding TenantID for Tenant with name: "
          + vimInstance.getTenant()
          + " on VimInstance with name: "
          + vimInstance.getName());
  try {
    ContextBuilder contextBuilder =
        ContextBuilder.newBuilder("openstack-nova")
            .credentials(vimInstance.getUsername(), vimInstance.getPassword())
            .endpoint(vimInstance.getAuthUrl());
    ComputeServiceContext context = contextBuilder.buildView(ComputeServiceContext.class);
    Function<Credentials, Access> auth =
        context
            .utils()
            .injector()
            .getInstance(Key.get(new TypeLiteral<Function<Credentials, Access>>() {}));
    //Get Access and all information
    Access access =
        auth.apply(
            new Credentials.Builder<Credentials>()
                .identity(vimInstance.getTenant() + ":" + vimInstance.getUsername())
                .credential(vimInstance.getPassword())
                .build());
    //Get Tenant ID of user
    String tenant_id = access.getToken().getTenant().get().getId();
    log.info(
        "Found TenantID for Tenant with name: "
            + vimInstance.getTenant()
            + " on VimInstance with name: "
            + vimInstance.getName()
            + " -> TenantID: "
            + tenant_id);
    return tenant_id;
  } catch (Exception e) {
    log.error(e.getMessage(), e);
    throw new VimDriverException(e.getMessage());
  }
}
 
开发者ID:openbaton,项目名称:openstack-plugin,代码行数:40,代码来源:OpenstackClient.java

示例13: loadGceCredentialsIfExist

import org.jclouds.domain.Credentials; //导入依赖的package包/类
@Override
public String loadGceCredentialsIfExist() throws KaramelException {
  Confs confs = Confs.loadKaramelConfs();
  String path = confs.getProperty(Settings.GCE_JSON_KEY_FILE_PATH);
  if (path != null) {
    Credentials credentials = GceLauncher.readCredentials(path);
    if (credentials != null) {
      return path;
    }
  }

  return null;
}
 
开发者ID:karamelchef,项目名称:karamel,代码行数:14,代码来源:KaramelApiImpl.java

示例14: GceContext

import org.jclouds.domain.Credentials; //导入依赖的package包/类
public GceContext(Credentials credentials) {
  ComputeServiceContext context = ContextBuilder.newBuilder("google-compute-engine")
      .modules(Arrays.asList(
              new SshjSshClientModule(),
              new EnterpriseConfigurationModule(),
              new SLF4JLoggingModule()))
      .credentials(credentials.identity, credentials.credential)
      .buildView(ComputeServiceContext.class);
  computeService = context.getComputeService();
  gceApi = context.unwrapApi(GoogleComputeEngineApi.class);
  fireWallApi = gceApi.firewalls();
  networkApi = gceApi.networks();
  routeApi = gceApi.routes();
  this.credentials = credentials;
}
 
开发者ID:karamelchef,项目名称:karamel,代码行数:16,代码来源:GceContext.java

示例15: readCredentials

import org.jclouds.domain.Credentials; //导入依赖的package包/类
/**
 *
 * @param jsonKeyPath
 * @return
 */
public static Credentials readCredentials(String jsonKeyPath) {
  Credentials credentials = null;
  if (jsonKeyPath != null && !jsonKeyPath.isEmpty()) {
    try {
      String fileContents = Files.toString(new File(jsonKeyPath), Charset.defaultCharset());
      Supplier<Credentials> credentialSupplier = new GoogleCredentialsFromJson(fileContents);
      credentials = credentialSupplier.get();
    } catch (IOException ex) {
      logger.error("Error Reading the Json key file. Please check the provided path is correct.", ex);
    }
  }
  return credentials;
}
 
开发者ID:karamelchef,项目名称:karamel,代码行数:19,代码来源:GceLauncher.java


注:本文中的org.jclouds.domain.Credentials类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。