O
- The object that this builder returnsB
- The type of this builder (that is returned by the base class)public abstract class AbstractConfiguredSecurityBuilder<O,B extends SecurityBuilder<O>> extends AbstractSecurityBuilder<O>
A base SecurityBuilder
that allows SecurityConfigurer
to be applied to
it. This makes modifying the SecurityBuilder
a strategy that can be customized
and broken up into a number of SecurityConfigurer
objects that have more
specific goals than that of the SecurityBuilder
.
For example, a SecurityBuilder
may build an DelegatingFilterProxy
, but
a SecurityConfigurer
might populate the SecurityBuilder
with the
filters necessary for session management, form based login, authorization, etc.
WebSecurity
Modifier | Constructor and Description |
---|---|
protected |
AbstractConfiguredSecurityBuilder(ObjectPostProcessor<java.lang.Object> objectPostProcessor)
Creates a new instance with the provided
ObjectPostProcessor . |
protected |
AbstractConfiguredSecurityBuilder(ObjectPostProcessor<java.lang.Object> objectPostProcessor,
boolean allowConfigurersOfSameType)
Creates a new instance with the provided
ObjectPostProcessor . |
Modifier and Type | Method and Description |
---|---|
<C extends SecurityConfigurer<O,B>> |
apply(C configurer)
Applies a
SecurityConfigurer to this SecurityBuilder overriding any
SecurityConfigurer of the exact same class. |
<C extends SecurityConfigurerAdapter<O,B>> |
apply(C configurer)
Applies a
SecurityConfigurerAdapter to this SecurityBuilder and
invokes SecurityConfigurerAdapter.setBuilder(SecurityBuilder) . |
protected void |
beforeConfigure()
Invoked prior to invoking each
SecurityConfigurer.configure(SecurityBuilder) method. |
protected void |
beforeInit()
Invoked prior to invoking each
SecurityConfigurer.init(SecurityBuilder)
method. |
protected O |
doBuild()
Executes the build using the
SecurityConfigurer 's that have been applied
using the following steps:
Invokes beforeInit() for any subclass to hook into
Invokes SecurityConfigurer.init(SecurityBuilder) for any
SecurityConfigurer that was applied to this builder.
Invokes beforeConfigure() for any subclass to hook into
Invokes performBuild() which actually builds the Object
|
<C extends SecurityConfigurer<O,B>> |
getConfigurer(java.lang.Class<C> clazz)
Gets the
SecurityConfigurer by its class name or null if not
found. |
<C extends SecurityConfigurer<O,B>> |
getConfigurers(java.lang.Class<C> clazz)
Gets all the
SecurityConfigurer instances by its class name or an empty
List if not found. |
O |
getOrBuild()
Similar to
AbstractSecurityBuilder.build() and AbstractSecurityBuilder.getObject() but checks the state to
determine if AbstractSecurityBuilder.build() needs to be called first. |
<C> C |
getSharedObject(java.lang.Class<C> sharedType)
Gets a shared Object.
|
java.util.Map<java.lang.Class<? extends java.lang.Object>,java.lang.Object> |
getSharedObjects()
Gets the shared objects
|
O |
objectPostProcessor(ObjectPostProcessor<java.lang.Object> objectPostProcessor)
Specifies the
ObjectPostProcessor to use. |
protected abstract O |
performBuild()
Subclasses must implement this method to build the object that is being returned.
|
protected <P> P |
postProcess(P object)
Performs post processing of an object.
|
<C extends SecurityConfigurer<O,B>> |
removeConfigurer(java.lang.Class<C> clazz)
Removes and returns the
SecurityConfigurer by its class name or
null if not found. |
<C extends SecurityConfigurer<O,B>> |
removeConfigurers(java.lang.Class<C> clazz)
Removes all the
SecurityConfigurer instances by its class name or an empty
List if not found. |
<C> void |
setSharedObject(java.lang.Class<C> sharedType,
C object)
Sets an object that is shared by multiple
SecurityConfigurer . |
build, getObject
protected AbstractConfiguredSecurityBuilder(ObjectPostProcessor<java.lang.Object> objectPostProcessor)
ObjectPostProcessor
. This post
processor must support Object since there are many types of objects that may be
post processed.objectPostProcessor
- the ObjectPostProcessor
to useprotected AbstractConfiguredSecurityBuilder(ObjectPostProcessor<java.lang.Object> objectPostProcessor, boolean allowConfigurersOfSameType)
ObjectPostProcessor
. This post
processor must support Object since there are many types of objects that may be
post processed.objectPostProcessor
- the ObjectPostProcessor
to useallowConfigurersOfSameType
- if true, will not override other
SecurityConfigurer
's when performing applypublic O getOrBuild()
AbstractSecurityBuilder.build()
and AbstractSecurityBuilder.getObject()
but checks the state to
determine if AbstractSecurityBuilder.build()
needs to be called first.AbstractSecurityBuilder.build()
or AbstractSecurityBuilder.getObject()
. If an error occurs
while building, returns null.public <C extends SecurityConfigurerAdapter<O,B>> C apply(C configurer) throws java.lang.Exception
SecurityConfigurerAdapter
to this SecurityBuilder
and
invokes SecurityConfigurerAdapter.setBuilder(SecurityBuilder)
.configurer
- java.lang.Exception
public <C extends SecurityConfigurer<O,B>> C apply(C configurer) throws java.lang.Exception
SecurityConfigurer
to this SecurityBuilder
overriding any
SecurityConfigurer
of the exact same class. Note that object hierarchies
are not considered.configurer
- java.lang.Exception
public <C> void setSharedObject(java.lang.Class<C> sharedType, C object)
SecurityConfigurer
.sharedType
- the Class to key the shared object by.object
- the Object to storepublic <C> C getSharedObject(java.lang.Class<C> sharedType)
sharedType
- the type of the shared Objectpublic java.util.Map<java.lang.Class<? extends java.lang.Object>,java.lang.Object> getSharedObjects()
public <C extends SecurityConfigurer<O,B>> java.util.List<C> getConfigurers(java.lang.Class<C> clazz)
SecurityConfigurer
instances by its class name or an empty
List if not found. Note that object hierarchies are not considered.clazz
- the SecurityConfigurer
class to look forpublic <C extends SecurityConfigurer<O,B>> java.util.List<C> removeConfigurers(java.lang.Class<C> clazz)
SecurityConfigurer
instances by its class name or an empty
List if not found. Note that object hierarchies are not considered.clazz
- the SecurityConfigurer
class to look forpublic <C extends SecurityConfigurer<O,B>> C getConfigurer(java.lang.Class<C> clazz)
SecurityConfigurer
by its class name or null
if not
found. Note that object hierarchies are not considered.clazz
- public <C extends SecurityConfigurer<O,B>> C removeConfigurer(java.lang.Class<C> clazz)
SecurityConfigurer
by its class name or
null
if not found. Note that object hierarchies are not considered.clazz
- public O objectPostProcessor(ObjectPostProcessor<java.lang.Object> objectPostProcessor)
ObjectPostProcessor
to use.objectPostProcessor
- the ObjectPostProcessor
to use. Cannot be nullSecurityBuilder
for further customizationsprotected <P> P postProcess(P object)
ObjectPostProcessor
.object
- the Object to post processprotected final O doBuild() throws java.lang.Exception
SecurityConfigurer
's that have been applied
using the following steps:
beforeInit()
for any subclass to hook intoSecurityConfigurer.init(SecurityBuilder)
for any
SecurityConfigurer
that was applied to this builder.beforeConfigure()
for any subclass to hook intoperformBuild()
which actually builds the ObjectdoBuild
in class AbstractSecurityBuilder<O>
AbstractSecurityBuilder.build()
.java.lang.Exception
- if an error occursprotected void beforeInit() throws java.lang.Exception
SecurityConfigurer.init(SecurityBuilder)
method. Subclasses may override this method to hook into the lifecycle without
using a SecurityConfigurer
.java.lang.Exception
protected void beforeConfigure() throws java.lang.Exception
SecurityConfigurer.configure(SecurityBuilder)
method. Subclasses may
override this method to hook into the lifecycle without using a
SecurityConfigurer
.java.lang.Exception
protected abstract O performBuild() throws java.lang.Exception
java.lang.Exception