Moves the existing virtual-thread/context-propagation project into context-propagation/ and adds method-security/ for the Spring Security 7 method-security article: nine runnable demos, fourteen assertions, and every transcript the article quotes, regenerated by scripts/run-all.sh. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RSrsDSRKVsY588yFiMJMo9
52 lines
1.3 KiB
Java
52 lines
1.3 KiB
Java
package com.ankurm.methodsec;
|
|
|
|
/**
|
|
* The one domain object every demo in this module operates on.
|
|
*
|
|
* <p>{@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
|
|
* (<a href="../../../../../../docs/02-spel-reference.md">docs/02-spel-reference.md</a>).
|
|
*
|
|
* <p>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
|
|
* <a href="../../../../../../docs/06-denied-handling.md">docs/06-denied-handling.md</a>.
|
|
*/
|
|
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 + "]";
|
|
}
|
|
|
|
}
|