Interface Authentication
- All Superinterfaces:
Principal, Serializable
- All Known Implementing Classes:
AuthenticationJWTClaimsSetAdapter, ClientAuthentication, ServerAuthentication, X509Authentication
Represents the state of an authentication.
- Since:
- 1.0
- Author:
- James Kleeh
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull AuthenticationBuilds anAuthenticationinstance for the user.static @NonNull Authenticationbuild(@NonNull String username, @NonNull Collection<String> roles) Builds anAuthenticationinstance for the user.static @NonNull AuthenticationBuilds anAuthenticationinstance for the user.static @NonNull Authenticationbuild(@NonNull String username, @Nullable Collection<String> roles, @Nullable Map<String, Object> attributes) Builds anAuthenticationinstance for the user.In order to correctly implement theSerializablespecification, this map should be Map<String, Serializable>, however that would place a burden on those not requiring serialization, forcing their values to conform to that spec.default @NonNull Collection<String> getRoles()default @NonNull AuthenticationwithAttributes(@NonNull Map<String, Object> attributes) Creates an authentication with the supplied attributes.default @NonNull AuthenticationwithAttributes(@NonNull Map<String, Object> attributes, boolean append) Creates an authentication with the supplied attributes, optionally appending them to the current attributes.default @NonNull AuthenticationwithRoles(@NonNull Collection<String> roles) Creates an authentication with the supplied roles.default @NonNull AuthenticationwithRoles(@NonNull Collection<String> roles, boolean append) Creates an authentication with the supplied roles, optionally appending them to the current roles.default @NonNull AuthenticationwithUsername(@NonNull String username) Creates an authentication with the supplied user name.
-
Method Details
-
getAttributes
In order to correctly implement theSerializablespecification, this map should be Map<String, Serializable>, however that would place a burden on those not requiring serialization, forcing their values to conform to that spec. This is left intentionally as Object in order to meet both use cases and those requiring serialization must ensure all values in the map implementSerializable.- Returns:
- Any additional attributes in the authentication
-
getRoles
- Returns:
- Any roles associated with the authentication
-
build
Builds anAuthenticationinstance for the user.- Parameters:
username- User's name- Returns:
- An
Authenticationfor the User
-
build
Builds anAuthenticationinstance for the user.- Parameters:
username- User's nameroles- User's roles- Returns:
- An
Authenticationfor the User
-
build
static @NonNull Authentication build(@NonNull String username, @NonNull Map<String, Object> attributes) Builds anAuthenticationinstance for the user.- Parameters:
username- User's nameattributes- User's attributes- Returns:
- An
Authenticationfor the User
-
build
static @NonNull Authentication build(@NonNull String username, @Nullable Collection<String> roles, @Nullable Map<String, Object> attributes) Builds anAuthenticationinstance for the user.- Parameters:
username- User's nameroles- User's rolesattributes- User's attributes- Returns:
- An
Authenticationfor the User
-
withAttributes
default @NonNull Authentication withAttributes(@NonNull Map<String, Object> attributes, boolean append) Creates an authentication with the supplied attributes, optionally appending them to the current attributes.- Parameters:
attributes- User's attributesappend- Whether to append the attributes to the current attributes- Returns:
- An
Authenticationwith the supplied attributes - Since:
- 5.1.0
-
withAttributes
Creates an authentication with the supplied attributes.- Parameters:
attributes- User's attributes- Returns:
- An
Authenticationwith the supplied attributes - Since:
- 5.1.0
-
withRoles
Creates an authentication with the supplied roles, optionally appending them to the current roles.- Parameters:
roles- User's rolesappend- Whether to append the roles to the current roles- Returns:
- An
Authenticationwith the supplied roles - Since:
- 5.1.0
-
withRoles
Creates an authentication with the supplied roles.- Parameters:
roles- User's roles- Returns:
- An
Authenticationwith the supplied roles - Since:
- 5.1.0
-
withUsername
Creates an authentication with the supplied user name.- Parameters:
username- User's name- Returns:
- An
Authenticationwith the supplied user name - Since:
- 5.1.0
-