|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2022 the original author or authors. |
| 2 | + * Copyright 2002-2024 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -35,6 +35,8 @@ public class AuthorizationObservationContext<T> extends Observation.Context {
|
35 | 35 |
|
36 | 36 | private AuthorizationDecision decision;
|
37 | 37 |
|
| 38 | + private AuthorizationResult authorizationResult; |
| 39 | + |
38 | 40 | public AuthorizationObservationContext(T object) {
|
39 | 41 | Assert.notNull(object, "object cannot be null");
|
40 | 42 | this.object = object;
|
@@ -71,17 +73,43 @@ public T getObject() {
|
71 | 73 | /**
|
72 | 74 | * Get the observed {@link AuthorizationDecision}
|
73 | 75 | * @return the observed {@link AuthorizationDecision}
|
| 76 | + * @deprecated please use {@link #getAuthorizationResult()} instead |
74 | 77 | */
|
| 78 | + @Deprecated |
75 | 79 | public AuthorizationDecision getDecision() {
|
76 |
| - return this.decision; |
| 80 | + Assert.isInstanceOf(AuthorizationDecision.class, this.authorizationResult, |
| 81 | + "Please call getAuthorizationResult instead. If you must call getDecision, please ensure that the result you provide is of type AuthorizationDecision"); |
| 82 | + return (AuthorizationDecision) this.authorizationResult; |
77 | 83 | }
|
78 | 84 |
|
79 | 85 | /**
|
80 | 86 | * Set the observed {@link AuthorizationDecision}
|
81 | 87 | * @param decision the observed {@link AuthorizationDecision}
|
| 88 | + * @deprecated please use {@link #setAuthorizationResult(AuthorizationResult)} instead |
82 | 89 | */
|
| 90 | + @Deprecated |
83 | 91 | public void setDecision(AuthorizationDecision decision) {
|
| 92 | + Assert.isInstanceOf(AuthorizationDecision.class, decision, |
| 93 | + "Please call setAuthorizationResult instead. If you must call getDecision, please ensure that the result you provide is of type AuthorizationDecision"); |
84 | 94 | this.decision = decision;
|
85 | 95 | }
|
86 | 96 |
|
| 97 | + /** |
| 98 | + * Get the observed {@link AuthorizationResult} |
| 99 | + * @return the observed {@link AuthorizationResult} |
| 100 | + * @since 6.4 |
| 101 | + */ |
| 102 | + public AuthorizationResult getAuthorizationResult() { |
| 103 | + return this.authorizationResult; |
| 104 | + } |
| 105 | + |
| 106 | + /** |
| 107 | + * Set the observed {@link AuthorizationResult} |
| 108 | + * @param authorizationResult the observed {@link AuthorizationResult} |
| 109 | + * @since 6.4 |
| 110 | + */ |
| 111 | + public void setAuthorizationResult(AuthorizationResult authorizationResult) { |
| 112 | + this.authorizationResult = authorizationResult; |
| 113 | + } |
| 114 | + |
87 | 115 | }
|
0 commit comments