Package org.internna.ossmoney.model.security

Examples of org.internna.ossmoney.model.security.UserDetails


  }

  @Test
  public void testCreateUser() throws NoSuchAlgorithmException, UnsupportedEncodingException {
    Dashboard dashboard = service.createDashBoDashboard();
    UserDetails user = service.createUser("foobar", "baz", "Foo Bar", "foo@bar.es", dashboard);
    assertNotNull("User created", user);
    assertEquals("Password encoded", StringUtils.SHA1("finance", "baz"), user.getPassword());
    assertNotNull("Budget created", user.getBudget());
    SecurityUtils.authenticate(authenticationManager, "foobar", "baz");
    assertNotNull("Payee created", Payee.findByName(user.getName()));
    assertEquals("Twelve months", 12, user.getBudget().getBudgets().size());
  }
View Full Code Here


  protected void setMessageSource(final MessageSource messageSource) {
    this.messageSource = messageSource;
  }

  @Override public void createInstitution(String name, String web, String icon) {
    UserDetails user = UserDetails.findCurrentUser();
    createInstitution(user, name, web, icon);
  }
View Full Code Here

      createPayee(owner, name);
    }
  }

  @Override public void createPayee(String name) {
    UserDetails user = UserDetails.findCurrentUser();
    createPayee(user, name);
  }
View Full Code Here

  private CacheStore cache;

  @Before
  public void init() {
    cache = new CacheStore();
    user = new UserDetails();
    user.setId(1L);
  }
View Full Code Here

    logger.info("Registered new user[" + username + "]");
  }

  protected UserDetails createUser(String username, String password, String name, String email, Dashboard dashboard) {
    Authority authority = Authority.findByName(Authority.ROLE_USER);
    UserDetails user = new UserDetails();
    user.setSalt(salt);
    user.setName(name);
    user.setEmail(email);
    user.setUsername(username);
    user.setPassword(password);
    user.setDashboard(dashboard);
    user.setEnabled(Boolean.TRUE);
    user.getRoles().add(authority);
    authority.getUsers().add(user);
    user.persist();
    adminService.createPayee(user, user.getName());
    createSubcategories(user);
    user.setBudget(createBudget(user));
    if (createBasicSpanishFinancialInstitutions) {
      createBasicSpanishInstitutions(user);
    }
    authority.merge();
    user.merge();
    return user;
  }
View Full Code Here

@Component
@Transactional
public final class AccountService implements org.internna.ossmoney.services.AccountService {

    @Override public void transferMoney(Long origin, Long target, Date operationDate, BigDecimal amount, BigDecimal chargeAmount, double rate, String memo) {
        UserDetails user = UserDetails.findCurrentUser();
        Account originAccount = Account.findAccount(origin);
        Account targetAccount = Account.findAccount(target);
        transferMoney(user, originAccount, targetAccount, operationDate, amount, chargeAmount, rate, memo);
    }
View Full Code Here

        return isValidTransaction(user, origin, operationDate, amount) && isValidTransaction(user, target, operationDate, amount);
    }

    @Override public long addTransaction(AccountTransaction transaction) {
        long accountId = -1;
        UserDetails user = UserDetails.findCurrentUser();
        if (transaction.getAccount() != null) {
            accountId = transaction.getAccount().getId();
            Account account = Account.findAccount(accountId);
            if (isValidTransaction(user, account, transaction.getOperationDate(), transaction.getAmount())) {
                transaction.setAccount(account);
View Full Code Here

        if (account != null) {
            Date now = new Date();
            account.setCreated(now);
            account.setLastModified(now);
            account.setClosed(Boolean.FALSE);
            UserDetails user = UserDetails.findCurrentUser();
            user.addAccount(account);
            if (account.getFavorite() == null) {
                account.setFavorite(Boolean.FALSE);
            }
            if (account.getAccountType() != null) {
                account.setAccountType(AccountType.entityManager().getReference(AccountType.class, account.getAccountType().getId()));
            }
            if (account.getHeldAt() != null) {
              FinancialInstitution institution = FinancialInstitution.findFinancialInstitution(account.getHeldAt().getId());
                institution.addAccount(account);
            }
            if ((account.getInitialBalance() == null) || (account.getInitialBalance().doubleValue() < 0)) {
                account.setInitialBalance(BigDecimal.ZERO);
            }
            account.persist();
            user.merge();
        }
    }
View Full Code Here

  private UserDetails owner;
  @Autowired private BillDataOnDemand dod;

  @Before
  public void setup() {
    owner = new UserDetails();
    owner.setName("Name");
    owner.setUsername("name");
    owner.setPassword("password");
    owner.setEnabled(Boolean.FALSE);
    owner.setDashboard(Dashboard.findDashboard(1L));
View Full Code Here

    owner.persist();
  }

  @Test
  public void testFindByOwner() {
    UserDetails other = UserDetails.findUserDetails(2L);
    Bill bill = dod.getRandomBill();
    Bill bill2 = dod.getRandomBill();
    Bill bill3 = dod.getRandomBill();
    for (Bill all : Bill.findAllBills()) {
      all.setOwner(UserDetails.findUserDetails(1L));all.merge();
View Full Code Here

TOP

Related Classes of org.internna.ossmoney.model.security.UserDetails

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.