Skip to content

Instantly share code, notes, and snippets.

View matteocedroni's full-sized avatar

Matteo Cedroni matteocedroni

View GitHub Profile
@matteocedroni
matteocedroni / SecurityChecker.java
Last active September 20, 2023 00:47
Programmatically check Spring Security expressions
import org.apache.log4j.Logger;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.security.access.expression.ExpressionUtils;
import org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler;
import org.springframework.security.access.expression.method.MethodSecurityExpressionHandler;
import org.springframework.security.util.SimpleMethodInvocation;
import java.lang.reflect.Method;