package com.ankurm.methodsec; /** * The one domain object every demo in this module operates on. * *
{@code owner} is deliberately a plain {@code String} that matches * {@code authentication.getName()}, because that is what makes expressions like * {@code returnObject.owner == authentication.name} readable in the SpEL reference * (docs/02-spel-reference.md). * *
Not a record: {@link Demo7DeniedHandling} needs a CGLIB-proxyable, non-final class for * {@code @AuthorizeReturnObject}, and records are final. That restriction is itself one of the * findings -- see * docs/06-denied-handling.md. */ public class Account { private final long id; private final String owner; private long balanceMinor; public Account(long id, String owner, long balanceMinor) { this.id = id; this.owner = owner; this.balanceMinor = balanceMinor; } public long getId() { return this.id; } public String getOwner() { return this.owner; } public long getBalanceMinor() { return this.balanceMinor; } public void setBalanceMinor(long balanceMinor) { this.balanceMinor = balanceMinor; } @Override public String toString() { return "Account[" + this.id + "," + this.owner + "," + this.balanceMinor + "]"; } }