|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.richclient.security.support.DefaultApplicationSecurityManager
public class DefaultApplicationSecurityManager
Default implementation of ApplicationSecurityManager. It provides basic processing for login and logout actions and the event lifecycle.
Instances of this class should be configured with an instance of
AuthenticationManager to be used to handle authentication
(login) requests. This would be done like this:
<bean id="securityManager"
class="org.springframework.richclient.security.support.DefaultApplicationSecurityManager">
<property name="authenticationManager" ref="authenticationManager"/>
</bean>
<bean id="authenticationManager"
class="org.springframework.security.providers.ProviderManager">
<property name="providers">
<list>
<ref bean="remoteAuthenticationProvider" />
</list>
</property>
</bean>
<bean id="remoteAuthenticationProvider"
class="org.springframework.security.providers.rcp.RemoteAuthenticationProvider">
<property name="remoteAuthenticationManager" ref="remoteAuthenticationManager" />
</bean>
<bean id="remoteAuthenticationManager"
class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean">
<property name="serviceUrl">
<value>http://localhost:8080/myserver/rootContext/RemoteAuthenticationManager</value>
</property>
<property name="serviceInterface">
<value>org.springframework.security.providers.rcp.RemoteAuthenticationManager</value>
</property>
</bean>
If this is not done, then an attempt will be made to "auto-configure" by locating an
appropriate authentication manager in the application context. In order, a search will
be made for a bean that implements one of these classes:
| Constructor Summary | |
|---|---|
DefaultApplicationSecurityManager()
Default constructor. |
|
DefaultApplicationSecurityManager(boolean autoConfigure)
Constructor invoked when we are created as the default implementation by ApplicationServices. |
|
| Method Summary | |
|---|---|
void |
afterPropertiesSet()
Ensure that we have an authentication manager to work with. |
org.springframework.security.Authentication |
doLogin(org.springframework.security.Authentication authentication)
Process a login attempt and fire all related events. |
org.springframework.security.Authentication |
doLogout()
Perform a logout. |
org.springframework.security.Authentication |
getAuthentication()
Get the authentication token for the currently logged in user. |
org.springframework.security.AuthenticationManager |
getAuthenticationManager()
Get the authentication manager in use. |
boolean |
isUserInRole(String role)
Determine if the currently authenticated user has the role provided. |
boolean |
isUserLoggedIn()
Return if a user is currently logged in, meaning that a previous call to doLogin resulted in a valid authentication request. |
protected void |
setAuthentication(org.springframework.security.Authentication authentication)
Set the authenticaiton token. |
void |
setAuthenticationManager(org.springframework.security.AuthenticationManager authenticationManager)
Set the authentication manager to use. |
protected boolean |
tryToWire(Class type)
Try to locate and "wire in" a suitable authentication manager. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DefaultApplicationSecurityManager()
public DefaultApplicationSecurityManager(boolean autoConfigure)
Auto-configuration consists of trying to locate an AuthenticationManager (in one of
several classes) in the application context. This auto-configuration is also
attempted after the bean is constructed by the context if the authenticationManager
property has not been set. See afterPropertiesSet().
autoConfigure - pass true to perform auto-configuration
IllegalArgumentException - If the auto-configuration failsafterPropertiesSet()| Method Detail |
|---|
public void setAuthenticationManager(org.springframework.security.AuthenticationManager authenticationManager)
setAuthenticationManager in interface ApplicationSecurityManagerauthenticationManager - instance to use for authentication requestspublic org.springframework.security.AuthenticationManager getAuthenticationManager()
getAuthenticationManager in interface ApplicationSecurityManagerpublic org.springframework.security.Authentication doLogin(org.springframework.security.Authentication authentication)
AuthenticationFailedEvent is published and the exception is
rethrown. If the authentication succeeds, then an AuthenticationEvent is
published, followed by a LoginEvent.
doLogin in interface ApplicationSecurityManagerauthentication - token to use for the login attempt
AuthenticationManager.authenticate(org.springframework.security.Authentication).
org.springframework.security.SpringSecurityException - If the authentication attempt failsApplicationSecurityManager.doLogin(org.springframework.security.Authentication)public boolean isUserLoggedIn()
isUserLoggedIn in interface ApplicationSecurityManagerpublic org.springframework.security.Authentication getAuthentication()
getAuthentication in interface ApplicationSecurityManagerprotected void setAuthentication(org.springframework.security.Authentication authentication)
authentication - token to install as current.public boolean isUserInRole(String role)
isUserInRole in interface ApplicationSecurityManagerrole - to check
public org.springframework.security.Authentication doLogout()
AuthenticationEvent followed by a LogoutEvent.
doLogout in interface ApplicationSecurityManagerApplicationSecurityManager.doLogout()public void afterPropertiesSet()
ProviderManager,
AuthenticationProvider, and AuthenticationManager.
afterPropertiesSet in interface InitializingBeanInitializingBean.afterPropertiesSet()protected boolean tryToWire(Class type)
type - The type of bean to look for
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||