Esempio n. 1
0
 public String login(String username, String password) {
   if (username == null || password == null) {
     return ("The user name or password you entered is incorrect.");
   }
   username = username.toLowerCase();
   log(INFO, "Logging in: " + username);
   try {
     if (!username.contains("@")) {
       log(ERROR, "User: "******" NOT email");
       return ("Enter a valid email address for your Cloud Foundry account.");
     }
     log(DEBUG, "Logging in user: = " + username);
     loginCredentials = new LoginCredentialsBean(username, password);
     Hashtable<String, Object> loginResult =
         spinupController.processLogin(loginCredentials, RuntimeAccess.getInstance().getRequest());
     secret = (SharedSecret) loginResult.get("secret");
     transportToken = (TransportToken) loginResult.get("token");
     if (secret != null && transportToken != null) {
       return ("SUCCESS " + username + " logged in");
     } else {
       return ("Unable able to authenticate. Problem getting token and/or secret.");
     }
   } catch (Exception e) {
     log(ERROR, "Login has failed " + e.getMessage());
     return ("The user name or password you entered is incorrect.");
   }
 }
Esempio n. 2
0
  public Hashtable<String, String> launchStudio() {
    Hashtable<String, String> result = new Hashtable<String, String>();
    if (spinupController.isNewDeployment(loginCredentials)) {
      if (dailyLimit()) {
        result.put(
            "ERROR",
            "Sorry, we have reached the preview limit for today.<BR>Please try back again tomorrow.");
        log(ERROR, "DAILY LIMIT REACHED: " + dailyCounter + " limit is: " + dailyLimit);
        return result;
      }
    }

    try {
      log(INFO, "Performing spinup for: " + loginCredentials.getUsername());
      result =
          spinupController.performSpinup(
              loginCredentials,
              secret,
              transportToken,
              RuntimeAccess.getInstance().getResponse(),
              false);
      recordUserLog(loginCredentials.getUsername());
      log(INFO, "Counter now: " + ++counter);
    } catch (CloudFoundryException cfe) {
      log(ERROR, "Failed to Launch Studio " + cfe.getMessage() + " " + cfe.toString());
      String msg = cfe.toString();
      if (msg.contains("Not enough memory capacity")) {
        String allowed = msg.substring(msg.indexOf("(") + 1, msg.indexOf(")"));
        result.put(
            "ERROR",
            "Insufficent memory to deploy studio to your account.<BR> "
                + allowed
                + "<BR>512M is required to start Studio.");
      } else {
        result.put(
            "ERROR", "Unable to deploy studio to your account.<BR> " + "Cause: " + cfe.toString());
      }
    } catch (Exception e) {
      log(ERROR, "Studio Launch has failed", e);
      result.put("ERROR", "Unable to deploy studio. " + e.getMessage());
      log(ERROR, e.getMessage());
    }
    return result;
  }