Package com.tmm.enterprise.microblog.security

Examples of com.tmm.enterprise.microblog.security.Account


   * @return
   * @throws Exception
   */
  @RequestMapping
  public ModelAndView latestUserActivity(@RequestParam String userName,@RequestParam(defaultValue="0") Long latestId,@RequestParam Integer pageNum,HttpServletRequest request) throws Exception {
    Account acc = accountService.loadAccountByUserName(userName);
    Person currentUser = acc.getUserProfile();
    List<Activity> latest = activityService.loadLatestPublicStatus(currentUser, pageNum);
    JsonObject returnObj = new JsonObject();
    if (!latest.isEmpty()) {
      JsonArray array = new JsonArray();
      boolean startRecording = (latestId == 0l);
View Full Code Here


   * @param password
   */
  @Transactional
  public Account createNewUser(String name, String email, String password,
      String firstName, String lastName, String role) {
    Account account = loadAccountByUserName(name);
    if (account == null) {
      account = new Account();
      Role r = loadOrCreateRole(role);
      account.addRole(r);
      account.setUserName(name);
      account.setEmail(email);
      account.setFirstName(firstName);
      account.setLastName(lastName);
      Person userProf = new Person();
      userProf.setRole(UserRole.MEMBER);
      userProf.setLinkedAccount(account);
      account.setUserProfile(userProf);

      getAccountDAO().persist(account);

      // now update password once we have the account created (we need the
      // ID to have been generated)
      account.setAndEncodePassword(password);
      // account = getAccountDAO().merge(account);
    }

    return account;
  }
View Full Code Here

   * @param password
   */
  @Transactional
  public Account createNewFullAdminUser(String name, String email,
      String password, String firstName, String lastName) {
    Account account = loadAccountByUserName(name);
    if (account == null) {
      account = new Account();
      Role r = loadOrCreateRole(Role.ROLE_ADMIN);
      account.addRole(r);
      account.setUserName(name);
      account.setEmail(email);
      account.setFirstName(firstName);
      account.setLastName(lastName);
      Person userProf = new Person();
      userProf.setRole(UserRole.MEMBER);
      userProf.setLinkedAccount(account);
      account.setUserProfile(userProf);

      getAccountDAO().persist(account);

      // now update password once we have the account created (we need the
      // ID to have been generated)
      account.setAndEncodePassword(password);
      // getAccountDAO().merge(account);
    }

    return account;
  }
View Full Code Here

  }

  @Transactional
  public Account createNewBatchUser(String name, String email,
      String password, String firstName, String lastName) {
    Account account = loadAccountByUserName(name);
    if (account == null) {
      account = new Account();
      Role r = loadOrCreateRole(Role.ROLE_ADMIN);
      account.addRole(r);
      account.setUserName(name);
      account.setEmail(email);
      account.setFirstName(firstName);
      account.setLastName(lastName);

      getAccountDAO().persist(account);

      // now update password once we have the account created (we need the
      // ID to have been generated)
      account.setAndEncodePassword(password);
      // getAccountDAO().merge(account);
    }

    return account;
  }
View Full Code Here

   * @param request
   * @return
   */
  public Account getAccount(HttpServletRequest request) {
    String userName = request.getRemoteUser();
    Account acc = loadAccountByUserName(userName);
    return acc;
  }
View Full Code Here

   *
   * @param request
   * @return
   */
  public Person getPerson(HttpServletRequest request) {
    Account acc = getAccount(request);
    Person person = acc.getUserProfile();
    return person;
  }
View Full Code Here

    return person;
  }

  @Transactional
  public void setCredentials() {
    Account account = loadAccountByUserName("admin");
    if (account == null) {
      account = createNewAdminUser("admin", "", "admin");
    }
    GrantedAuthority[] auths = new GrantedAuthority[1];
    auths[0] = new GrantedAuthorityImpl("ROLE_ADMIN");
    ApplicationUser user = new ApplicationUser(new Long(account.getId()),
        account.getUserName(), account.getPassword(), true, true, true,
        true, auths);
    Authentication auth = new TestingAuthenticationToken(user, "ignored",
        auths);
    auth.setAuthenticated(true);
    SecurityContextHolder.getContext().setAuthentication(auth);
View Full Code Here

    this.notifications.remove(n);
  }

  @PrePersist
  public void distributeNotifications() {
    Account acc = ApplicationService.getInstance().getModifyingAccount();
    Person user = acc.getUserProfile();
    List<Person> notified = new ArrayList<Person>();

    if (this.getObjectType().equals(ObjectType.TODO)) {
      createNotification(user, notified);
View Full Code Here

    return getEntityManager().find(Contactable.class, id);
  }

  @Transactional
  public Contactable loadContactableByName(String contactName) throws ButterflyException {
    Account acc = accountService.loadAccountByUserName(contactName);
    if (acc != null) {
      Person user = acc.getUserProfile();
      if (user != null) {
        return user;
      }
    }
View Full Code Here

   *            - target Contactable ID
   * @throws ButterflyException
   */
  @Transactional
  public void connect(String userName, long connectId) throws ButterflyException {
    Account acc = accountService.loadAccountByUserName(userName);
    if (acc != null) {
      Person user = acc.getUserProfile();
      if (user != null) {
        Contactable c = loadContactable(connectId);
        user.addFollowing(c);
      } else {
        throw new ButterflyException(ButterflyExceptionCode.CONTACT002_ERRORMAKINGCONNECTION, "Error making connection: ");
View Full Code Here

TOP

Related Classes of com.tmm.enterprise.microblog.security.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.