shiro(4)-银行示例

时间:2022-05-05
本文章向大家介绍shiro(4)-银行示例,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

在官方的示例中,有一个aspectj的示例,这个是一个银行的示例,简单的做了一下修改,演示一下其中几个方法的使用过程。

看以下几个类,包括账户信息,转账信息,以及一些异常处理程序,还包括一个业务操作类

Account账户信息类

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class Account {

    private static long _SEQUENCE;

    private long _id;

    private String _ownerName;

    private volatile boolean _isActive;

    private double _balance;

    private final List<AccountTransaction> _transactions;

    private String _createdBy;

    private Date _creationDate;

    public Account(String anOwnerName) {
        _id = ++_SEQUENCE;
        _ownerName = anOwnerName;
        _isActive = true;
        _balance = 0.0d;
        _transactions = new ArrayList<AccountTransaction>();
        _createdBy = "unknown";
        _creationDate = new Date();
    }

    /**
     * Returns the id attribute.
     *
     * @return The id value.
     */
    public long getId() {
        return _id;
    }

    /**
     * Returns the ownerName attribute.
     *
     * @return The ownerName value.
     */
    public String getOwnerName() {
        return _ownerName;
    }

    /**
     * Returns the isActive attribute.
     *
     * @return The isActive value.
     */
    public boolean isActive() {
        return _isActive;
    }

    /**
     * Changes the value of the attributes isActive.
     *
     * @param aIsActive The new value of the isActive attribute.
     */
    public void setActive(boolean aIsActive) {
        _isActive = aIsActive;
    }

    /**
     * Changes the value of the attributes ownerName.
     *
     * @param aOwnerName The new value of the ownerName attribute.
     */
    public void setOwnerName(String aOwnerName) {
        _ownerName = aOwnerName;
    }

    /**
     * Returns the balance attribute.
     *
     * @return The balance value.
     */
    public double getBalance() {
        return _balance;
    }

    /**
     * Returns the transactions attribute.
     *
     * @return The transactions value.
     */
    public List<AccountTransaction> getTransactions() {
        return _transactions;
    }

    protected void applyTransaction(AccountTransaction aTransaction) throws NotEnoughFundsException, InactiveAccountException {
        if (!_isActive) {
            throw new InactiveAccountException("Unable to apply " + aTransaction.getType() + " of amount " + aTransaction.getAmount() + " to account " + _id);
        }

        synchronized (_transactions) {
            if (AccountTransaction.TransactionType.DEPOSIT == aTransaction.getType()) {
                _transactions.add(aTransaction);
                _balance += aTransaction.getAmount();

            } else if (AccountTransaction.TransactionType.WITHDRAWAL == aTransaction.getType()) {
                if (_balance < aTransaction.getAmount()) {
                    throw new NotEnoughFundsException("Unable to withdraw " + aTransaction.getAmount() + "$ from account " + _id + " - current balance is " + _balance);
                }
                _transactions.add(aTransaction);
                _balance -= aTransaction.getAmount();

            } else {
                throw new IllegalArgumentException("The transaction passed in has an invalid type: " + aTransaction.getType());
            }
        }
    }

    /**
     * Changes the value of the attributes createdBy.
     *
     * @param aCreatedBy The new value of the createdBy attribute.
     */
    protected void setCreatedBy(String aCreatedBy) {
        _createdBy = aCreatedBy;
    }

    /**
     * Returns the createdBy attribute.
     *
     * @return The createdBy value.
     */
    public String getCreatedBy() {
        return _createdBy;
    }

    /**
     * Returns the creationDate attribute.
     *
     * @return The creationDate value.
     */
    public Date getCreationDate() {
        return _creationDate;
    }

    /* (non-Javadoc)
    * @see java.lang.Object#toString()
    */

    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).
                append("id", _id).
                append("ownerName", _ownerName).
                append("isActive", _isActive).
                append("balance", _balance).
                append("tx.count", _transactions.size()).
                append("createdBy", _createdBy).
                append("creationDate", new Timestamp(_creationDate.getTime())).
                toString();
    }
}

AccountNotFoundException,账号不存在异常

package org.apache.shiro.samples.aspectj.bank;

public class AccountNotFoundException extends BankServiceException {

    public AccountNotFoundException(String aMessage) {
        super(aMessage);
    }

}

AccountTransaction,账号转入与转出

package org.apache.shiro.samples.aspectj.bank;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import java.sql.Timestamp;
import java.util.Date;

public class AccountTransaction {

    private static long _SEQUENCE;

    public enum TransactionType {
        DEPOSIT,
        WITHDRAWAL
    }

    private long _id;

    private TransactionType _type;

    private long _accountId;

    private double _amount;

    private String _createdBy;
    private Date _creationDate;

    public static AccountTransaction createDepositTx(long anAccountId, double anAmount) {
        return new AccountTransaction(TransactionType.DEPOSIT, anAccountId, anAmount);
    }

    public static AccountTransaction createWithdrawalTx(long anAccountId, double anAmount) {
        return new AccountTransaction(TransactionType.WITHDRAWAL, anAccountId, anAmount);
    }

    private AccountTransaction(TransactionType aType, long anAccountId, double anAmount) {
        _id = ++_SEQUENCE;
        _type = aType;
        _accountId = anAccountId;
        _amount = anAmount;
        _createdBy = "unknown";
        _creationDate = new Date();
    }

    /**
     * Returns the id attribute.
     *
     * @return The id value.
     */
    public long getId() {
        return _id;
    }

    /**
     * Returns the type attribute.
     *
     * @return The type value.
     */
    public TransactionType getType() {
        return _type;
    }

    /**
     * Returns the accountId attribute.
     *
     * @return The accountId value.
     */
    public long getAccountId() {
        return _accountId;
    }

    /**
     * Returns the amount attribute.
     *
     * @return The amount value.
     */
    public double getAmount() {
        return _amount;
    }

    /**
     * Changes the value of the attributes createdBy.
     *
     * @param aCreatedBy The new value of the createdBy attribute.
     */
    protected void setCreatedBy(String aCreatedBy) {
        _createdBy = aCreatedBy;
    }

    /**
     * Returns the createdBy attribute.
     *
     * @return The createdBy value.
     */
    public String getCreatedBy() {
        return _createdBy;
    }

    /**
     * Returns the creationDate attribute.
     *
     * @return The creationDate value.
     */
    public Date getCreationDate() {
        return _creationDate;
    }

    /* (non-Javadoc)
    * @see java.lang.Object#toString()
    */

    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).
                append("id", _id).
                append("type", _type).
                append("accountId", _accountId).
                append("amount", _amount).
                append("createdBy", _createdBy).
                append("creationDate", new Timestamp(_creationDate.getTime())).
                toString();
    }

}

BankServerRunner,银行服务运行

package org.apache.shiro.samples.aspectj.bank;

public class BankServerRunner {

    private SecureBankService _bankService;

    public synchronized void start() throws Exception {
        if (_bankService == null) {
            _bankService = new SecureBankService();
            _bankService.start();
        }
    }

    public synchronized void stop() {
        if (_bankService != null) {
            try {
                _bankService.dispose();
            } finally {
                _bankService = null;
            }
        }
    }

    public BankService getBankService() {
        return _bankService;
    }

    public static void main(String[] args) {
        try {
            BankServerRunner server = new BankServerRunner();
            server.start();

            server.stop();

        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}

 BankService,银行服务接口

package org.apache.shiro.samples.aspectj.bank;

import java.util.Date;

public interface BankService {

    public long[] searchAccountIdsByOwner(String anOwnerName);

    public long createNewAccount(String anOwnerName);

    public double getBalanceOf(long anAccountId) throws AccountNotFoundException;

    public String getOwnerOf(long anAccountId) throws AccountNotFoundException;

    public double depositInto(long anAccountId, double anAmount) throws AccountNotFoundException, InactiveAccountException;

    public double withdrawFrom(long anAccountId, double anAmount) throws AccountNotFoundException, NotEnoughFundsException, InactiveAccountException;

    public TxLog[] getTxHistoryFor(long anAccountId) throws AccountNotFoundException;

    public double closeAccount(long anAccountId) throws AccountNotFoundException, InactiveAccountException;

    public boolean isAccountActive(long anAccountId) throws AccountNotFoundException;

    public static class TxLog {
        private Date _creationDate;
        private double _amount;
        private String _madeBy;

        public TxLog(Date aCreationDate, double aAmount, String aMadeBy) {
            super();
            _creationDate = aCreationDate;
            _amount = aAmount;
            _madeBy = aMadeBy;
        }

        /**
         * Returns the creationDate attribute.
         *
         * @return The creationDate value.
         */
        public Date getCreationDate() {
            return _creationDate;
        }

        /**
         * Returns the amount attribute.
         *
         * @return The amount value.
         */
        public double getAmount() {
            return _amount;
        }

        /**
         * Returns the madeBy attribute.
         *
         * @return The madeBy value.
         */
        public String getMadeBy() {
            return _madeBy;
        }
    }

}

BankServiceException,银行服务异常

package org.apache.shiro.samples.aspectj.bank;

public class BankServiceException extends Exception {

    public BankServiceException(String aMessage) {
        super(aMessage);
    }

    public BankServiceException(String aMessage, Throwable aCause) {
        super(aMessage, aCause);
    }

}

InactiveAccountException,存入账户异常

package org.apache.shiro.samples.aspectj.bank;

public class InactiveAccountException extends BankServiceException {

    public InactiveAccountException(String aMessage) {
        super(aMessage);
    }

}

NotEnoughFundsException,账户不足异常

package org.apache.shiro.samples.aspectj.bank;

public class NotEnoughFundsException extends BankServiceException {

    public NotEnoughFundsException(String aMessage) {
        super(aMessage);
    }

}

SecureBankService,安全银行的服务类,处理各种银行的业务

package org.apache.shiro.samples.aspectj.bank;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.samples.aspectj.bank.AccountTransaction.TransactionType;
import org.apache.shiro.subject.Subject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class SecureBankService implements BankService {

    private static final Logger log = LoggerFactory.getLogger(SecureBankService.class);
    private volatile boolean _isRunning;
    private final List<Account> _accounts;
    private Map<Long, Account> _accountsById;

    /**
     * Creates a new {@link SecureBankService} instance.
     */
    public SecureBankService() {
        _accounts = new ArrayList<Account>();
        _accountsById = new HashMap<Long, Account>();
    }

    /**
     * Starts this service
     */
    public void start() throws Exception {
        _isRunning = true;
        log.info("银行服务开始...");
    }

    /**
     * Stop this service
     */
    public void dispose() {
        log.info("银行服务停止...");
        _isRunning = false;

        synchronized (_accounts) {
            _accountsById.clear();
            _accounts.clear();
        }

        log.info("银行服务停止!");
    }

    /**
     * Internal utility method that validate the internal state of this service.
     */
    protected void assertServiceState() {
        if (!_isRunning) {
            throw new IllegalStateException("银行的服务没有开始");
        }
    }

    public int getAccountCount() {
        return _accounts.size();
    }

    /* (non-Javadoc)
    * @see com.connectif.trilogy.root.security.BankService#createNewAccount(java.lang.String)
    */

    @RequiresPermissions("bankAccount:create")
    public long createNewAccount(String anOwnerName) {
        assertServiceState();
        log.info("创建新的账户给 " + anOwnerName);

        synchronized (_accounts) {
            Account account = new Account(anOwnerName);
            account.setCreatedBy(getCurrentUsername());
            _accounts.add(account);
            _accountsById.put(account.getId(), account);

            log.debug("创建新的账户: " + account);
            return account.getId();
        }
    }

    /* (non-Javadoc)
    * @see com.connectif.trilogy.root.security.BankService#searchAccountIdsByOwner(java.lang.String)
    */

    public long[] searchAccountIdsByOwner(String anOwnerName) {
        assertServiceState();
        log.info("查找已经存在的银行账户为 " + anOwnerName);

        ArrayList<Account> matchAccounts = new ArrayList<Account>();
        synchronized (_accounts) {
            for (Account a : _accounts) {
                if (a.getOwnerName().toLowerCase().contains(anOwnerName.toLowerCase())) {
                    matchAccounts.add(a);
                }
            }
        }

        long[] accountIds = new long[matchAccounts.size()];
        int index = 0;
        for (Account a : matchAccounts) {
            accountIds[index++] = a.getId();
        }

        log.debug("找到 " + accountIds.length + " 相匹配的账户的名称 " + anOwnerName);
        return accountIds;
    }

    /* (non-Javadoc)
    * @see com.connectif.trilogy.root.security.BankService#getOwnerOf(long)
    */

    @RequiresPermissions("bankAccount:read")
    public String getOwnerOf(long anAccountId) throws AccountNotFoundException {
        assertServiceState();
        log.info("获得银行账户的所有者 " + anAccountId);

        Account a = safellyRetrieveAccountForId(anAccountId);
        return a.getOwnerName();
    }

    /* (non-Javadoc)
    * @see com.connectif.trilogy.root.security.BankService#getBalanceOf(long)
    */

    @RequiresPermissions("bankAccount:read")
    public double getBalanceOf(long anAccountId) throws AccountNotFoundException {
        assertServiceState();
        log.info("得到账户的余额 " + anAccountId);

        Account a = safellyRetrieveAccountForId(anAccountId);
        return a.getBalance();
    }

    /* (non-Javadoc)
    * @see com.connectif.trilogy.root.security.BankService#depositInto(long, double)
    */

    @RequiresPermissions("bankAccount:operate")
    public double depositInto(long anAccountId, double anAmount) throws AccountNotFoundException, InactiveAccountException {
        assertServiceState();
        log.info("存钱到 " + anAmount + " 这个账户 " + anAccountId);

        try {
            Account a = safellyRetrieveAccountForId(anAccountId);
            AccountTransaction tx = AccountTransaction.createDepositTx(anAccountId, anAmount);
            tx.setCreatedBy(getCurrentUsername());
            log.debug("创建一个新的交易 " + tx);

            a.applyTransaction(tx);
            log.debug("新的账户余额 " + a.getId() + " 存款后 " + a.getBalance());

            return a.getBalance();

        } catch (NotEnoughFundsException nefe) {
            throw new IllegalStateException("应该从未发生过", nefe);
        }
    }

    /* (non-Javadoc)
    * @see com.connectif.trilogy.root.security.BankService#withdrawFrom(long, double)
    */

    @RequiresPermissions("bankAccount:operate")
    public double withdrawFrom(long anAccountId, double anAmount) throws AccountNotFoundException, NotEnoughFundsException, InactiveAccountException {
        assertServiceState();
        log.info("取款 " + anAmount + " 从账户 " + anAccountId);

        Account a = safellyRetrieveAccountForId(anAccountId);
        AccountTransaction tx = AccountTransaction.createWithdrawalTx(anAccountId, anAmount);
        tx.setCreatedBy(getCurrentUsername());
        log.debug("创建一个新的交易 " + tx);

        a.applyTransaction(tx);
        log.debug("新的账户余额 " + a.getId() + " 取款后 " + a.getBalance());

        return a.getBalance();
    }

    /* (non-Javadoc)
    * @see com.connectif.trilogy.root.security.BankService#getTxHistoryFor(long)
    */

    @RequiresPermissions("bankAccount:read")
    public TxLog[] getTxHistoryFor(long anAccountId) throws AccountNotFoundException {
        assertServiceState();
        log.info("获取账户交易 " + anAccountId);

        Account a = safellyRetrieveAccountForId(anAccountId);

        TxLog[] txs = new TxLog[a.getTransactions().size()];
        int index = 0;
        for (AccountTransaction tx : a.getTransactions()) {
            log.debug("查过交易 " + tx);

            if (TransactionType.DEPOSIT == tx.getType()) {
                txs[index++] = new TxLog(tx.getCreationDate(), tx.getAmount(), tx.getCreatedBy());
            } else {
                txs[index++] = new TxLog(tx.getCreationDate(), -1.0d * tx.getAmount(), tx.getCreatedBy());
            }
        }

        return txs;
    }

    /* (non-Javadoc)
    * @see com.connectif.trilogy.root.security.BankService#closeAccount(long)
    */

    @RequiresPermissions("bankAccount:close")
    public double closeAccount(long anAccountId) throws AccountNotFoundException, InactiveAccountException {
        assertServiceState();
        log.info("截止账户 " + anAccountId);

        Account a = safellyRetrieveAccountForId(anAccountId);
        if (!a.isActive()) {
            throw new InactiveAccountException("这个账户 " + anAccountId + " 已经关闭");
        }

        try {
            AccountTransaction tx = AccountTransaction.createWithdrawalTx(a.getId(), a.getBalance());
            tx.setCreatedBy(getCurrentUsername());
            log.debug("创建一个新的交易  " + tx);
            a.applyTransaction(tx);
            a.setActive(false);

            log.debug("账户 " + a.getId() + " 现在是关闭的 " + tx.getAmount() + " 针对这个业主");
            return tx.getAmount();

        } catch (NotEnoughFundsException nefe) {
            throw new IllegalStateException("应该从来不发生", nefe);
        }
    }

    /* (non-Javadoc)
    * @see com.connectif.trilogy.root.security.BankService#isAccountActive(long)
    */

    @RequiresPermissions("bankAccount:read")
    public boolean isAccountActive(long anAccountId) throws AccountNotFoundException {
        assertServiceState();
        log.info("获取账户的活动状态 " + anAccountId);

        Account a = safellyRetrieveAccountForId(anAccountId);
        return a.isActive();
    }


    /**
     * Internal method that safelly (concurrency-wise) retrieves an account from the id passed in.
     *
     * @param anAccountId The identifier of the account to retrieve.
     * @return The account instance retrieved.
     * @throws AccountNotFoundException If no account is found for the provided identifier.
     */
    protected Account safellyRetrieveAccountForId(long anAccountId) throws AccountNotFoundException {
        Account account = null;
        synchronized (_accounts) {
            account = _accountsById.get(anAccountId);
        }

        if (account == null) {
            throw new AccountNotFoundException("没有找到ID为 " + anAccountId + " 的账户");
        }

        log.info("检查账户 " + account);
        return account;
    }

    /**
     * Internal utility method to retrieve the username of the current authenticated user.
     *
     * @return The name.
     */
    protected String getCurrentUsername() {
        Subject subject = SecurityUtils.getSubject();
        if (subject == null || subject.getPrincipal() == null || !subject.isAuthenticated()) {
            throw new IllegalStateException("无法检索当前验证的主题");
        }
        return SecurityUtils.getSubject().getPrincipal().toString();
    }
}

在配置文件中配置了三组账户

[users]
root = secret, admin
sally = 1234, superviser
dan = 123, user

用户 root 密码secret 角色admin

用户 sally 密码1234 角色superviser

用户 dan密码123 角色user

角色信息包括

[roles]
admin = bankAccount:*
superviser = bankAccount:create, bankAccount:read bankAccount:close
user = bankAccount:create, bankAccount:read, bankAccount:operate

包括种种操作的权限分配

使用junit测试

@BeforeClass
	public static void setUpClass() throws Exception {
		BasicConfigurator.resetConfiguration();
		BasicConfigurator.configure();
		logger = Logger.getLogger(SecureBankServiceTest.class.getSimpleName());

		Factory<SecurityManager> factory = new IniSecurityManagerFactory(
				"classpath:shiroBankServiceTest.ini");
		SecurityManager securityManager = factory.getInstance();
		SecurityUtils.setSecurityManager(securityManager);

		service = new SecureBankService();
		service.start();
	}

加载对应的ini中的信息,在每次运行之前

登录用户的操作方法

// 作为用户登录,不能关闭账户
	protected void loginAsUser() {
		if (_subject == null) {
			_subject = SecurityUtils.getSubject();
		}

		// use dan to run as a normal user (which cannot close an account)
		_subject.login(new UsernamePasswordToken("dan", "123"));
	}

	// 作为超级用户登录,不能操作账户
	protected void loginAsSuperviser() {
		if (_subject == null) {
			_subject = SecurityUtils.getSubject();
		}

		// use sally to run as a superviser (which cannot operate an account)
		_subject.login(new UsernamePasswordToken("sally", "1234"));
	}

给张三创建账户,并且检查账户的情况

@Test
	public void testCreateAccount() throws Exception {
		loginAsUser();
		createAndValidateAccountFor("张三");
	}

protected long createAndValidateAccountFor(String anOwner) throws Exception {
		long createdId = service.createNewAccount(anOwner);
		assertAccount(anOwner, true, 0.0d, 0, createdId);
		return createdId;
	}

public static void assertAccount(String eOwnerName, boolean eIsActive,
			double eBalance, int eTxLogCount, long actualAccountId)
			throws Exception {
		Assert.assertEquals(eOwnerName, service.getOwnerOf(actualAccountId));
		Assert.assertEquals(eIsActive, service.isAccountActive(actualAccountId));
		Assert.assertEquals(eBalance, service.getBalanceOf(actualAccountId));
		Assert.assertEquals(eTxLogCount,
				service.getTxHistoryFor(actualAccountId).length);
	}

看打印出来的信息

1 [main] DEBUG org.apache.shiro.io.ResourceUtils  - Opening resource from class path [shiroBankServiceTest.ini]
10 [main] DEBUG org.apache.shiro.config.Ini  - Parsing [users]
12 [main] DEBUG org.apache.shiro.config.Ini  - Parsing [roles]
13 [main] DEBUG org.apache.shiro.config.IniFactorySupport  - Creating instance from Ini [sections=users,roles]
46 [main] DEBUG org.apache.shiro.realm.text.IniRealm  - Discovered the [roles] section.  Processing...
48 [main] DEBUG org.apache.shiro.realm.text.IniRealm  - Discovered the [users] section.  Processing...
59 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 银行服务开始...
62 [main] INFO SecureBankServiceTest  - 

#########################
### 开始测试用例 1

120 [main] DEBUG org.apache.shiro.authc.credential.SimpleCredentialsMatcher  - Performing credentials equality check for tokenCredentials of type [[C and accountCredentials of type [java.lang.String]
120 [main] DEBUG org.apache.shiro.authc.credential.SimpleCredentialsMatcher  - Both credentials arguments can be easily converted to byte arrays.  Performing array equals comparison
121 [main] DEBUG org.apache.shiro.authc.AbstractAuthenticator  - Authentication successful for token [org.apache.shiro.authc.UsernamePasswordToken - dan, rememberMe=false].  Returned account [dan]
121 [main] DEBUG org.apache.shiro.subject.support.DefaultSubjectContext  - No SecurityManager available in subject context map.  Falling back to SecurityUtils.getSecurityManager() lookup.
121 [main] DEBUG org.apache.shiro.subject.support.DefaultSubjectContext  - No SecurityManager available in subject context map.  Falling back to SecurityUtils.getSecurityManager() lookup.
122 [main] DEBUG org.apache.shiro.session.mgt.AbstractValidatingSessionManager  - No sessionValidationScheduler set.  Attempting to create default instance.
123 [main] INFO org.apache.shiro.session.mgt.AbstractValidatingSessionManager  - Enabling session validation scheduler...
132 [main] DEBUG org.apache.shiro.session.mgt.DefaultSessionManager  - Creating new EIS record for new session instance [org.apache.shiro.session.mgt.SimpleSession,id=null]
188 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建新的账户给 张三
203 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建新的账户: Account[id=1,ownerName=张三,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 20:40:26.71]
203 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获得银行账户的所有者 1
203 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=张三,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 20:40:26.71]
205 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户的活动状态 1
205 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=张三,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 20:40:26.71]
205 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
205 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=张三,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 20:40:26.71]
205 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
205 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=张三,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 20:40:26.71]
206 [main] DEBUG org.apache.shiro.mgt.DefaultSecurityManager  - Logging out subject with primary principal {}dan
206 [main] DEBUG org.apache.shiro.session.mgt.AbstractSessionManager  - Stopping session with id [66208001-e91d-4625-938f-1b1c08b2645c]
208 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 银行服务停止...
208 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 银行服务停止!

创建张三的用户信息并且检查张三的账户的情况。

第二个测试

创建账户李四并且存入250到账户里,用户有创建和操作的权限,所以可以操作

@Test
	public void testDepositInto_singleTx() throws Exception {
		loginAsUser();
		long accountId = createAndValidateAccountFor("李四");
		makeDepositAndValidateAccount(accountId, 250.00d, "李四");
	}
protected double makeDepositAndValidateAccount(long anAccountId,
   double anAmount, String eOwnerName) throws Exception {
  double previousBalance = service.getBalanceOf(anAccountId);
  int previousTxCount = service.getTxHistoryFor(anAccountId).length;
  double newBalance = service.depositInto(anAccountId, anAmount);
  Assert.assertEquals(previousBalance + anAmount, newBalance);
  assertAccount(eOwnerName, true, newBalance, 1 + previousTxCount,
    anAccountId);
  return newBalance;
 }

运行后的结果

0 [main] DEBUG org.apache.shiro.io.ResourceUtils  - Opening resource from class path [shiroBankServiceTest.ini]
9 [main] DEBUG org.apache.shiro.config.Ini  - Parsing [users]
12 [main] DEBUG org.apache.shiro.config.Ini  - Parsing [roles]
13 [main] DEBUG org.apache.shiro.config.IniFactorySupport  - Creating instance from Ini [sections=users,roles]
44 [main] DEBUG org.apache.shiro.realm.text.IniRealm  - Discovered the [roles] section.  Processing...
46 [main] DEBUG org.apache.shiro.realm.text.IniRealm  - Discovered the [users] section.  Processing...
56 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 银行服务开始...
59 [main] INFO SecureBankServiceTest  - 

#########################
### 开始测试用例 1

115 [main] DEBUG org.apache.shiro.authc.credential.SimpleCredentialsMatcher  - Performing credentials equality check for tokenCredentials of type [[C and accountCredentials of type [java.lang.String]
115 [main] DEBUG org.apache.shiro.authc.credential.SimpleCredentialsMatcher  - Both credentials arguments can be easily converted to byte arrays.  Performing array equals comparison
115 [main] DEBUG org.apache.shiro.authc.AbstractAuthenticator  - Authentication successful for token [org.apache.shiro.authc.UsernamePasswordToken - dan, rememberMe=false].  Returned account [dan]
115 [main] DEBUG org.apache.shiro.subject.support.DefaultSubjectContext  - No SecurityManager available in subject context map.  Falling back to SecurityUtils.getSecurityManager() lookup.
116 [main] DEBUG org.apache.shiro.subject.support.DefaultSubjectContext  - No SecurityManager available in subject context map.  Falling back to SecurityUtils.getSecurityManager() lookup.
116 [main] DEBUG org.apache.shiro.session.mgt.AbstractValidatingSessionManager  - No sessionValidationScheduler set.  Attempting to create default instance.
117 [main] INFO org.apache.shiro.session.mgt.AbstractValidatingSessionManager  - Enabling session validation scheduler...
124 [main] DEBUG org.apache.shiro.session.mgt.DefaultSessionManager  - Creating new EIS record for new session instance [org.apache.shiro.session.mgt.SimpleSession,id=null]
171 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建新的账户给 李四
188 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建新的账户: Account[id=1,ownerName=李四,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 20:44:14.991]
188 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获得银行账户的所有者 1
188 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=李四,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 20:44:14.991]
190 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户的活动状态 1
191 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=李四,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 20:44:14.991]
191 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
191 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=李四,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 20:44:14.991]
191 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
191 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=李四,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 20:44:14.991]
192 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
193 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=李四,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 20:44:14.991]
193 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
193 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=李四,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 20:44:14.991]
193 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 存钱到 250.0 这个账户 1
193 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=李四,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 20:44:14.991]
196 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建一个新的交易 AccountTransaction[id=1,type=DEPOSIT,accountId=1,amount=250.0,createdBy=dan,creationDate=2011-09-12 20:44:15.013]
196 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 新的账户余额 1 存款后 250.0
196 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获得银行账户的所有者 1
196 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=李四,isActive=true,balance=250.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 20:44:14.991]
196 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户的活动状态 1
196 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=李四,isActive=true,balance=250.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 20:44:14.991]
196 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
196 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=李四,isActive=true,balance=250.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 20:44:14.991]
196 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
196 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=李四,isActive=true,balance=250.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 20:44:14.991]
196 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=1,type=DEPOSIT,accountId=1,amount=250.0,createdBy=dan,creationDate=2011-09-12 20:44:15.013]
196 [main] DEBUG org.apache.shiro.mgt.DefaultSecurityManager  - Logging out subject with primary principal {}dan
197 [main] DEBUG org.apache.shiro.session.mgt.AbstractSessionManager  - Stopping session with id [3b53dc16-67d5-4730-ae8a-872d113c7546]
198 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 银行服务停止...
198 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 银行服务停止!

创建账户王五并且存入多笔款项

@Test
	public void testDepositInto_multiTxs() throws Exception {
		loginAsUser();
		long accountId = createAndValidateAccountFor("王五");
		makeDepositAndValidateAccount(accountId, 50.00d, "王五");
		makeDepositAndValidateAccount(accountId, 300.00d, "王五");
		makeDepositAndValidateAccount(accountId, 85.00d, "王五");
		assertAccount("王五", true, 435.00d, 3, accountId);
	}

一共存入三笔,最后得到的数据的总和为435

看日志打出来的信息

0 [main] DEBUG org.apache.shiro.io.ResourceUtils  - Opening resource from class path [shiroBankServiceTest.ini]
10 [main] DEBUG org.apache.shiro.config.Ini  - Parsing [users]
12 [main] DEBUG org.apache.shiro.config.Ini  - Parsing [roles]
13 [main] DEBUG org.apache.shiro.config.IniFactorySupport  - Creating instance from Ini [sections=users,roles]
46 [main] DEBUG org.apache.shiro.realm.text.IniRealm  - Discovered the [roles] section.  Processing...
49 [main] DEBUG org.apache.shiro.realm.text.IniRealm  - Discovered the [users] section.  Processing...
59 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 银行服务开始...
62 [main] INFO SecureBankServiceTest  - 

#########################
### 开始测试用例 1

118 [main] DEBUG org.apache.shiro.authc.credential.SimpleCredentialsMatcher  - Performing credentials equality check for tokenCredentials of type [[C and accountCredentials of type [java.lang.String]
118 [main] DEBUG org.apache.shiro.authc.credential.SimpleCredentialsMatcher  - Both credentials arguments can be easily converted to byte arrays.  Performing array equals comparison
119 [main] DEBUG org.apache.shiro.authc.AbstractAuthenticator  - Authentication successful for token [org.apache.shiro.authc.UsernamePasswordToken - dan, rememberMe=false].  Returned account [dan]
119 [main] DEBUG org.apache.shiro.subject.support.DefaultSubjectContext  - No SecurityManager available in subject context map.  Falling back to SecurityUtils.getSecurityManager() lookup.
119 [main] DEBUG org.apache.shiro.subject.support.DefaultSubjectContext  - No SecurityManager available in subject context map.  Falling back to SecurityUtils.getSecurityManager() lookup.
120 [main] DEBUG org.apache.shiro.session.mgt.AbstractValidatingSessionManager  - No sessionValidationScheduler set.  Attempting to create default instance.
121 [main] INFO org.apache.shiro.session.mgt.AbstractValidatingSessionManager  - Enabling session validation scheduler...
129 [main] DEBUG org.apache.shiro.session.mgt.DefaultSessionManager  - Creating new EIS record for new session instance [org.apache.shiro.session.mgt.SimpleSession,id=null]
189 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建新的账户给 王五
204 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建新的账户: Account[id=1,ownerName=王五,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 20:52:54.72]
204 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获得银行账户的所有者 1
204 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=王五,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 20:52:54.72]
205 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户的活动状态 1
206 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=王五,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 20:52:54.72]
206 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
206 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=王五,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 20:52:54.72]
206 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
206 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=王五,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 20:52:54.72]
207 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
207 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=王五,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 20:52:54.72]
207 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
207 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=王五,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 20:52:54.72]
207 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 存钱到 50.0 这个账户 1
207 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=王五,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 20:52:54.72]
210 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建一个新的交易 AccountTransaction[id=1,type=DEPOSIT,accountId=1,amount=50.0,createdBy=dan,creationDate=2011-09-12 20:52:54.739]
210 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 新的账户余额 1 存款后 50.0
210 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获得银行账户的所有者 1
210 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=王五,isActive=true,balance=50.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 20:52:54.72]
210 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户的活动状态 1
210 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=王五,isActive=true,balance=50.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 20:52:54.72]
210 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
210 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=王五,isActive=true,balance=50.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 20:52:54.72]
210 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
210 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=王五,isActive=true,balance=50.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 20:52:54.72]
210 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=1,type=DEPOSIT,accountId=1,amount=50.0,createdBy=dan,creationDate=2011-09-12 20:52:54.739]
210 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
211 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=王五,isActive=true,balance=50.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 20:52:54.72]
211 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
211 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=王五,isActive=true,balance=50.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 20:52:54.72]
211 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=1,type=DEPOSIT,accountId=1,amount=50.0,createdBy=dan,creationDate=2011-09-12 20:52:54.739]
211 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 存钱到 300.0 这个账户 1
211 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=王五,isActive=true,balance=50.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 20:52:54.72]
211 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建一个新的交易 AccountTransaction[id=2,type=DEPOSIT,accountId=1,amount=300.0,createdBy=dan,creationDate=2011-09-12 20:52:54.741]
211 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 新的账户余额 1 存款后 350.0
211 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获得银行账户的所有者 1
211 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=王五,isActive=true,balance=350.0,tx.count=2,createdBy=dan,creationDate=2011-09-12 20:52:54.72]
211 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户的活动状态 1
211 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=王五,isActive=true,balance=350.0,tx.count=2,createdBy=dan,creationDate=2011-09-12 20:52:54.72]
211 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
211 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=王五,isActive=true,balance=350.0,tx.count=2,createdBy=dan,creationDate=2011-09-12 20:52:54.72]
211 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
211 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=王五,isActive=true,balance=350.0,tx.count=2,createdBy=dan,creationDate=2011-09-12 20:52:54.72]
212 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=1,type=DEPOSIT,accountId=1,amount=50.0,createdBy=dan,creationDate=2011-09-12 20:52:54.739]
212 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=2,type=DEPOSIT,accountId=1,amount=300.0,createdBy=dan,creationDate=2011-09-12 20:52:54.741]
212 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
212 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=王五,isActive=true,balance=350.0,tx.count=2,createdBy=dan,creationDate=2011-09-12 20:52:54.72]
212 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
212 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=王五,isActive=true,balance=350.0,tx.count=2,createdBy=dan,creationDate=2011-09-12 20:52:54.72]
212 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=1,type=DEPOSIT,accountId=1,amount=50.0,createdBy=dan,creationDate=2011-09-12 20:52:54.739]
212 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=2,type=DEPOSIT,accountId=1,amount=300.0,createdBy=dan,creationDate=2011-09-12 20:52:54.741]
212 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 存钱到 85.0 这个账户 1
212 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=王五,isActive=true,balance=350.0,tx.count=2,createdBy=dan,creationDate=2011-09-12 20:52:54.72]
212 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建一个新的交易 AccountTransaction[id=3,type=DEPOSIT,accountId=1,amount=85.0,createdBy=dan,creationDate=2011-09-12 20:52:54.742]
212 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 新的账户余额 1 存款后 435.0
212 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获得银行账户的所有者 1
212 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=王五,isActive=true,balance=435.0,tx.count=3,createdBy=dan,creationDate=2011-09-12 20:52:54.72]
212 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户的活动状态 1
213 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=王五,isActive=true,balance=435.0,tx.count=3,createdBy=dan,creationDate=2011-09-12 20:52:54.72]
213 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
213 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=王五,isActive=true,balance=435.0,tx.count=3,createdBy=dan,creationDate=2011-09-12 20:52:54.72]
213 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
213 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=王五,isActive=true,balance=435.0,tx.count=3,createdBy=dan,creationDate=2011-09-12 20:52:54.72]
213 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=1,type=DEPOSIT,accountId=1,amount=50.0,createdBy=dan,creationDate=2011-09-12 20:52:54.739]
213 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=2,type=DEPOSIT,accountId=1,amount=300.0,createdBy=dan,creationDate=2011-09-12 20:52:54.741]
213 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=3,type=DEPOSIT,accountId=1,amount=85.0,createdBy=dan,creationDate=2011-09-12 20:52:54.742]
213 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获得银行账户的所有者 1
213 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=王五,isActive=true,balance=435.0,tx.count=3,createdBy=dan,creationDate=2011-09-12 20:52:54.72]
213 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户的活动状态 1
213 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=王五,isActive=true,balance=435.0,tx.count=3,createdBy=dan,creationDate=2011-09-12 20:52:54.72]
213 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
213 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=王五,isActive=true,balance=435.0,tx.count=3,createdBy=dan,creationDate=2011-09-12 20:52:54.72]
213 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
214 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=王五,isActive=true,balance=435.0,tx.count=3,createdBy=dan,creationDate=2011-09-12 20:52:54.72]
214 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=1,type=DEPOSIT,accountId=1,amount=50.0,createdBy=dan,creationDate=2011-09-12 20:52:54.739]
214 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=2,type=DEPOSIT,accountId=1,amount=300.0,createdBy=dan,creationDate=2011-09-12 20:52:54.741]
214 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=3,type=DEPOSIT,accountId=1,amount=85.0,createdBy=dan,creationDate=2011-09-12 20:52:54.742]
214 [main] DEBUG org.apache.shiro.mgt.DefaultSecurityManager  - Logging out subject with primary principal {}dan
214 [main] DEBUG org.apache.shiro.session.mgt.AbstractSessionManager  - Stopping session with id [1d66c2ec-a668-478a-8f30-e3c65f80a16d]
216 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 银行服务停止...
216 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 银行服务停止!

创建账户贾六并且取款,因为账户为空所以会抛出异常

	@Test(expected = NotEnoughFundsException.class)
	public void testWithdrawFrom_emptyAccount() throws Exception {
		loginAsUser();
		long accountId = createAndValidateAccountFor("贾六");
		service.withdrawFrom(accountId, 100.00d);
	}

看执行的结果

1 [main] DEBUG org.apache.shiro.io.ResourceUtils  - Opening resource from class path [shiroBankServiceTest.ini]
11 [main] DEBUG org.apache.shiro.config.Ini  - Parsing [users]
13 [main] DEBUG org.apache.shiro.config.Ini  - Parsing [roles]
15 [main] DEBUG org.apache.shiro.config.IniFactorySupport  - Creating instance from Ini [sections=users,roles]
46 [main] DEBUG org.apache.shiro.realm.text.IniRealm  - Discovered the [roles] section.  Processing...
50 [main] DEBUG org.apache.shiro.realm.text.IniRealm  - Discovered the [users] section.  Processing...
60 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 银行服务开始...
63 [main] INFO SecureBankServiceTest  - 

#########################
### 开始测试用例 1

126 [main] DEBUG org.apache.shiro.authc.credential.SimpleCredentialsMatcher  - Performing credentials equality check for tokenCredentials of type [[C and accountCredentials of type [java.lang.String]
126 [main] DEBUG org.apache.shiro.authc.credential.SimpleCredentialsMatcher  - Both credentials arguments can be easily converted to byte arrays.  Performing array equals comparison
128 [main] DEBUG org.apache.shiro.authc.AbstractAuthenticator  - Authentication successful for token [org.apache.shiro.authc.UsernamePasswordToken - dan, rememberMe=false].  Returned account [dan]
128 [main] DEBUG org.apache.shiro.subject.support.DefaultSubjectContext  - No SecurityManager available in subject context map.  Falling back to SecurityUtils.getSecurityManager() lookup.
129 [main] DEBUG org.apache.shiro.subject.support.DefaultSubjectContext  - No SecurityManager available in subject context map.  Falling back to SecurityUtils.getSecurityManager() lookup.
130 [main] DEBUG org.apache.shiro.session.mgt.AbstractValidatingSessionManager  - No sessionValidationScheduler set.  Attempting to create default instance.
132 [main] INFO org.apache.shiro.session.mgt.AbstractValidatingSessionManager  - Enabling session validation scheduler...
145 [main] DEBUG org.apache.shiro.session.mgt.DefaultSessionManager  - Creating new EIS record for new session instance [org.apache.shiro.session.mgt.SimpleSession,id=null]
190 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建新的账户给 贾六
205 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建新的账户: Account[id=1,ownerName=贾六,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 20:56:05.029]
205 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获得银行账户的所有者 1
205 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=贾六,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 20:56:05.029]
206 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户的活动状态 1
206 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=贾六,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 20:56:05.029]
206 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
207 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=贾六,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 20:56:05.029]
207 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
207 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=贾六,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 20:56:05.029]
208 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 取款 100.0 从账户 1
208 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=贾六,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 20:56:05.029]
210 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建一个新的交易 AccountTransaction[id=1,type=WITHDRAWAL,accountId=1,amount=100.0,createdBy=dan,creationDate=2011-09-12 20:56:05.047]
210 [main] DEBUG org.apache.shiro.mgt.DefaultSecurityManager  - Logging out subject with primary principal {}dan
210 [main] DEBUG org.apache.shiro.session.mgt.AbstractSessionManager  - Stopping session with id [05f3559d-d0c4-458c-a220-31389550576f]
211 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 银行服务停止...
211 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 银行服务停止!

得到期望的NotEnoughFundsException,运行通过

然后创建账户周七,先存入50,然后取100,结果得到的与面相同,余额不足异常

	@Test(expected = NotEnoughFundsException.class)
	public void testWithdrawFrom_notEnoughFunds() throws Exception {
		loginAsUser();
		long accountId = createAndValidateAccountFor("周七");
		makeDepositAndValidateAccount(accountId, 50.00d, "周七");
		service.withdrawFrom(accountId, 100.00d);
	}

看打印出的日志信息

0 [main] DEBUG org.apache.shiro.io.ResourceUtils  - Opening resource from class path [shiroBankServiceTest.ini]
10 [main] DEBUG org.apache.shiro.config.Ini  - Parsing [users]
12 [main] DEBUG org.apache.shiro.config.Ini  - Parsing [roles]
13 [main] DEBUG org.apache.shiro.config.IniFactorySupport  - Creating instance from Ini [sections=users,roles]
44 [main] DEBUG org.apache.shiro.realm.text.IniRealm  - Discovered the [roles] section.  Processing...
48 [main] DEBUG org.apache.shiro.realm.text.IniRealm  - Discovered the [users] section.  Processing...
59 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 银行服务开始...
61 [main] INFO SecureBankServiceTest  - 

#########################
### 开始测试用例 1

118 [main] DEBUG org.apache.shiro.authc.credential.SimpleCredentialsMatcher  - Performing credentials equality check for tokenCredentials of type [[C and accountCredentials of type [java.lang.String]
118 [main] DEBUG org.apache.shiro.authc.credential.SimpleCredentialsMatcher  - Both credentials arguments can be easily converted to byte arrays.  Performing array equals comparison
119 [main] DEBUG org.apache.shiro.authc.AbstractAuthenticator  - Authentication successful for token [org.apache.shiro.authc.UsernamePasswordToken - dan, rememberMe=false].  Returned account [dan]
119 [main] DEBUG org.apache.shiro.subject.support.DefaultSubjectContext  - No SecurityManager available in subject context map.  Falling back to SecurityUtils.getSecurityManager() lookup.
119 [main] DEBUG org.apache.shiro.subject.support.DefaultSubjectContext  - No SecurityManager available in subject context map.  Falling back to SecurityUtils.getSecurityManager() lookup.
120 [main] DEBUG org.apache.shiro.session.mgt.AbstractValidatingSessionManager  - No sessionValidationScheduler set.  Attempting to create default instance.
121 [main] INFO org.apache.shiro.session.mgt.AbstractValidatingSessionManager  - Enabling session validation scheduler...
131 [main] DEBUG org.apache.shiro.session.mgt.DefaultSessionManager  - Creating new EIS record for new session instance [org.apache.shiro.session.mgt.SimpleSession,id=null]
179 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建新的账户给 周七
196 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建新的账户: Account[id=1,ownerName=周七,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:01:30.936]
196 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获得银行账户的所有者 1
196 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=周七,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:01:30.936]
197 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户的活动状态 1
197 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=周七,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:01:30.936]
197 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
197 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=周七,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:01:30.936]
197 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
197 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=周七,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:01:30.936]
198 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
198 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=周七,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:01:30.936]
198 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
198 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=周七,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:01:30.936]
198 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 存钱到 50.0 这个账户 1
199 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=周七,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:01:30.936]
200 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建一个新的交易 AccountTransaction[id=1,type=DEPOSIT,accountId=1,amount=50.0,createdBy=dan,creationDate=2011-09-12 21:01:30.955]
200 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 新的账户余额 1 存款后 50.0
200 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获得银行账户的所有者 1
201 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=周七,isActive=true,balance=50.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:01:30.936]
201 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户的活动状态 1
201 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=周七,isActive=true,balance=50.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:01:30.936]
201 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
201 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=周七,isActive=true,balance=50.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:01:30.936]
201 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
201 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=周七,isActive=true,balance=50.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:01:30.936]
201 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=1,type=DEPOSIT,accountId=1,amount=50.0,createdBy=dan,creationDate=2011-09-12 21:01:30.955]
201 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 取款 100.0 从账户 1
201 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=周七,isActive=true,balance=50.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:01:30.936]
201 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建一个新的交易 AccountTransaction[id=2,type=WITHDRAWAL,accountId=1,amount=100.0,createdBy=dan,creationDate=2011-09-12 21:01:30.956]
202 [main] DEBUG org.apache.shiro.mgt.DefaultSecurityManager  - Logging out subject with primary principal {}dan
202 [main] DEBUG org.apache.shiro.session.mgt.AbstractSessionManager  - Stopping session with id [a85a89c7-a805-4086-bd5b-109a0d54086c]
203 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 银行服务停止...
203 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 银行服务停止!

再测试先存后取,先存入500,后取100,最后得到的结果为400

	@Test
	public void testWithdrawFrom_singleTx() throws Exception {
		loginAsUser();
		long accountId = createAndValidateAccountFor("国八");
		makeDepositAndValidateAccount(accountId, 500.00d, "国八");
		makeWithdrawalAndValidateAccount(accountId, 100.00d, "国八");
		assertAccount("国八", true, 400.00d, 2, accountId);
	}

看打印出的结果

0 [main] DEBUG org.apache.shiro.io.ResourceUtils  - Opening resource from class path [shiroBankServiceTest.ini]
9 [main] DEBUG org.apache.shiro.config.Ini  - Parsing [users]
10 [main] DEBUG org.apache.shiro.config.Ini  - Parsing [roles]
11 [main] DEBUG org.apache.shiro.config.IniFactorySupport  - Creating instance from Ini [sections=users,roles]
43 [main] DEBUG org.apache.shiro.realm.text.IniRealm  - Discovered the [roles] section.  Processing...
45 [main] DEBUG org.apache.shiro.realm.text.IniRealm  - Discovered the [users] section.  Processing...
55 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 银行服务开始...
59 [main] INFO SecureBankServiceTest  - 

#########################
### 开始测试用例 1

115 [main] DEBUG org.apache.shiro.authc.credential.SimpleCredentialsMatcher  - Performing credentials equality check for tokenCredentials of type [[C and accountCredentials of type [java.lang.String]
115 [main] DEBUG org.apache.shiro.authc.credential.SimpleCredentialsMatcher  - Both credentials arguments can be easily converted to byte arrays.  Performing array equals comparison
116 [main] DEBUG org.apache.shiro.authc.AbstractAuthenticator  - Authentication successful for token [org.apache.shiro.authc.UsernamePasswordToken - dan, rememberMe=false].  Returned account [dan]
116 [main] DEBUG org.apache.shiro.subject.support.DefaultSubjectContext  - No SecurityManager available in subject context map.  Falling back to SecurityUtils.getSecurityManager() lookup.
116 [main] DEBUG org.apache.shiro.subject.support.DefaultSubjectContext  - No SecurityManager available in subject context map.  Falling back to SecurityUtils.getSecurityManager() lookup.
116 [main] DEBUG org.apache.shiro.session.mgt.AbstractValidatingSessionManager  - No sessionValidationScheduler set.  Attempting to create default instance.
117 [main] INFO org.apache.shiro.session.mgt.AbstractValidatingSessionManager  - Enabling session validation scheduler...
124 [main] DEBUG org.apache.shiro.session.mgt.DefaultSessionManager  - Creating new EIS record for new session instance [org.apache.shiro.session.mgt.SimpleSession,id=null]
168 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建新的账户给 国八
185 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建新的账户: Account[id=1,ownerName=国八,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:03:17.085]
186 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获得银行账户的所有者 1
186 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=国八,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:03:17.085]
187 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户的活动状态 1
187 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=国八,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:03:17.085]
187 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
187 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=国八,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:03:17.085]
187 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
187 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=国八,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:03:17.085]
188 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
188 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=国八,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:03:17.085]
188 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
188 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=国八,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:03:17.085]
188 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 存钱到 500.0 这个账户 1
188 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=国八,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:03:17.085]
190 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建一个新的交易 AccountTransaction[id=1,type=DEPOSIT,accountId=1,amount=500.0,createdBy=dan,creationDate=2011-09-12 21:03:17.103]
190 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 新的账户余额 1 存款后 500.0
190 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获得银行账户的所有者 1
190 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=国八,isActive=true,balance=500.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:03:17.085]
190 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户的活动状态 1
191 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=国八,isActive=true,balance=500.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:03:17.085]
191 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
191 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=国八,isActive=true,balance=500.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:03:17.085]
191 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
191 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=国八,isActive=true,balance=500.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:03:17.085]
191 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=1,type=DEPOSIT,accountId=1,amount=500.0,createdBy=dan,creationDate=2011-09-12 21:03:17.103]
191 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
191 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=国八,isActive=true,balance=500.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:03:17.085]
191 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
191 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=国八,isActive=true,balance=500.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:03:17.085]
191 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=1,type=DEPOSIT,accountId=1,amount=500.0,createdBy=dan,creationDate=2011-09-12 21:03:17.103]
191 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 取款 100.0 从账户 1
191 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=国八,isActive=true,balance=500.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:03:17.085]
192 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建一个新的交易 AccountTransaction[id=2,type=WITHDRAWAL,accountId=1,amount=100.0,createdBy=dan,creationDate=2011-09-12 21:03:17.104]
192 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 新的账户余额 1 取款后 400.0
192 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获得银行账户的所有者 1
192 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=国八,isActive=true,balance=400.0,tx.count=2,createdBy=dan,creationDate=2011-09-12 21:03:17.085]
192 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户的活动状态 1
192 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=国八,isActive=true,balance=400.0,tx.count=2,createdBy=dan,creationDate=2011-09-12 21:03:17.085]
192 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
192 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=国八,isActive=true,balance=400.0,tx.count=2,createdBy=dan,creationDate=2011-09-12 21:03:17.085]
192 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
192 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=国八,isActive=true,balance=400.0,tx.count=2,createdBy=dan,creationDate=2011-09-12 21:03:17.085]
192 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=1,type=DEPOSIT,accountId=1,amount=500.0,createdBy=dan,creationDate=2011-09-12 21:03:17.103]
192 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=2,type=WITHDRAWAL,accountId=1,amount=100.0,createdBy=dan,creationDate=2011-09-12 21:03:17.104]
192 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获得银行账户的所有者 1
192 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=国八,isActive=true,balance=400.0,tx.count=2,createdBy=dan,creationDate=2011-09-12 21:03:17.085]
192 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户的活动状态 1
192 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=国八,isActive=true,balance=400.0,tx.count=2,createdBy=dan,creationDate=2011-09-12 21:03:17.085]
193 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
193 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=国八,isActive=true,balance=400.0,tx.count=2,createdBy=dan,creationDate=2011-09-12 21:03:17.085]
193 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
193 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=国八,isActive=true,balance=400.0,tx.count=2,createdBy=dan,creationDate=2011-09-12 21:03:17.085]
193 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=1,type=DEPOSIT,accountId=1,amount=500.0,createdBy=dan,creationDate=2011-09-12 21:03:17.103]
193 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=2,type=WITHDRAWAL,accountId=1,amount=100.0,createdBy=dan,creationDate=2011-09-12 21:03:17.104]
193 [main] DEBUG org.apache.shiro.mgt.DefaultSecurityManager  - Logging out subject with primary principal {}dan
193 [main] DEBUG org.apache.shiro.session.mgt.AbstractSessionManager  - Stopping session with id [192dddd6-7090-435c-bb65-b3b64a73d667]
195 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 银行服务停止...
195 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 银行服务停止!

存入一笔取多笔

	@Test
	public void testWithdrawFrom_manyTxs() throws Exception {
		loginAsUser();
		long accountId = createAndValidateAccountFor("Zoe Smith");
		makeDepositAndValidateAccount(accountId, 500.00d, "Zoe Smith");
		makeWithdrawalAndValidateAccount(accountId, 100.00d, "Zoe Smith");
		makeWithdrawalAndValidateAccount(accountId, 75.00d, "Zoe Smith");
		makeWithdrawalAndValidateAccount(accountId, 125.00d, "Zoe Smith");
		assertAccount("Zoe Smith", true, 200.00d, 4, accountId);
	}

查看打印的日志信息

0 [main] DEBUG org.apache.shiro.io.ResourceUtils  - Opening resource from class path [shiroBankServiceTest.ini]
9 [main] DEBUG org.apache.shiro.config.Ini  - Parsing [users]
11 [main] DEBUG org.apache.shiro.config.Ini  - Parsing [roles]
13 [main] DEBUG org.apache.shiro.config.IniFactorySupport  - Creating instance from Ini [sections=users,roles]
53 [main] DEBUG org.apache.shiro.realm.text.IniRealm  - Discovered the [roles] section.  Processing...
57 [main] DEBUG org.apache.shiro.realm.text.IniRealm  - Discovered the [users] section.  Processing...
72 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 银行服务开始...
76 [main] INFO SecureBankServiceTest  - 

#########################
### 开始测试用例 1

132 [main] DEBUG org.apache.shiro.authc.credential.SimpleCredentialsMatcher  - Performing credentials equality check for tokenCredentials of type [[C and accountCredentials of type [java.lang.String]
132 [main] DEBUG org.apache.shiro.authc.credential.SimpleCredentialsMatcher  - Both credentials arguments can be easily converted to byte arrays.  Performing array equals comparison
133 [main] DEBUG org.apache.shiro.authc.AbstractAuthenticator  - Authentication successful for token [org.apache.shiro.authc.UsernamePasswordToken - dan, rememberMe=false].  Returned account [dan]
133 [main] DEBUG org.apache.shiro.subject.support.DefaultSubjectContext  - No SecurityManager available in subject context map.  Falling back to SecurityUtils.getSecurityManager() lookup.
133 [main] DEBUG org.apache.shiro.subject.support.DefaultSubjectContext  - No SecurityManager available in subject context map.  Falling back to SecurityUtils.getSecurityManager() lookup.
134 [main] DEBUG org.apache.shiro.session.mgt.AbstractValidatingSessionManager  - No sessionValidationScheduler set.  Attempting to create default instance.
135 [main] INFO org.apache.shiro.session.mgt.AbstractValidatingSessionManager  - Enabling session validation scheduler...
143 [main] DEBUG org.apache.shiro.session.mgt.DefaultSessionManager  - Creating new EIS record for new session instance [org.apache.shiro.session.mgt.SimpleSession,id=null]
186 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建新的账户给 Zoe Smith
205 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建新的账户: Account[id=1,ownerName=Zoe Smith,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
205 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获得银行账户的所有者 1
205 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
207 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户的活动状态 1
207 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
207 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
207 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
207 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
208 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
209 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
209 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
209 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
209 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
209 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 存钱到 500.0 这个账户 1
209 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
212 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建一个新的交易 AccountTransaction[id=1,type=DEPOSIT,accountId=1,amount=500.0,createdBy=dan,creationDate=2011-09-12 21:04:28.337]
212 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 新的账户余额 1 存款后 500.0
212 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获得银行账户的所有者 1
212 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=500.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
212 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户的活动状态 1
212 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=500.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
212 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
212 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=500.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
212 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
212 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=500.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
213 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=1,type=DEPOSIT,accountId=1,amount=500.0,createdBy=dan,creationDate=2011-09-12 21:04:28.337]
213 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
213 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=500.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
213 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
213 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=500.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
213 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=1,type=DEPOSIT,accountId=1,amount=500.0,createdBy=dan,creationDate=2011-09-12 21:04:28.337]
213 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 取款 100.0 从账户 1
213 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=500.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
213 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建一个新的交易 AccountTransaction[id=2,type=WITHDRAWAL,accountId=1,amount=100.0,createdBy=dan,creationDate=2011-09-12 21:04:28.338]
213 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 新的账户余额 1 取款后 400.0
213 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获得银行账户的所有者 1
213 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=400.0,tx.count=2,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
213 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户的活动状态 1
213 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=400.0,tx.count=2,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
213 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
214 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=400.0,tx.count=2,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
214 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
214 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=400.0,tx.count=2,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
214 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=1,type=DEPOSIT,accountId=1,amount=500.0,createdBy=dan,creationDate=2011-09-12 21:04:28.337]
214 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=2,type=WITHDRAWAL,accountId=1,amount=100.0,createdBy=dan,creationDate=2011-09-12 21:04:28.338]
214 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
214 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=400.0,tx.count=2,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
214 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
214 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=400.0,tx.count=2,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
214 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=1,type=DEPOSIT,accountId=1,amount=500.0,createdBy=dan,creationDate=2011-09-12 21:04:28.337]
214 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=2,type=WITHDRAWAL,accountId=1,amount=100.0,createdBy=dan,creationDate=2011-09-12 21:04:28.338]
214 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 取款 75.0 从账户 1
214 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=400.0,tx.count=2,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
215 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建一个新的交易 AccountTransaction[id=3,type=WITHDRAWAL,accountId=1,amount=75.0,createdBy=dan,creationDate=2011-09-12 21:04:28.339]
215 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 新的账户余额 1 取款后 325.0
215 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获得银行账户的所有者 1
215 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=325.0,tx.count=3,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
215 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户的活动状态 1
215 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=325.0,tx.count=3,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
215 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
215 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=325.0,tx.count=3,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
215 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
215 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=325.0,tx.count=3,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
215 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=1,type=DEPOSIT,accountId=1,amount=500.0,createdBy=dan,creationDate=2011-09-12 21:04:28.337]
215 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=2,type=WITHDRAWAL,accountId=1,amount=100.0,createdBy=dan,creationDate=2011-09-12 21:04:28.338]
215 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=3,type=WITHDRAWAL,accountId=1,amount=75.0,createdBy=dan,creationDate=2011-09-12 21:04:28.339]
215 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
215 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=325.0,tx.count=3,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
215 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
216 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=325.0,tx.count=3,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
216 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=1,type=DEPOSIT,accountId=1,amount=500.0,createdBy=dan,creationDate=2011-09-12 21:04:28.337]
216 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=2,type=WITHDRAWAL,accountId=1,amount=100.0,createdBy=dan,creationDate=2011-09-12 21:04:28.338]
216 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=3,type=WITHDRAWAL,accountId=1,amount=75.0,createdBy=dan,creationDate=2011-09-12 21:04:28.339]
216 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 取款 125.0 从账户 1
216 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=325.0,tx.count=3,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
216 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建一个新的交易 AccountTransaction[id=4,type=WITHDRAWAL,accountId=1,amount=125.0,createdBy=dan,creationDate=2011-09-12 21:04:28.341]
216 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 新的账户余额 1 取款后 200.0
216 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获得银行账户的所有者 1
216 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=200.0,tx.count=4,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
216 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户的活动状态 1
216 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=200.0,tx.count=4,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
216 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
216 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=200.0,tx.count=4,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
216 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
216 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=200.0,tx.count=4,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
216 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=1,type=DEPOSIT,accountId=1,amount=500.0,createdBy=dan,creationDate=2011-09-12 21:04:28.337]
217 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=2,type=WITHDRAWAL,accountId=1,amount=100.0,createdBy=dan,creationDate=2011-09-12 21:04:28.338]
217 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=3,type=WITHDRAWAL,accountId=1,amount=75.0,createdBy=dan,creationDate=2011-09-12 21:04:28.339]
217 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=4,type=WITHDRAWAL,accountId=1,amount=125.0,createdBy=dan,creationDate=2011-09-12 21:04:28.341]
217 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获得银行账户的所有者 1
217 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=200.0,tx.count=4,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
217 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户的活动状态 1
217 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=200.0,tx.count=4,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
217 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
220 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=200.0,tx.count=4,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
220 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
221 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=200.0,tx.count=4,createdBy=dan,creationDate=2011-09-12 21:04:28.312]
221 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=1,type=DEPOSIT,accountId=1,amount=500.0,createdBy=dan,creationDate=2011-09-12 21:04:28.337]
221 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=2,type=WITHDRAWAL,accountId=1,amount=100.0,createdBy=dan,creationDate=2011-09-12 21:04:28.338]
221 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=3,type=WITHDRAWAL,accountId=1,amount=75.0,createdBy=dan,creationDate=2011-09-12 21:04:28.339]
221 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=4,type=WITHDRAWAL,accountId=1,amount=125.0,createdBy=dan,creationDate=2011-09-12 21:04:28.341]
221 [main] DEBUG org.apache.shiro.mgt.DefaultSecurityManager  - Logging out subject with primary principal {}dan
221 [main] DEBUG org.apache.shiro.session.mgt.AbstractSessionManager  - Stopping session with id [1ecbe8f2-f2f5-468b-af2b-d82d6b1267fa]
223 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 银行服务停止...
223 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 银行服务停止!

存多少取多少

@Test
	public void testWithdrawFrom_upToZero() throws Exception {
		loginAsUser();
		long accountId = createAndValidateAccountFor("Zoe Smith");
		makeDepositAndValidateAccount(accountId, 500.00d, "Zoe Smith");
		makeWithdrawalAndValidateAccount(accountId, 500.00d, "Zoe Smith");
		assertAccount("Zoe Smith", true, 0.00d, 2, accountId);
	}

查看打印的日志信息

0 [main] DEBUG org.apache.shiro.io.ResourceUtils  - Opening resource from class path [shiroBankServiceTest.ini]
9 [main] DEBUG org.apache.shiro.config.Ini  - Parsing [users]
11 [main] DEBUG org.apache.shiro.config.Ini  - Parsing [roles]
12 [main] DEBUG org.apache.shiro.config.IniFactorySupport  - Creating instance from Ini [sections=users,roles]
43 [main] DEBUG org.apache.shiro.realm.text.IniRealm  - Discovered the [roles] section.  Processing...
45 [main] DEBUG org.apache.shiro.realm.text.IniRealm  - Discovered the [users] section.  Processing...
55 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 银行服务开始...
58 [main] INFO SecureBankServiceTest  - 

#########################
### 开始测试用例 1

114 [main] DEBUG org.apache.shiro.authc.credential.SimpleCredentialsMatcher  - Performing credentials equality check for tokenCredentials of type [[C and accountCredentials of type [java.lang.String]
114 [main] DEBUG org.apache.shiro.authc.credential.SimpleCredentialsMatcher  - Both credentials arguments can be easily converted to byte arrays.  Performing array equals comparison
114 [main] DEBUG org.apache.shiro.authc.AbstractAuthenticator  - Authentication successful for token [org.apache.shiro.authc.UsernamePasswordToken - dan, rememberMe=false].  Returned account [dan]
115 [main] DEBUG org.apache.shiro.subject.support.DefaultSubjectContext  - No SecurityManager available in subject context map.  Falling back to SecurityUtils.getSecurityManager() lookup.
115 [main] DEBUG org.apache.shiro.subject.support.DefaultSubjectContext  - No SecurityManager available in subject context map.  Falling back to SecurityUtils.getSecurityManager() lookup.
115 [main] DEBUG org.apache.shiro.session.mgt.AbstractValidatingSessionManager  - No sessionValidationScheduler set.  Attempting to create default instance.
116 [main] INFO org.apache.shiro.session.mgt.AbstractValidatingSessionManager  - Enabling session validation scheduler...
125 [main] DEBUG org.apache.shiro.session.mgt.DefaultSessionManager  - Creating new EIS record for new session instance [org.apache.shiro.session.mgt.SimpleSession,id=null]
168 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建新的账户给 Zoe Smith
186 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建新的账户: Account[id=1,ownerName=Zoe Smith,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:05:23.783]
186 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获得银行账户的所有者 1
187 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:05:23.783]
188 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户的活动状态 1
188 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:05:23.783]
188 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
188 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:05:23.783]
188 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
188 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:05:23.783]
189 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
189 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:05:23.783]
189 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
189 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:05:23.783]
190 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 存钱到 500.0 这个账户 1
190 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:05:23.783]
192 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建一个新的交易 AccountTransaction[id=1,type=DEPOSIT,accountId=1,amount=500.0,createdBy=dan,creationDate=2011-09-12 21:05:23.804]
192 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 新的账户余额 1 存款后 500.0
192 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获得银行账户的所有者 1
192 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=500.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:05:23.783]
192 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户的活动状态 1
192 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=500.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:05:23.783]
192 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
192 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=500.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:05:23.783]
192 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
192 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=500.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:05:23.783]
192 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=1,type=DEPOSIT,accountId=1,amount=500.0,createdBy=dan,creationDate=2011-09-12 21:05:23.804]
192 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
192 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=500.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:05:23.783]
192 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
193 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=500.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:05:23.783]
193 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=1,type=DEPOSIT,accountId=1,amount=500.0,createdBy=dan,creationDate=2011-09-12 21:05:23.804]
193 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 取款 500.0 从账户 1
193 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=500.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:05:23.783]
193 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建一个新的交易 AccountTransaction[id=2,type=WITHDRAWAL,accountId=1,amount=500.0,createdBy=dan,creationDate=2011-09-12 21:05:23.806]
193 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 新的账户余额 1 取款后 0.0
193 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获得银行账户的所有者 1
193 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=0.0,tx.count=2,createdBy=dan,creationDate=2011-09-12 21:05:23.783]
193 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户的活动状态 1
193 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=0.0,tx.count=2,createdBy=dan,creationDate=2011-09-12 21:05:23.783]
193 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
193 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=0.0,tx.count=2,createdBy=dan,creationDate=2011-09-12 21:05:23.783]
193 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
193 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=0.0,tx.count=2,createdBy=dan,creationDate=2011-09-12 21:05:23.783]
193 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=1,type=DEPOSIT,accountId=1,amount=500.0,createdBy=dan,creationDate=2011-09-12 21:05:23.804]
193 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=2,type=WITHDRAWAL,accountId=1,amount=500.0,createdBy=dan,creationDate=2011-09-12 21:05:23.806]
194 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获得银行账户的所有者 1
194 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=0.0,tx.count=2,createdBy=dan,creationDate=2011-09-12 21:05:23.783]
194 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户的活动状态 1
194 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=0.0,tx.count=2,createdBy=dan,creationDate=2011-09-12 21:05:23.783]
194 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
194 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=0.0,tx.count=2,createdBy=dan,creationDate=2011-09-12 21:05:23.783]
194 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
194 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Zoe Smith,isActive=true,balance=0.0,tx.count=2,createdBy=dan,creationDate=2011-09-12 21:05:23.783]
194 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=1,type=DEPOSIT,accountId=1,amount=500.0,createdBy=dan,creationDate=2011-09-12 21:05:23.804]
194 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=2,type=WITHDRAWAL,accountId=1,amount=500.0,createdBy=dan,creationDate=2011-09-12 21:05:23.806]
194 [main] DEBUG org.apache.shiro.mgt.DefaultSecurityManager  - Logging out subject with primary principal {}dan
195 [main] DEBUG org.apache.shiro.session.mgt.AbstractSessionManager  - Stopping session with id [12aeb47c-f3c1-46c1-baec-78da03762422]
196 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 银行服务停止...
196 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 银行服务停止!

关闭账户余额为0的账户,普通用户没有权限,所以需要转到另外一个角色的账户进行操作

@Test
	public void testCloseAccount_zeroBalance() throws Exception {
		loginAsUser();
		long accountId = createAndValidateAccountFor("Chris Smith");

		logoutCurrentSubject();
		loginAsSuperviser();
		double closingBalance = service.closeAccount(accountId);
		Assert.assertEquals(0.00d, closingBalance);
		assertAccount("Chris Smith", false, 0.00d, 1, accountId);
	}

查看打印出来的日志信息

0 [main] DEBUG org.apache.shiro.io.ResourceUtils  - Opening resource from class path [shiroBankServiceTest.ini]
11 [main] DEBUG org.apache.shiro.config.Ini  - Parsing [users]
13 [main] DEBUG org.apache.shiro.config.Ini  - Parsing [roles]
14 [main] DEBUG org.apache.shiro.config.IniFactorySupport  - Creating instance from Ini [sections=users,roles]
47 [main] DEBUG org.apache.shiro.realm.text.IniRealm  - Discovered the [roles] section.  Processing...
50 [main] DEBUG org.apache.shiro.realm.text.IniRealm  - Discovered the [users] section.  Processing...
61 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 银行服务开始...
63 [main] INFO SecureBankServiceTest  - 

#########################
### 开始测试用例 1

121 [main] DEBUG org.apache.shiro.authc.credential.SimpleCredentialsMatcher  - Performing credentials equality check for tokenCredentials of type [[C and accountCredentials of type [java.lang.String]
121 [main] DEBUG org.apache.shiro.authc.credential.SimpleCredentialsMatcher  - Both credentials arguments can be easily converted to byte arrays.  Performing array equals comparison
121 [main] DEBUG org.apache.shiro.authc.AbstractAuthenticator  - Authentication successful for token [org.apache.shiro.authc.UsernamePasswordToken - dan, rememberMe=false].  Returned account [dan]
122 [main] DEBUG org.apache.shiro.subject.support.DefaultSubjectContext  - No SecurityManager available in subject context map.  Falling back to SecurityUtils.getSecurityManager() lookup.
122 [main] DEBUG org.apache.shiro.subject.support.DefaultSubjectContext  - No SecurityManager available in subject context map.  Falling back to SecurityUtils.getSecurityManager() lookup.
123 [main] DEBUG org.apache.shiro.session.mgt.AbstractValidatingSessionManager  - No sessionValidationScheduler set.  Attempting to create default instance.
124 [main] INFO org.apache.shiro.session.mgt.AbstractValidatingSessionManager  - Enabling session validation scheduler...
133 [main] DEBUG org.apache.shiro.session.mgt.DefaultSessionManager  - Creating new EIS record for new session instance [org.apache.shiro.session.mgt.SimpleSession,id=null]
191 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建新的账户给 Chris Smith
207 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建新的账户: Account[id=1,ownerName=Chris Smith,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:13:04.496]
207 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获得银行账户的所有者 1
207 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Chris Smith,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:13:04.496]
208 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户的活动状态 1
209 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Chris Smith,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:13:04.496]
209 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
209 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Chris Smith,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:13:04.496]
209 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
209 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Chris Smith,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:13:04.496]
210 [main] DEBUG org.apache.shiro.mgt.DefaultSecurityManager  - Logging out subject with primary principal {}dan
210 [main] DEBUG org.apache.shiro.session.mgt.AbstractSessionManager  - Stopping session with id [c4adc0a6-987c-4c94-ad38-d13f683c7f1d]
211 [main] DEBUG org.apache.shiro.authc.credential.SimpleCredentialsMatcher  - Performing credentials equality check for tokenCredentials of type [[C and accountCredentials of type [java.lang.String]
211 [main] DEBUG org.apache.shiro.authc.credential.SimpleCredentialsMatcher  - Both credentials arguments can be easily converted to byte arrays.  Performing array equals comparison
211 [main] DEBUG org.apache.shiro.authc.AbstractAuthenticator  - Authentication successful for token [org.apache.shiro.authc.UsernamePasswordToken - sally, rememberMe=false].  Returned account [sally]
211 [main] DEBUG org.apache.shiro.subject.support.DefaultSubjectContext  - No SecurityManager available in subject context map.  Falling back to SecurityUtils.getSecurityManager() lookup.
211 [main] DEBUG org.apache.shiro.subject.support.DefaultSubjectContext  - No SecurityManager available in subject context map.  Falling back to SecurityUtils.getSecurityManager() lookup.
211 [main] DEBUG org.apache.shiro.session.mgt.DefaultSessionManager  - Creating new EIS record for new session instance [org.apache.shiro.session.mgt.SimpleSession,id=null]
211 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 截止账户 1
211 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Chris Smith,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:13:04.496]
213 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建一个新的交易  AccountTransaction[id=1,type=WITHDRAWAL,accountId=1,amount=0.0,createdBy=sally,creationDate=2011-09-12 21:13:04.516]
213 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 账户 1 现在是关闭的 0.0 针对这个业主
213 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获得银行账户的所有者 1
213 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Chris Smith,isActive=false,balance=0.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:13:04.496]
213 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户的活动状态 1
214 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Chris Smith,isActive=false,balance=0.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:13:04.496]
214 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
214 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Chris Smith,isActive=false,balance=0.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:13:04.496]
214 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
214 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Chris Smith,isActive=false,balance=0.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:13:04.496]
214 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=1,type=WITHDRAWAL,accountId=1,amount=0.0,createdBy=sally,creationDate=2011-09-12 21:13:04.516]
214 [main] DEBUG org.apache.shiro.mgt.DefaultSecurityManager  - Logging out subject with primary principal {}sally
214 [main] DEBUG org.apache.shiro.session.mgt.AbstractSessionManager  - Stopping session with id [f0988257-3441-489a-859c-538043ead6e3]
215 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 银行服务停止...
215 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 银行服务停止!

创建用户并且存入350,然后对这个用户进行关闭操作

@Test
	public void testCloseAccount_withBalance() throws Exception {
		loginAsUser();
		long accountId = createAndValidateAccountFor("Gerry Smith");
		makeDepositAndValidateAccount(accountId, 385.00d, "Gerry Smith");

		logoutCurrentSubject();
		loginAsSuperviser();
		double closingBalance = service.closeAccount(accountId);
		Assert.assertEquals(385.00d, closingBalance);
		assertAccount("Gerry Smith", false, 0.00d, 2, accountId);
	}

查看打印的日志信息

0 [main] DEBUG org.apache.shiro.io.ResourceUtils  - Opening resource from class path [shiroBankServiceTest.ini]
9 [main] DEBUG org.apache.shiro.config.Ini  - Parsing [users]
11 [main] DEBUG org.apache.shiro.config.Ini  - Parsing [roles]
12 [main] DEBUG org.apache.shiro.config.IniFactorySupport  - Creating instance from Ini [sections=users,roles]
46 [main] DEBUG org.apache.shiro.realm.text.IniRealm  - Discovered the [roles] section.  Processing...
48 [main] DEBUG org.apache.shiro.realm.text.IniRealm  - Discovered the [users] section.  Processing...
58 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 银行服务开始...
61 [main] INFO SecureBankServiceTest  - 

#########################
### 开始测试用例 1

117 [main] DEBUG org.apache.shiro.authc.credential.SimpleCredentialsMatcher  - Performing credentials equality check for tokenCredentials of type [[C and accountCredentials of type [java.lang.String]
117 [main] DEBUG org.apache.shiro.authc.credential.SimpleCredentialsMatcher  - Both credentials arguments can be easily converted to byte arrays.  Performing array equals comparison
118 [main] DEBUG org.apache.shiro.authc.AbstractAuthenticator  - Authentication successful for token [org.apache.shiro.authc.UsernamePasswordToken - dan, rememberMe=false].  Returned account [dan]
118 [main] DEBUG org.apache.shiro.subject.support.DefaultSubjectContext  - No SecurityManager available in subject context map.  Falling back to SecurityUtils.getSecurityManager() lookup.
118 [main] DEBUG org.apache.shiro.subject.support.DefaultSubjectContext  - No SecurityManager available in subject context map.  Falling back to SecurityUtils.getSecurityManager() lookup.
118 [main] DEBUG org.apache.shiro.session.mgt.AbstractValidatingSessionManager  - No sessionValidationScheduler set.  Attempting to create default instance.
119 [main] INFO org.apache.shiro.session.mgt.AbstractValidatingSessionManager  - Enabling session validation scheduler...
128 [main] DEBUG org.apache.shiro.session.mgt.DefaultSessionManager  - Creating new EIS record for new session instance [org.apache.shiro.session.mgt.SimpleSession,id=null]
173 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建新的账户给 Gerry Smith
190 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建新的账户: Account[id=1,ownerName=Gerry Smith,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:17:58.652]
190 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获得银行账户的所有者 1
190 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Gerry Smith,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:17:58.652]
191 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户的活动状态 1
191 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Gerry Smith,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:17:58.652]
192 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
192 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Gerry Smith,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:17:58.652]
192 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
192 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Gerry Smith,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:17:58.652]
193 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
193 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Gerry Smith,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:17:58.652]
193 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
193 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Gerry Smith,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:17:58.652]
193 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 存钱到 385.0 这个账户 1
193 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Gerry Smith,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:17:58.652]
195 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建一个新的交易 AccountTransaction[id=1,type=DEPOSIT,accountId=1,amount=385.0,createdBy=dan,creationDate=2011-09-12 21:17:58.672]
195 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 新的账户余额 1 存款后 385.0
195 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获得银行账户的所有者 1
195 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Gerry Smith,isActive=true,balance=385.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:17:58.652]
195 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户的活动状态 1
195 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Gerry Smith,isActive=true,balance=385.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:17:58.652]
195 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
196 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Gerry Smith,isActive=true,balance=385.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:17:58.652]
196 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
196 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Gerry Smith,isActive=true,balance=385.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:17:58.652]
196 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=1,type=DEPOSIT,accountId=1,amount=385.0,createdBy=dan,creationDate=2011-09-12 21:17:58.672]
196 [main] DEBUG org.apache.shiro.mgt.DefaultSecurityManager  - Logging out subject with primary principal {}dan
196 [main] DEBUG org.apache.shiro.session.mgt.AbstractSessionManager  - Stopping session with id [b2e689a3-cd4a-4785-962b-0df77758533b]
197 [main] DEBUG org.apache.shiro.authc.credential.SimpleCredentialsMatcher  - Performing credentials equality check for tokenCredentials of type [[C and accountCredentials of type [java.lang.String]
197 [main] DEBUG org.apache.shiro.authc.credential.SimpleCredentialsMatcher  - Both credentials arguments can be easily converted to byte arrays.  Performing array equals comparison
197 [main] DEBUG org.apache.shiro.authc.AbstractAuthenticator  - Authentication successful for token [org.apache.shiro.authc.UsernamePasswordToken - sally, rememberMe=false].  Returned account [sally]
197 [main] DEBUG org.apache.shiro.subject.support.DefaultSubjectContext  - No SecurityManager available in subject context map.  Falling back to SecurityUtils.getSecurityManager() lookup.
197 [main] DEBUG org.apache.shiro.subject.support.DefaultSubjectContext  - No SecurityManager available in subject context map.  Falling back to SecurityUtils.getSecurityManager() lookup.
197 [main] DEBUG org.apache.shiro.session.mgt.DefaultSessionManager  - Creating new EIS record for new session instance [org.apache.shiro.session.mgt.SimpleSession,id=null]
197 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 截止账户 1
197 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Gerry Smith,isActive=true,balance=385.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:17:58.652]
197 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建一个新的交易  AccountTransaction[id=2,type=WITHDRAWAL,accountId=1,amount=385.0,createdBy=sally,creationDate=2011-09-12 21:17:58.674]
197 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 账户 1 现在是关闭的 385.0 针对这个业主
197 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获得银行账户的所有者 1
197 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Gerry Smith,isActive=false,balance=0.0,tx.count=2,createdBy=dan,creationDate=2011-09-12 21:17:58.652]
197 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户的活动状态 1
197 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Gerry Smith,isActive=false,balance=0.0,tx.count=2,createdBy=dan,creationDate=2011-09-12 21:17:58.652]
197 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
198 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Gerry Smith,isActive=false,balance=0.0,tx.count=2,createdBy=dan,creationDate=2011-09-12 21:17:58.652]
198 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
198 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Gerry Smith,isActive=false,balance=0.0,tx.count=2,createdBy=dan,creationDate=2011-09-12 21:17:58.652]
198 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=1,type=DEPOSIT,accountId=1,amount=385.0,createdBy=dan,creationDate=2011-09-12 21:17:58.672]
198 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=2,type=WITHDRAWAL,accountId=1,amount=385.0,createdBy=sally,creationDate=2011-09-12 21:17:58.674]
198 [main] DEBUG org.apache.shiro.mgt.DefaultSecurityManager  - Logging out subject with primary principal {}sally
198 [main] DEBUG org.apache.shiro.session.mgt.AbstractSessionManager  - Stopping session with id [6ffa0d67-7510-4205-9fa8-01b6bb9793f5]
199 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 银行服务停止...
199 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 银行服务停止!

创建用户并且关闭正活动的账户

@Test(expected = InactiveAccountException.class)
	public void testCloseAccount_alreadyClosed() throws Exception {
		loginAsUser();
		long accountId = createAndValidateAccountFor("Chris Smith");

		logoutCurrentSubject();
		loginAsSuperviser();
		double closingBalance = service.closeAccount(accountId);
		Assert.assertEquals(0.00d, closingBalance);
		assertAccount("Chris Smith", false, 0.00d, 1, accountId);
		service.closeAccount(accountId);
	}

查看打印的日志信息

0 [main] DEBUG org.apache.shiro.io.ResourceUtils  - Opening resource from class path [shiroBankServiceTest.ini]
9 [main] DEBUG org.apache.shiro.config.Ini  - Parsing [users]
12 [main] DEBUG org.apache.shiro.config.Ini  - Parsing [roles]
13 [main] DEBUG org.apache.shiro.config.IniFactorySupport  - Creating instance from Ini [sections=users,roles]
44 [main] DEBUG org.apache.shiro.realm.text.IniRealm  - Discovered the [roles] section.  Processing...
47 [main] DEBUG org.apache.shiro.realm.text.IniRealm  - Discovered the [users] section.  Processing...
57 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 银行服务开始...
60 [main] INFO SecureBankServiceTest  - 

#########################
### 开始测试用例 1

117 [main] DEBUG org.apache.shiro.authc.credential.SimpleCredentialsMatcher  - Performing credentials equality check for tokenCredentials of type [[C and accountCredentials of type [java.lang.String]
117 [main] DEBUG org.apache.shiro.authc.credential.SimpleCredentialsMatcher  - Both credentials arguments can be easily converted to byte arrays.  Performing array equals comparison
117 [main] DEBUG org.apache.shiro.authc.AbstractAuthenticator  - Authentication successful for token [org.apache.shiro.authc.UsernamePasswordToken - dan, rememberMe=false].  Returned account [dan]
118 [main] DEBUG org.apache.shiro.subject.support.DefaultSubjectContext  - No SecurityManager available in subject context map.  Falling back to SecurityUtils.getSecurityManager() lookup.
118 [main] DEBUG org.apache.shiro.subject.support.DefaultSubjectContext  - No SecurityManager available in subject context map.  Falling back to SecurityUtils.getSecurityManager() lookup.
119 [main] DEBUG org.apache.shiro.session.mgt.AbstractValidatingSessionManager  - No sessionValidationScheduler set.  Attempting to create default instance.
120 [main] INFO org.apache.shiro.session.mgt.AbstractValidatingSessionManager  - Enabling session validation scheduler...
127 [main] DEBUG org.apache.shiro.session.mgt.DefaultSessionManager  - Creating new EIS record for new session instance [org.apache.shiro.session.mgt.SimpleSession,id=null]
178 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建新的账户给 Chris Smith
195 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建新的账户: Account[id=1,ownerName=Chris Smith,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:19:53.755]
195 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获得银行账户的所有者 1
195 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Chris Smith,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:19:53.755]
196 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户的活动状态 1
196 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Chris Smith,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:19:53.755]
196 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
196 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Chris Smith,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:19:53.755]
197 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
197 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Chris Smith,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:19:53.755]
198 [main] DEBUG org.apache.shiro.mgt.DefaultSecurityManager  - Logging out subject with primary principal {}dan
198 [main] DEBUG org.apache.shiro.session.mgt.AbstractSessionManager  - Stopping session with id [8ff8f7c8-5d03-4e4f-b47d-0414cd43111d]
198 [main] DEBUG org.apache.shiro.authc.credential.SimpleCredentialsMatcher  - Performing credentials equality check for tokenCredentials of type [[C and accountCredentials of type [java.lang.String]
198 [main] DEBUG org.apache.shiro.authc.credential.SimpleCredentialsMatcher  - Both credentials arguments can be easily converted to byte arrays.  Performing array equals comparison
199 [main] DEBUG org.apache.shiro.authc.AbstractAuthenticator  - Authentication successful for token [org.apache.shiro.authc.UsernamePasswordToken - sally, rememberMe=false].  Returned account [sally]
199 [main] DEBUG org.apache.shiro.subject.support.DefaultSubjectContext  - No SecurityManager available in subject context map.  Falling back to SecurityUtils.getSecurityManager() lookup.
199 [main] DEBUG org.apache.shiro.subject.support.DefaultSubjectContext  - No SecurityManager available in subject context map.  Falling back to SecurityUtils.getSecurityManager() lookup.
199 [main] DEBUG org.apache.shiro.session.mgt.DefaultSessionManager  - Creating new EIS record for new session instance [org.apache.shiro.session.mgt.SimpleSession,id=null]
199 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 截止账户 1
199 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Chris Smith,isActive=true,balance=0.0,tx.count=0,createdBy=dan,creationDate=2011-09-12 21:19:53.755]
201 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 创建一个新的交易  AccountTransaction[id=1,type=WITHDRAWAL,accountId=1,amount=0.0,createdBy=sally,creationDate=2011-09-12 21:19:53.777]
201 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 账户 1 现在是关闭的 0.0 针对这个业主
201 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获得银行账户的所有者 1
201 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Chris Smith,isActive=false,balance=0.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:19:53.755]
201 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户的活动状态 1
201 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Chris Smith,isActive=false,balance=0.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:19:53.755]
201 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 得到账户的余额 1
201 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Chris Smith,isActive=false,balance=0.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:19:53.755]
201 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 获取账户交易 1
201 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Chris Smith,isActive=false,balance=0.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:19:53.755]
201 [main] DEBUG org.apache.shiro.samples.aspectj.bank.SecureBankService  - 查过交易 AccountTransaction[id=1,type=WITHDRAWAL,accountId=1,amount=0.0,createdBy=sally,creationDate=2011-09-12 21:19:53.777]
202 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 截止账户 1
202 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 检查账户 Account[id=1,ownerName=Chris Smith,isActive=false,balance=0.0,tx.count=1,createdBy=dan,creationDate=2011-09-12 21:19:53.755]
202 [main] DEBUG org.apache.shiro.mgt.DefaultSecurityManager  - Logging out subject with primary principal {}sally
202 [main] DEBUG org.apache.shiro.session.mgt.AbstractSessionManager  - Stopping session with id [53286615-5b71-4642-b3e8-916fb77fba60]
203 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 银行服务停止...
203 [main] INFO org.apache.shiro.samples.aspectj.bank.SecureBankService  - 银行服务停止!

其中判断权限使用的是annocation的方式

@RequiresPermissions("bankAccount:create") 是否有用户创建权限

@RequiresPermissions("bankAccount:read") 读权限

@RequiresPermissions("bankAccount:operate") 操作权限

@RequiresPermissions("bankAccount:close") 关闭权限

根据以上几个标签就可以得到对应的权限信息