Examples of JpaAccount


Examples of ch.entwine.weblounge.security.sql.entities.JpaAccount

   *
   * @see ch.entwine.weblounge.common.security.DirectoryService#loadUser(java.lang.String,
   *      ch.entwine.weblounge.common.site.Site)
   */
  public User loadUser(String login, Site site) {
    JpaAccount jpaAccount = null;

    // Load the user account and the user
    try {
      jpaAccount = persistence.getAccount(site.getIdentifier(), login, true);
    } catch (Throwable e) {
      logger.error("Error loading user '{}' from the database: {}", login, e.getMessage());
      return null;
    }

    // Is that user known
    if (jpaAccount == null) {
      logger.debug("User '{}' is not known in site '{}'", login, site.getIdentifier());
      return null;
    }

    // Create the weblounge user

    WebloungeUser user = new WebloungeUserImpl(login, site.getIdentifier());

    // Standard attributes like first name, name, ...
    if (StringUtils.isNotBlank(jpaAccount.getFirstname()))
      user.setFirstName(jpaAccount.getFirstname());
    if (StringUtils.isNotBlank(jpaAccount.getLastname()))
      user.setLastName(jpaAccount.getLastname());
    if (StringUtils.isNotBlank(jpaAccount.getEmail()))
      user.setEmail(jpaAccount.getEmail());
    if (StringUtils.isNotBlank(jpaAccount.getInitials()))
      user.setInitials(jpaAccount.getInitials());

    // Password
    user.addPrivateCredentials(new PasswordImpl(jpaAccount.getPassword(), DigestType.md5));

    // Roles
    for (JpaRole r : jpaAccount.getRoles()) {

      // Make sure weblounge roles get special treatment in order
      // to support role inheritance. Other directories will need
      // to implement this through a LoginListener implementation
      if (Security.SYSTEM_CONTEXT.equals(r.getContext())) {
View Full Code Here

Examples of ch.entwine.weblounge.security.sql.entities.JpaAccount

      throws Exception {
    if (StringUtils.isBlank(login))
      throw new IllegalArgumentException("Login must not be blank");
    if (StringUtils.isBlank(activationCode))
      throw new IllegalArgumentException("Activation code must not be blank");
    JpaAccount account = persistence.getAccount(site.getIdentifier(), login, true);
    if (account == null)
      return false;
    if (!activationCode.equals(account.getActivationCode()))
      return false;

    account.setEnabled(true);
    account.setActivationCode(null);
    persistence.updateAccount(account);
    logger.info("Account '{}' has been activated", login);
    return true;
  }
View Full Code Here

Examples of ch.entwine.weblounge.security.sql.entities.JpaAccount

    TypedQuery<JpaAccount> query = null;
    query = entityManager.createNamedQuery("getAccount", JpaAccount.class);
    query.setParameter("siteId", site);
    query.setParameter("userId", login);

    JpaAccount jpaAccount = null;

    try {
      jpaAccount = query.getSingleResult();
      logger.debug("User account already exists for user '{}'", login);
    } catch (NoResultException e) {
      JpaSite jpaSite = registerSite(site);
      jpaAccount = new JpaAccount(jpaSite, login, password);
      entityManager.persist(jpaAccount);
      logger.info("User account '{}@{}' created", login, site);
    }

    return jpaAccount;
View Full Code Here

Examples of ch.entwine.weblounge.security.sql.entities.JpaAccount

   * @see ch.entwine.weblounge.security.sql.SQLDirectoryProviderPersistence#removeAccount(java.lang.String,
   *      java.lang.String)
   */
  @Override
  public void removeAccount(String site, String login) throws Exception {
    JpaAccount jpaAccount = getAccount(site, login, false);
    if (jpaAccount == null)
      return;
    entityManager.remove(jpaAccount);
    logger.info("User account '{}@{}' removed", login, site);
  }
View Full Code Here

Examples of ch.entwine.weblounge.security.sql.entities.JpaAccount

   * @see ch.entwine.weblounge.security.sql.SQLDirectoryProviderPersistence#isAccountEnabled(java.lang.String,
   *      java.lang.String)
   */
  @Override
  public boolean isAccountEnabled(String site, String user) throws Exception {
    JpaAccount jpaAccount = getAccount(site, user, false);
    if (jpaAccount == null)
      throw new IllegalStateException("Account does not exist");
    return jpaAccount.isEnabled();
  }
View Full Code Here

Examples of ch.entwine.weblounge.security.sql.entities.JpaAccount

   * @param enable
   *          <code>true</code> to enable the account
   */
  private void toggleAccount(String site, String user, boolean enable)
      throws Exception {
    JpaAccount jpaAccount = getAccount(site, user, false);
    if (jpaAccount == null)
      throw new IllegalStateException("Account does not exist");
    jpaAccount.setEnabled(enable);
    entityManager.persist(jpaAccount);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.