Пример #1
0
 @Override
 public void cancelPasswordResetToken(CallingContext context, String username) {
   checkParameter("User", username);
   RaptureUser user = getUser(context, username);
   if (user == null) {
     throw RaptureExceptionFactory.create(
         HttpURLConnection.HTTP_BAD_REQUEST,
         Messages.getString("Admin.NoExistUser")); // $NON-NLS-1$
   }
   // expire token now
   user.setTokenExpirationTime(System.currentTimeMillis());
   RaptureUserStorage.add(
       user, context.getUser(), "Cancel password reset token for user " + username); // $NON-NLS-1$
 }
Пример #2
0
 @Override
 public String createPasswordResetToken(CallingContext context, String username) {
   checkParameter("User", username);
   RaptureUser user = getUser(context, username);
   if (user == null) {
     throw RaptureExceptionFactory.create(
         HttpURLConnection.HTTP_BAD_REQUEST,
         Messages.getString("Admin.NoExistUser")); // $NON-NLS-1$
   }
   String token = generateSecureToken();
   user.setPasswordResetToken(token);
   user.setTokenExpirationTime(DateTime.now().plusDays(1).getMillis());
   RaptureUserStorage.add(
       user,
       context.getUser(),
       "Generate password reset token for user " + username); // $NON-NLS-1$
   return token;
 }