Class HttpSecurityLoaderUtil
- java.lang.Object
-
- net.officefloor.web.security.type.HttpSecurityLoaderUtil
-
public class HttpSecurityLoaderUtil extends java.lang.Object
Utility class for testing theHttpSecuritySource
.- Author:
- Daniel Sagenschneider
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <C> void
authenticate(HttpAuthentication<C> authentication, C credentials)
Undertakes authentication.static <AC extends java.io.Serializable,C>
AuthenticationContext<AC,C>createAuthenticationContext(ServerHttpConnection connection, HttpSecurity<?,AC,C,?,?> security, java.util.function.Consumer<FunctionAuthenticateContext<AC,C>> handleAuthenticate)
Creates anAuthenticationContext
for testing.static HttpSecurityTypeBuilder
createHttpSecurityTypeBuilder()
Creates theHttpSecurityTypeBuilder
to create the expectedHttpSecurityType
.static <A,AC extends java.io.Serializable,C,O extends java.lang.Enum<O>,F extends java.lang.Enum<F>,HS extends HttpSecuritySource<A,AC,C,O,F>>
HttpSecurity<A,AC,C,O,F>loadHttpSecurity(java.lang.Class<HS> httpSecuritySourceClass, java.lang.String... propertyNameValues)
Convenience method to load theHttpSecurity
initialised ready for testing.static <A,AC extends java.io.Serializable,C,O extends java.lang.Enum<O>,F extends java.lang.Enum<F>,HS extends HttpSecuritySource<A,AC,C,O,F>>
HSloadHttpSecuritySource(java.lang.Class<HS> httpSecuritySourceClass, java.lang.String... propertyNameValues)
Convenience method to load theHttpSecuritySource
initialised ready for testing.static <A,AC extends java.io.Serializable,C,O extends java.lang.Enum<O>,F extends java.lang.Enum<F>>
HttpSecurityType<A,AC,C,O,F>loadHttpSecurityType(HttpSecuritySource<A,AC,C,O,F> httpSecuritySource, java.lang.String... propertyNameValues)
Loads theHttpSecurityType
.static <C> void
logout(HttpAuthentication<C> authentication)
Undertakes logout.static <A,AC extends java.io.Serializable,C,O extends java.lang.Enum<O>,F extends java.lang.Enum<F>,HS extends HttpSecuritySource<A,AC,C,O,F>>
HSnewHttpSecuritySource(java.lang.Class<HS> httpSecuritySourceClass)
Instantiates and instance of theHttpSecuritySource
.static <A,AC extends java.io.Serializable,C,O extends java.lang.Enum<O>,F extends java.lang.Enum<F>,HS extends HttpSecuritySource<A,AC,C,O,F>>
HttpSecurityType<A,AC,C,O,F>validateHttpSecurityType(HttpSecurityTypeBuilder expectedHttpSecurityType, java.lang.Class<HS> httpSecuritySourceClass, java.lang.String... propertyNameValues)
Validates theHttpSecurityType
contained in theHttpSecurityTypeBuilder
against theHttpSecurityType
loaded from theHttpSecuritySource
.static <A,AC extends java.io.Serializable,C,O extends java.lang.Enum<O>,F extends java.lang.Enum<F>,HS extends HttpSecuritySource<A,AC,C,O,F>>
PropertyListvalidateSpecification(java.lang.Class<HS> httpSecuritySourceClass, java.lang.String... propertyNameLabels)
Validates theHttpSecuritySourceSpecification
for theHttpSecuritySource
.
-
-
-
Method Detail
-
validateSpecification
public static <A,AC extends java.io.Serializable,C,O extends java.lang.Enum<O>,F extends java.lang.Enum<F>,HS extends HttpSecuritySource<A,AC,C,O,F>> PropertyList validateSpecification(java.lang.Class<HS> httpSecuritySourceClass, java.lang.String... propertyNameLabels)
Validates theHttpSecuritySourceSpecification
for theHttpSecuritySource
.- Type Parameters:
A
- Authentication type.AC
- Access control type.C
- Credentials type.O
- Dependency keys type.F
-Flow
keys type.HS
-HttpSecuritySource
type.- Parameters:
httpSecuritySourceClass
-HttpSecuritySource
class.propertyNameLabels
- Listing of name/label pairs for theProperty
instances.- Returns:
- Loaded
PropertyList
.
-
createHttpSecurityTypeBuilder
public static HttpSecurityTypeBuilder createHttpSecurityTypeBuilder()
Creates theHttpSecurityTypeBuilder
to create the expectedHttpSecurityType
.- Returns:
HttpSecurityTypeBuilder
.
-
validateHttpSecurityType
public static <A,AC extends java.io.Serializable,C,O extends java.lang.Enum<O>,F extends java.lang.Enum<F>,HS extends HttpSecuritySource<A,AC,C,O,F>> HttpSecurityType<A,AC,C,O,F> validateHttpSecurityType(HttpSecurityTypeBuilder expectedHttpSecurityType, java.lang.Class<HS> httpSecuritySourceClass, java.lang.String... propertyNameValues)
Validates theHttpSecurityType
contained in theHttpSecurityTypeBuilder
against theHttpSecurityType
loaded from theHttpSecuritySource
.- Type Parameters:
A
- Authentication type.AC
- Access control type.C
- Credentials type.O
- Dependency keys type.F
-Flow
keys type.HS
-HttpSecuritySource
type.- Parameters:
expectedHttpSecurityType
-HttpSecurityTypeBuilder
.httpSecuritySourceClass
-HttpSecuritySource
class.propertyNameValues
-Property
name/value pairs.- Returns:
- Validated
HttpSecurityType
.
-
loadHttpSecuritySource
public static <A,AC extends java.io.Serializable,C,O extends java.lang.Enum<O>,F extends java.lang.Enum<F>,HS extends HttpSecuritySource<A,AC,C,O,F>> HS loadHttpSecuritySource(java.lang.Class<HS> httpSecuritySourceClass, java.lang.String... propertyNameValues)
Convenience method to load theHttpSecuritySource
initialised ready for testing.- Type Parameters:
A
- Authentication type.AC
- Access control type.C
- Credentials type.O
- Dependency keys type.F
-Flow
keys type.HS
-HttpSecuritySource
type.- Parameters:
httpSecuritySourceClass
-HttpSecuritySource
class.propertyNameValues
-Property
name/value pairs to initialise theHttpSecuritySource
.- Returns:
- Initialised
HttpSecuritySource
.
-
loadHttpSecurity
public static <A,AC extends java.io.Serializable,C,O extends java.lang.Enum<O>,F extends java.lang.Enum<F>,HS extends HttpSecuritySource<A,AC,C,O,F>> HttpSecurity<A,AC,C,O,F> loadHttpSecurity(java.lang.Class<HS> httpSecuritySourceClass, java.lang.String... propertyNameValues)
Convenience method to load theHttpSecurity
initialised ready for testing.- Type Parameters:
A
- Authentication type.AC
- Access control type.C
- Credentials type.O
- Dependency keys type.F
-Flow
keys type.HS
-HttpSecuritySource
type.- Parameters:
httpSecuritySourceClass
-HttpSecuritySource
class.propertyNameValues
-Property
name/value pairs to initialise theHttpSecuritySource
.- Returns:
- Initialised
HttpSecuritySource
.
-
newHttpSecuritySource
public static <A,AC extends java.io.Serializable,C,O extends java.lang.Enum<O>,F extends java.lang.Enum<F>,HS extends HttpSecuritySource<A,AC,C,O,F>> HS newHttpSecuritySource(java.lang.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
-Flow
keys type.HS
-HttpSecuritySource
type.- Parameters:
httpSecuritySourceClass
-HttpSecuritySource
class.- Returns:
- New
HttpSecuritySource
instance.
-
loadHttpSecurityType
public static <A,AC extends java.io.Serializable,C,O extends java.lang.Enum<O>,F extends java.lang.Enum<F>> HttpSecurityType<A,AC,C,O,F> loadHttpSecurityType(HttpSecuritySource<A,AC,C,O,F> httpSecuritySource, java.lang.String... propertyNameValues)
Loads theHttpSecurityType
.- Type Parameters:
A
- Authentication type.AC
- Access control type.C
- Credentials type.O
- Dependency keys type.F
-Flow
keys type.- Parameters:
httpSecuritySource
-HttpSecuritySource
.propertyNameValues
-Property
name/value pairs.- Returns:
HttpSecurityType
.
-
createAuthenticationContext
public static <AC extends java.io.Serializable,C> AuthenticationContext<AC,C> createAuthenticationContext(ServerHttpConnection connection, HttpSecurity<?,AC,C,?,?> security, java.util.function.Consumer<FunctionAuthenticateContext<AC,C>> handleAuthenticate) throws java.lang.Throwable
Creates anAuthenticationContext
for testing.- Parameters:
connection
-ServerHttpConnection
.security
-HttpSecurity
.handleAuthenticate
- Handles the authentication.- Returns:
AuthenticationContext
for testing.- Throws:
java.lang.Exception
- If fails to create theAuthenticationContext
.java.lang.Throwable
-
authenticate
public static <C> void authenticate(HttpAuthentication<C> authentication, C credentials) throws java.lang.Throwable
Undertakes authentication.- Parameters:
authentication
-HttpAuthentication
.credentials
- Credentials.- Throws:
java.lang.Throwable
- If fails to authenticate or times out authenticating.
-
logout
public static <C> void logout(HttpAuthentication<C> authentication) throws java.lang.Throwable
Undertakes logout.- Parameters:
authentication
-HttpAuthentication
.- Throws:
java.lang.Throwable
- If fails to logout or times out.
-
-