예제 #1
0
 @Override
 public void addUser(
     CallingContext context,
     String userName,
     String description,
     String hashPassword,
     String email) {
   checkParameter("User", userName); // $NON-NLS-1$
   // Does the user already exist?
   RaptureUser usr = getUser(context, userName);
   if (usr == null) {
     usr = new RaptureUser();
     usr.setUsername(userName);
     usr.setDescription(description);
     usr.setHashPassword(hashPassword);
     usr.setEmailAddress(email);
     RaptureUserHelper.validateSalt(usr);
     usr.setInactive(false);
     RaptureUserStorage.add(
         usr, context.getUser(), Messages.getString("Admin.AddedUser") + userName); // $NON-NLS-1$
   } else {
     throw RaptureExceptionFactory.create(
         HttpURLConnection.HTTP_BAD_REQUEST,
         Messages.getString("Admin.UserAlreadyExists")); // $NON-NLS-1$
   }
 }
예제 #2
0
  @Override
  public RaptureUser generateApiUser(CallingContext context, String prefix, String description) {
    // Special treatment of prefix "debug"
    checkParameter("Prefix", prefix); // $NON-NLS-1$

    String userId = "zz-" + prefix; // $NON-NLS-1$

    if (!prefix.equals("debug")) { // $NON-NLS-1$
      userId = prefix + "-" + IDGenerator.getUUID(); // $NON-NLS-1$
    }
    RaptureUser usr = new RaptureUser();
    usr.setUsername(userId);
    usr.setDescription(description);
    usr.setHashPassword(""); // $NON-NLS-1$
    usr.setInactive(false);
    usr.setApiKey(true);
    RaptureUserStorage.add(
        usr, context.getUser(), Messages.getString("Admin.CreatedApi")); // $NON-NLS-1$
    return usr;
  }