Annotation Interface Authorized
@Retention(RUNTIME)
@Target({METHOD,TYPE,FIELD})
@Documented
@Inherited
public @interface Authorized
An annotation used to specify server resources with enforced authorization.
The following sample shows examples of use of @Authorized annotation on application endpoints:
@Authorized
@Authenticated
public class SecuredEndpoint { ... }
@Authorized(false)
public class PublicEndpoint {
public String getResourceContent() { ... }
// Only authenticated users can update the content of the public resource
@Authorized
public String setNewResourceContent(String content) { ... }
}
Authorized annotation is not cumulative - e.g. if you define this annotation on a resource method, it will take ALL values from this instance of Authorized (so if you want to use a custom authorization provider, you must define it again in each Authorized instance).
-
Field Summary
Fields -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionbooleanBy default, authorization is implicit and all annotations are processed before method invocation to authorize access.Explicit authorization provider to use when processing this Authorized.booleanDetermine whether authorization should be enabled.
-
Field Details
-
TYPE
Type name of this annotation.
-
-
Element Details
-
value
boolean valueDetermine whether authorization should be enabled. Defaults totrue- Returns:
trueif authorization should be enabled.
- Default:
true
-
provider
String providerExplicit authorization provider to use when processing this Authorized. Setting this value will ignore security provider configured globally. Value is the name of a configuredAuthenticationProvider.- Returns:
- name of a configured provider
- Default:
""
-
explicit
boolean explicitBy default, authorization is implicit and all annotations are processed before method invocation to authorize access. In case this is set to true, authorization MUST be invoked manually, callingSecurityContext.authorize(Object...). If set to true the security module will not check authorization; security module still checks that authorization was called. If not, an exception is generated post-processing. For example the Jersey integration will return an internal server error in such a case.- Returns:
- true if explicit authorization will be invoked in the code, false for implicit (handled by security module)
- Default:
false
-