Package ch.entwine.weblounge.common.security

Examples of ch.entwine.weblounge.common.security.Password


   */
  @Override
  public boolean equals(Object o) {
    if (!(o instanceof Password))
      return false;
    Password pw = (Password) o;
    DigestType digestType = pw.getDigestType();
    switch (digestType) {
      case md5:
        return md5.equals(pw.getPassword());
      case plain:
        try {
          return md5.equals(DigestUtils.md5(pw.getPassword().getBytes("utf-8")));
        } catch (UnsupportedEncodingException e) {
          throw new IllegalStateException(e);
        }
      default:
        throw new IllegalStateException("Found unknown digest type " + digestType);
View Full Code Here


    String password = XPathHelper.valueOf(userNode, "security/password", xpath);
    if (password != null) {
      String digestType = null;
      try {
        digestType = XPathHelper.valueOf(userNode, "security/password/@type", xpath);
        Password pw = new PasswordImpl(password, DigestType.valueOf(digestType));
        user.addPrivateCredentials(pw);
      } catch (Throwable t) {
        throw new IllegalStateException("Unknown password digest found: " + digestType);
      }
    }
View Full Code Here

    b.append("<security>");

    // Password
    Set<Object> passwords = getPrivateCredentials(Password.class);
    for (Object o : passwords) {
      Password password = (Password) o;
      b.append("<password type=\"");
      b.append(password.getDigestType().toString());
      b.append("\"><![CDATA[");
      b.append(password.getPassword());
      b.append("]]></password>");
    }

    // Roles
    Set<Object> roles = getPublicCredentials(Role.class);
View Full Code Here

    String password = XPathHelper.valueOf(userNode, "ns:password", xpath);
    if (password != null) {
      String digestType = null;
      try {
        digestType = XPathHelper.valueOf(userNode, "ns:password/@type", xpath);
        Password pw = new PasswordImpl(password, DigestType.valueOf(digestType));
        user.addPrivateCredentials(pw);
      } catch (Throwable t) {
        throw new IllegalStateException("Unknown password digest found: " + digestType);
      }
    }
View Full Code Here

    b.append("<login>").append(login).append("</login>");

    // Password
    Set<Object> passwords = getPrivateCredentials(Password.class);
    for (Object o : passwords) {
      Password password = (Password)o;
      b.append("<password type=\"");
      b.append(password.getDigestType().toString());
      b.append("\"><![CDATA[");
      b.append(password.getPassword());
      b.append("]]></password>");
    }

    // First name
    if (firstName != null) {
View Full Code Here

        throw new DataRetrievalFailureException("User '" + user + "' has no password");
      }

      // Create the password according to the site's and Spring Security's
      // digest policy
      Password p = (Password) passwords.iterator().next();
      String password = null;
      switch (site.getDigestType()) {
        case md5:
          if (!DigestType.md5.equals(p.getDigestType())) {
            logger.debug("Creating digest password for '{}@{}'", name, site.getIdentifier());
            password = PasswordEncoder.encode(p.getPassword());
          } else {
            password = p.getPassword();
          }
          break;
        case plain:
          if (!DigestType.plain.equals(p.getDigestType())) {
            logger.warn("User '{}@{}' does not have a plain text password'", name, site.getIdentifier());
            return null;
          }
          password = p.getPassword();
          break;
        default:
          throw new IllegalStateException("Unknown digest type '" + site.getDigestType() + "'");
      }
View Full Code Here

        throw new ConfigurationException(OPT_ADMIN_DIGEST, digest);
      }
    }

    if (StringUtils.isNotBlank(pass)) {
      Password password = new PasswordImpl(StringUtils.trimToEmpty(pass), digestType);
      administrator.addPrivateCredentials(password);
    }

    // Add the roles
    for (Role role : SystemRole.SYSTEMADMIN.getClosure()) {
View Full Code Here

    assertEquals(administratorLogin, site.getAdministrator().getLogin());
    assertTrue(site.getAdministrator().canLogin());
   
    Set<Object> passwords = site.getAdministrator().getPrivateCredentials(Password.class);
    for (Object o : passwords) {
      Password password = (Password)o;
      assertEquals(administratorPassword, password.getPassword());
    }
  }
View Full Code Here

TOP

Related Classes of ch.entwine.weblounge.common.security.Password

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.