1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.springframework.security.oauth2.provider.expression;
17
18 import org.springframework.expression.Expression;
19 import org.springframework.expression.ExpressionParser;
20 import org.springframework.expression.ParseException;
21 import org.springframework.expression.ParserContext;
22 import org.springframework.util.Assert;
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 public class OAuth2ExpressionParser implements ExpressionParser {
39
40 private final ExpressionParser delegate;
41
42 public OAuth2ExpressionParser(ExpressionParser delegate) {
43 Assert.notNull(delegate, "delegate cannot be null");
44 this.delegate = delegate;
45 }
46
47 public Expression parseExpression(String expressionString) throws ParseException {
48 return delegate.parseExpression(wrapExpression(expressionString));
49 }
50
51 public Expression parseExpression(String expressionString, ParserContext context) throws ParseException {
52 return delegate.parseExpression(wrapExpression(expressionString), context);
53 }
54
55 private String wrapExpression(String expressionString) {
56 return "#oauth2.throwOnError(" + expressionString + ")";
57 }
58 }