Package org.jclouds.domain.LoginCredentials

Examples of org.jclouds.domain.LoginCredentials.Builder


   public LoginCredentials apply(Template template, LoginCredentials fromNode) {
      LoginCredentials creds = fromNode;
      LoginCredentials credsFromParameters = credentialsFromImageOrTemplateOptions.apply(template);
      if (credsFromParameters != null) {
         Builder builder = LoginCredentials.builder(creds);
         if (credsFromParameters.getUser() != null)
            builder.user(credsFromParameters.getUser());
         if (credsFromParameters.getOptionalPassword().isPresent())
            builder.password(credsFromParameters.getOptionalPassword().get());
         if (credsFromParameters.getOptionalPrivateKey().isPresent())
            builder.privateKey(credsFromParameters.getOptionalPrivateKey().get());
         if (credsFromParameters.shouldAuthenticateSudo())
            builder.authenticateSudo(true);
         creds = builder.build();
      }
      return creds;
   }
View Full Code Here


      return overrideDefaultCredentialsWithOptionsIfPresent(defaultCreds, options);
   }

   public static LoginCredentials overrideDefaultCredentialsWithOptionsIfPresent(
         @Nullable LoginCredentials defaultCreds, RunScriptOptions options) {
      Builder builder = LoginCredentials.builder(defaultCreds);
      if (options.getLoginUser() != null)
         builder.user(options.getLoginUser());
      if (options.getLoginPassword() != null)
         builder.password(options.getLoginPassword());
      if (options.getLoginPrivateKey() != null)
         builder.privateKey(options.getLoginPrivateKey());
      if (options.shouldAuthenticateSudo() != null)
         builder.authenticateSudo(true);
      return builder.build();
   }
View Full Code Here

      return templateOptionsProvider.get();
   }

   protected NodeMetadata updateNodeWithCredentialsIfPresent(NodeMetadata node, RunScriptOptions options) {
      checkNotNull(node, "node");
      Builder builder = LoginCredentials.builder(node.getCredentials());
      if (options.getLoginUser() != null)
         builder.user(options.getLoginUser());
      if (options.hasLoginPasswordOption()) {
          if (options.hasLoginPassword()) {
             builder.password(options.getLoginPassword());
          } else {
             builder.noPassword();
          }
      }
      if (options.hasLoginPrivateKeyOption()) {
          if (options.hasLoginPrivateKey()) {
             builder.privateKey(options.getLoginPrivateKey());
          } else {
             builder.noPrivateKey();
          }
      }
      if (options.shouldAuthenticateSudo() != null)
         builder.authenticateSudo(true);
      return NodeMetadataBuilder.fromNodeMetadata(node).credentials(builder.build()).build();
   }
View Full Code Here

      }
      if (osDescriptionMatches != null) {
         builder.osDescriptionMatches(osDescriptionMatches);
      }
      if (loginUser != null) {
         Builder loginBuilder = LoginCredentials.builder();

         int pos = loginUser.indexOf(':');
         if (pos != -1) {
            loginBuilder.user(loginUser.substring(0, pos)).password(loginUser.substring(pos + 1));
         } else
            loginBuilder.user(loginUser);

         if (authenticateSudo != null) {
            loginBuilder.authenticateSudo(authenticateSudo);
         }
         LoginCredentials creds = loginBuilder.build();
         templateOptions.overrideLoginCredentials(creds);
      }
      if (locationId != null) {
         builder.locationId(locationId);
      }
View Full Code Here

   @Nullable
   public LoginCredentials get() {
      if (credentialStore.containsKey("image")) {
         return LoginCredentials.fromCredentials(credentialStore.get("image"));
      }
      Builder builder = LoginCredentials.builder();

      String loginUser = config.apply(provider + ".image.login-user");
      if (loginUser == null)
         loginUser = config.apply("jclouds.image.login-user");
      if (loginUser != null) {
         int pos = loginUser.indexOf(':');
         if (pos != -1) {
            builder.user(loginUser.substring(0, pos)).password(loginUser.substring(pos + 1));
         } else
            builder.user(loginUser);
      }

      String authenticateSudo = config.apply(provider + ".image.authenticate-sudo");
      if (authenticateSudo == null)
         authenticateSudo = config.apply("jclouds.image.authenticate-sudo");
      if (authenticateSudo != null) {
         builder.authenticateSudo(Boolean.valueOf(authenticateSudo));
      }

      LoginCredentials creds = builder.build();
      if (creds != null)
         credentialStore.put("image", creds);
      return creds;
   }
View Full Code Here

TOP

Related Classes of org.jclouds.domain.LoginCredentials.Builder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.