Class HttpSecurityLoaderUtil
java.lang.Object
net.officefloor.web.security.type.HttpSecurityLoaderUtil
Utility class for testing the
HttpSecuritySource.- Author:
- Daniel Sagenschneider
-
Method Summary
Modifier and TypeMethodDescriptionstatic <C> voidauthenticate(HttpAuthentication<C> authentication, C credentials) Undertakes authentication.static <AC extends Serializable,C>
AuthenticationContext<AC,C> createAuthenticationContext(ServerHttpConnection connection, HttpSecurity<?, AC, C, ?, ?> security, Consumer<FunctionAuthenticateContext<AC, C>> handleAuthenticate) Creates anAuthenticationContextfor testing.static HttpSecurityTypeBuilderCreates theHttpSecurityTypeBuilderto create the expectedHttpSecurityType.static <A,AC extends Serializable, C, O extends Enum<O>, F extends Enum<F>, HS extends HttpSecuritySource<A, AC, C, O, F>>
HttpSecurity<A,AC, C, O, F> loadHttpSecurity(Class<HS> httpSecuritySourceClass, String... propertyNameValues) Convenience method to load theHttpSecurityinitialised ready for testing.static <A,AC extends Serializable, C, O extends Enum<O>, F extends Enum<F>, HS extends HttpSecuritySource<A, AC, C, O, F>>
HSloadHttpSecuritySource(Class<HS> httpSecuritySourceClass, String... propertyNameValues) Convenience method to load theHttpSecuritySourceinitialised ready for testing.static <A,AC extends Serializable, C, O extends Enum<O>, F extends Enum<F>>
HttpSecurityType<A,AC, C, O, F> loadHttpSecurityType(HttpSecuritySource<A, AC, C, O, F> httpSecuritySource, String... propertyNameValues) Loads theHttpSecurityType.static <C> voidlogout(HttpAuthentication<C> authentication) Undertakes logout.static <A,AC extends Serializable, C, O extends Enum<O>, F extends Enum<F>, HS extends HttpSecuritySource<A, AC, C, O, F>>
HSnewHttpSecuritySource(Class<HS> httpSecuritySourceClass) Instantiates and instance of theHttpSecuritySource.static <A,AC extends Serializable, C, O extends Enum<O>, F extends Enum<F>, HS extends HttpSecuritySource<A, AC, C, O, F>>
HttpSecurityType<A,AC, C, O, F> validateHttpSecurityType(HttpSecurityTypeBuilder expectedHttpSecurityType, Class<HS> httpSecuritySourceClass, String... propertyNameValues) Validates theHttpSecurityTypecontained in theHttpSecurityTypeBuilderagainst theHttpSecurityTypeloaded from theHttpSecuritySource.static <A,AC extends Serializable, C, O extends Enum<O>, F extends Enum<F>, HS extends HttpSecuritySource<A, AC, C, O, F>>
PropertyListvalidateSpecification(Class<HS> httpSecuritySourceClass, String... propertyNameLabels) Validates theHttpSecuritySourceSpecificationfor theHttpSecuritySource.
-
Method Details
-
validateSpecification
public static <A,AC extends Serializable, PropertyList validateSpecificationC, O extends Enum<O>, F extends Enum<F>, HS extends HttpSecuritySource<A, AC, C, O, F>> (Class<HS> httpSecuritySourceClass, String... propertyNameLabels) Validates theHttpSecuritySourceSpecificationfor theHttpSecuritySource.- Type Parameters:
A- Authentication type.AC- Access control type.C- Credentials type.O- Dependency keys type.F-Flowkeys type.HS-HttpSecuritySourcetype.- Parameters:
httpSecuritySourceClass-HttpSecuritySourceclass.propertyNameLabels- Listing of name/label pairs for thePropertyinstances.- Returns:
- Loaded
PropertyList.
-
createHttpSecurityTypeBuilder
Creates theHttpSecurityTypeBuilderto create the expectedHttpSecurityType.- Returns:
HttpSecurityTypeBuilder.
-
validateHttpSecurityType
public static <A,AC extends Serializable, HttpSecurityType<A,C, O extends Enum<O>, F extends Enum<F>, HS extends HttpSecuritySource<A, AC, C, O, F>> AC, validateHttpSecurityTypeC, O, F> (HttpSecurityTypeBuilder expectedHttpSecurityType, Class<HS> httpSecuritySourceClass, String... propertyNameValues) Validates theHttpSecurityTypecontained in theHttpSecurityTypeBuilderagainst theHttpSecurityTypeloaded from theHttpSecuritySource.- Type Parameters:
A- Authentication type.AC- Access control type.C- Credentials type.O- Dependency keys type.F-Flowkeys type.HS-HttpSecuritySourcetype.- Parameters:
expectedHttpSecurityType-HttpSecurityTypeBuilder.httpSecuritySourceClass-HttpSecuritySourceclass.propertyNameValues-Propertyname/value pairs.- Returns:
- Validated
HttpSecurityType.
-
loadHttpSecuritySource
public static <A,AC extends Serializable, HS loadHttpSecuritySourceC, O extends Enum<O>, F extends Enum<F>, HS extends HttpSecuritySource<A, AC, C, O, F>> (Class<HS> httpSecuritySourceClass, String... propertyNameValues) Convenience method to load theHttpSecuritySourceinitialised ready for testing.- Type Parameters:
A- Authentication type.AC- Access control type.C- Credentials type.O- Dependency keys type.F-Flowkeys type.HS-HttpSecuritySourcetype.- Parameters:
httpSecuritySourceClass-HttpSecuritySourceclass.propertyNameValues-Propertyname/value pairs to initialise theHttpSecuritySource.- Returns:
- Initialised
HttpSecuritySource.
-
loadHttpSecurity
public static <A,AC extends Serializable, HttpSecurity<A,C, O extends Enum<O>, F extends Enum<F>, HS extends HttpSecuritySource<A, AC, C, O, F>> AC, loadHttpSecurityC, O, F> (Class<HS> httpSecuritySourceClass, String... propertyNameValues) Convenience method to load theHttpSecurityinitialised ready for testing.- Type Parameters:
A- Authentication type.AC- Access control type.C- Credentials type.O- Dependency keys type.F-Flowkeys type.HS-HttpSecuritySourcetype.- Parameters:
httpSecuritySourceClass-HttpSecuritySourceclass.propertyNameValues-Propertyname/value pairs to initialise theHttpSecuritySource.- Returns:
- Initialised
HttpSecuritySource.
-
newHttpSecuritySource
public static <A,AC extends Serializable, HS newHttpSecuritySourceC, O extends Enum<O>, F extends Enum<F>, HS extends HttpSecuritySource<A, AC, C, O, F>> (Class<HS> httpSecuritySourceClass) Instantiates and instance of theHttpSecuritySource.- Type Parameters:
A- Authentication type.AC- Access control type.C- Credentials type.O- Dependency keys type.F-Flowkeys type.HS-HttpSecuritySourcetype.- Parameters:
httpSecuritySourceClass-HttpSecuritySourceclass.- Returns:
- New
HttpSecuritySourceinstance.
-
loadHttpSecurityType
public static <A,AC extends Serializable, HttpSecurityType<A,C, O extends Enum<O>, F extends Enum<F>> AC, loadHttpSecurityTypeC, O, F> (HttpSecuritySource<A, AC, C, O, F> httpSecuritySource, String... propertyNameValues) Loads theHttpSecurityType.- Type Parameters:
A- Authentication type.AC- Access control type.C- Credentials type.O- Dependency keys type.F-Flowkeys type.- Parameters:
httpSecuritySource-HttpSecuritySource.propertyNameValues-Propertyname/value pairs.- Returns:
HttpSecurityType.
-
createAuthenticationContext
public static <AC extends Serializable,C> AuthenticationContext<AC,C> createAuthenticationContext(ServerHttpConnection connection, HttpSecurity<?, AC, throws ThrowableC, ?, ?> security, Consumer<FunctionAuthenticateContext<AC, C>> handleAuthenticate) Creates anAuthenticationContextfor testing.- Type Parameters:
AC- Access control type.C- Credentials type.- Parameters:
connection-ServerHttpConnection.security-HttpSecurity.handleAuthenticate- Handles the authentication.- Returns:
AuthenticationContextfor testing.- Throws:
Exception- If fails to create theAuthenticationContext.Throwable
-
authenticate
public static <C> void authenticate(HttpAuthentication<C> authentication, C credentials) throws Throwable Undertakes authentication.- Type Parameters:
C- Credentials type.- Parameters:
authentication-HttpAuthentication.credentials- Credentials.- Throws:
Throwable- If fails to authenticate or times out authenticating.
-
logout
Undertakes logout.- Type Parameters:
C- Credentials type.- Parameters:
authentication-HttpAuthentication.- Throws:
Throwable- If fails to logout or times out.
-