Пример #1
0
 /**
  * Authenticate a user based on a username and password.
  *
  * @param username
  * @param password
  * @return a user object or null
  */
 @Override
 public UserModel authenticate(String username, char[] password) {
   Properties allUsers = read();
   String userInfo = allUsers.getProperty(username);
   if (StringUtils.isEmpty(userInfo)) {
     return null;
   }
   UserModel returnedUser = null;
   UserModel user = getUserModel(username);
   if (user.password.startsWith(StringUtils.MD5_TYPE)) {
     // password digest
     String md5 = StringUtils.MD5_TYPE + StringUtils.getMD5(new String(password));
     if (user.password.equalsIgnoreCase(md5)) {
       returnedUser = user;
     }
   } else if (user.password.startsWith(StringUtils.COMBINED_MD5_TYPE)) {
     // username+password digest
     String md5 =
         StringUtils.COMBINED_MD5_TYPE
             + StringUtils.getMD5(username.toLowerCase() + new String(password));
     if (user.password.equalsIgnoreCase(md5)) {
       returnedUser = user;
     }
   } else if (user.password.equals(new String(password))) {
     // plain-text password
     returnedUser = user;
   }
   return returnedUser;
 }
Пример #2
0
  public GravatarImage(String id, PersonIdent person, int width) {
    super(id);

    String email =
        person.getEmailAddress() == null
            ? person.getName().toLowerCase()
            : person.getEmailAddress().toLowerCase();
    String hash = StringUtils.getMD5(email);
    Link<Void> link =
        new BookmarkablePageLink<Void>(
            "link", GravatarProfilePage.class, WicketUtils.newObjectParameter(hash));
    link.add(new SimpleAttributeModifier("target", "_blank"));
    String url = ActivityUtils.getGravatarThumbnailUrl(email, width);
    ExternalImage image = new ExternalImage("image", url);
    WicketUtils.setCssClass(image, "gravatar");
    link.add(image);
    WicketUtils.setHtmlTooltip(
        link, MessageFormat.format("View Gravatar profile for {0}", person.getName()));
    add(link);
    setVisible(GitBlit.getBoolean(Keys.web.allowGravatar, true));
  }