Package com.piercey.app.entities

Examples of com.piercey.app.entities.Account


    final List<?> result = query.list();

    if (result.size() == 0)
    {
      final Account account = new Account(username, password, "buddy@waddya.at");
      final RandomNumberGenerator random = new SecureRandomNumberGenerator();

      account.setSalt(random.nextBytes().toBase64());
      account.setPassword(new Sha256Hash(account.getPassword(), account.getSalt(), 1024).toBase64());

      session.save(account);
    }
  }
View Full Code Here


  public static boolean SaveAccount(Account account)
  {
    logger.executionTrace();
   
    final Session session = DatabaseUtil.getSessionFactory().getCurrentSession();
    final Account existingAccount = getAccount(session, account.getUsername());

    if (existingAccount == null)
    {
      final RandomNumberGenerator random = new SecureRandomNumberGenerator();
      account.setSalt(random.nextBytes().toBase64());
      account.setPassword(new Sha256Hash(account.getPassword(), account.getSalt(), 1024).toBase64());
    }
    else
    {
      // Don't allow password changes during an account update.
      account.setPassword(existingAccount.getPassword());
    }

    if (!session.getTransaction().isActive())
      session.getTransaction().begin();
View Full Code Here

    if (principals.fromRealm(getName()).isEmpty())
      return null;

    final String username = (String) principals.fromRealm(getName()).iterator().next();
    final Account account = getAccount(username);

    if (account == null)
      return null;

    final SimpleAuthorizationInfo authorizationInfo = new SimpleAuthorizationInfo();

    for (Role role : account.getRoles())
      authorizationInfo.addRole(role.getRoleName());

    return authorizationInfo;
  }
View Full Code Here

  protected Set<String> getRoleNamesForUser(Connection conn, String username) throws SQLException
  {
    logger.executionTrace();

    final Set<String> roleNames = new HashSet<String>();
    final Account account = getAccount(username);

    if (account != null)
      for (Role role : account.getRoles())
        roleNames.add(role.getRoleName());

    return roleNames;
  }
View Full Code Here

TOP

Related Classes of com.piercey.app.entities.Account

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.