Java Doc for JaasAuthenticationProvider.java in  » Security » acegi-security » org » acegisecurity » providers » jaas » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Security » acegi security » org.acegisecurity.providers.jaas 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.acegisecurity.providers.jaas.JaasAuthenticationProvider

JaasAuthenticationProvider
public class JaasAuthenticationProvider implements AuthenticationProvider,ApplicationEventPublisherAware,InitializingBean,ApplicationListener(Code)
An AuthenticationProvider implementation that retrieves user details from a JAAS login configuration.

This AuthenticationProvider is capable of validating org.acegisecurity.providers.UsernamePasswordAuthenticationToken requests contain the correct username and password.

This implementation is backed by a JAAS configuration. The loginConfig property must be set to a given JAAS configuration file. This setter accepts a Spring org.springframework.core.io.Resource instance. It should point to a JAAS configuration file containing an index matching the JaasAuthenticationProvider.setLoginContextName(java.lang.String) loginContextName property.

For example: If this JaasAuthenticationProvider were configured in a Spring WebApplicationContext the xml to set the loginConfiguration could be as follows...

 <property name="loginConfig">
 <value>/WEB-INF/login.conf</value>
 </property>
 

The loginContextName should coincide with a given index in the loginConfig specifed. The loginConfig file used in the JUnit tests appears as the following...

 JAASTest {
 org.acegisecurity.providers.jaas.TestLoginModule required;
 };
 
Using the example login configuration above, the loginContextName property would be set as JAASTest...
 <property name="loginContextName"> <value>JAASTest</value> </property>
 

When using JAAS login modules as the authentication source, sometimes the LoginContext will require CallbackHandlers. The JaasAuthenticationProvider uses an internal CallbackHandler to wrap the JaasAuthenticationCallbackHandler s configured in the ApplicationContext. When the LoginContext calls the internal CallbackHandler, control is passed to each JaasAuthenticationCallbackHandler for each Callback passed.

JaasAuthenticationCallbackHandler s are passed to the JaasAuthenticationProvider through the JaasAuthenticationProvider.setCallbackHandlers(org.acegisecurity.providers.jaas.JaasAuthenticationCallbackHandler[]) callbackHandlers property.

 <property name="callbackHandlers">
 <list>
 <bean class="org.acegisecurity.providers.jaas.TestCallbackHandler"/>
 <bean class="
JaasNameCallbackHandler org.acegisecurity.providers.jaas.JaasNameCallbackHandler "/>
 <bean class="
JaasPasswordCallbackHandler org.acegisecurity.providers.jaas.JaasPasswordCallbackHandler "/>
 </list>
 </property>
 

After calling LoginContext.login(), the JaasAuthenticationProvider will retrieve the returned Principals from the Subject (LoginContext.getSubject().getPrincipals). Each returned principal is then passed to the configured AuthorityGranter s. An AuthorityGranter is a mapping between a returned Principal, and a role name. If an AuthorityGranter wishes to grant an Authorization a role, it returns that role name from it's AuthorityGranter.grant(java.security.Principal) method. The returned role will be applied to the Authorization object as a GrantedAuthority .

AuthorityGranters are configured in spring xml as follows...

 <property name="authorityGranters">
 <list>
 <bean class="org.acegisecurity.providers.jaas.TestAuthorityGranter"/>
 </list>
 </property>
 
A configuration note: The JaasAuthenticationProvider uses the security properites "e;login.config.url.X"e; to configure jaas. If you would like to customize the way Jaas gets configured, create a subclass of this and override the JaasAuthenticationProvider.configureJaas(Resource) method.


author:
   Ray Krueger
version:
   $Id: JaasAuthenticationProvider.java 1985 2007-08-29 11:51:02Z luke_t $


Field Summary
final protected static  Loglog
    


Method Summary
public  voidafterPropertiesSet()
    
public  Authenticationauthenticate(Authentication auth)
     Attempts to login the user given the Authentication objects principal and credential
Parameters:
  auth - The Authentication object to be authenticated.
protected  voidconfigureJaas(Resource loginConfig)
    
protected  ApplicationEventPublishergetApplicationEventPublisher()
    
public  AuthorityGranter[]getAuthorityGranters()
     Returns the AuthorityGrannter array that was passed to the JaasAuthenticationProvider.setAuthorityGranters(AuthorityGranter[]) method, or null if it none were ever set.
public  JaasAuthenticationCallbackHandler[]getCallbackHandlers()
     Returns the current JaasAuthenticationCallbackHandler array, or null if none are set.
public  ResourcegetLoginConfig()
    
public  StringgetLoginContextName()
    
public  LoginExceptionResolvergetLoginExceptionResolver()
    
protected  voidhandleLogout(HttpSessionDestroyedEvent event)
     Handles the logout by getting the SecurityContext for the session that was destroyed.
public  voidonApplicationEvent(ApplicationEvent applicationEvent)
    
protected  voidpublishFailureEvent(UsernamePasswordAuthenticationToken token, AcegiSecurityException ase)
     Publishes the JaasAuthenticationFailedEvent .
protected  voidpublishSuccessEvent(UsernamePasswordAuthenticationToken token)
     Publishes the JaasAuthenticationSuccessEvent .
public  voidsetApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
    
public  voidsetAuthorityGranters(AuthorityGranter[] authorityGranters)
     Set the AuthorityGranters that should be consulted for role names to be granted to the Authentication.
public  voidsetCallbackHandlers(JaasAuthenticationCallbackHandler[] callbackHandlers)
     Set the JAASAuthentcationCallbackHandler array to handle callback objects generated by the LoginContext.login method.
public  voidsetLoginConfig(Resource loginConfig)
     Set the JAAS login configuration file.
public  voidsetLoginContextName(String loginContextName)
     Set the loginContextName, this name is used as the index to the configuration specified in the loginConfig property.
public  voidsetLoginExceptionResolver(LoginExceptionResolver loginExceptionResolver)
    
public  booleansupports(Class aClass)
    

Field Detail
log
final protected static Log log(Code)





Method Detail
afterPropertiesSet
public void afterPropertiesSet() throws Exception(Code)



authenticate
public Authentication authenticate(Authentication auth) throws AuthenticationException(Code)
Attempts to login the user given the Authentication objects principal and credential
Parameters:
  auth - The Authentication object to be authenticated. The authenticated Authentication object, with it's grantedAuthorities set.
throws:
  AuthenticationException - This implementation does not handle 'locked' or 'disabled' accounts. This methodonly throws a AuthenticationServiceException, with the message of the LoginException that will bethrown, should the loginContext.login() method fail.



configureJaas
protected void configureJaas(Resource loginConfig) throws IOException(Code)
Hook method for configuring Jaas
Parameters:
  loginConfig - URL to Jaas login configuration
throws:
  IOException - if there is a problem reading the config resource.



getApplicationEventPublisher
protected ApplicationEventPublisher getApplicationEventPublisher()(Code)



getAuthorityGranters
public AuthorityGranter[] getAuthorityGranters()(Code)
Returns the AuthorityGrannter array that was passed to the JaasAuthenticationProvider.setAuthorityGranters(AuthorityGranter[]) method, or null if it none were ever set. The AuthorityGranter array, or null
See Also:   JaasAuthenticationProvider.setAuthorityGranters(AuthorityGranter[])



getCallbackHandlers
public JaasAuthenticationCallbackHandler[] getCallbackHandlers()(Code)
Returns the current JaasAuthenticationCallbackHandler array, or null if none are set. the JAASAuthenticationCallbackHandlers.
See Also:   JaasAuthenticationProvider.setCallbackHandlers(JaasAuthenticationCallbackHandler[])



getLoginConfig
public Resource getLoginConfig()(Code)



getLoginContextName
public String getLoginContextName()(Code)



getLoginExceptionResolver
public LoginExceptionResolver getLoginExceptionResolver()(Code)



handleLogout
protected void handleLogout(HttpSessionDestroyedEvent event)(Code)
Handles the logout by getting the SecurityContext for the session that was destroyed. MUST NOT use SecurityContextHolder we are logging out a session that is not related to the current user.
Parameters:
  event -



onApplicationEvent
public void onApplicationEvent(ApplicationEvent applicationEvent)(Code)



publishFailureEvent
protected void publishFailureEvent(UsernamePasswordAuthenticationToken token, AcegiSecurityException ase)(Code)
Publishes the JaasAuthenticationFailedEvent . Can be overridden by subclasses for different functionality
Parameters:
  token - The UsernamePasswordAuthenticationToken being processed
Parameters:
  ase - The AcegiSecurityException that caused the failure



publishSuccessEvent
protected void publishSuccessEvent(UsernamePasswordAuthenticationToken token)(Code)
Publishes the JaasAuthenticationSuccessEvent . Can be overridden by subclasses for different functionality.
Parameters:
  token - The UsernamePasswordAuthenticationToken being processed



setApplicationEventPublisher
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)(Code)



setAuthorityGranters
public void setAuthorityGranters(AuthorityGranter[] authorityGranters)(Code)
Set the AuthorityGranters that should be consulted for role names to be granted to the Authentication.
Parameters:
  authorityGranters - AuthorityGranter array
See Also:   JaasAuthenticationProvider



setCallbackHandlers
public void setCallbackHandlers(JaasAuthenticationCallbackHandler[] callbackHandlers)(Code)
Set the JAASAuthentcationCallbackHandler array to handle callback objects generated by the LoginContext.login method.
Parameters:
  callbackHandlers - Array of JAASAuthenticationCallbackHandlers



setLoginConfig
public void setLoginConfig(Resource loginConfig)(Code)
Set the JAAS login configuration file.
Parameters:
  loginConfig - SpringResource
See Also:    JAAS Reference



setLoginContextName
public void setLoginContextName(String loginContextName)(Code)
Set the loginContextName, this name is used as the index to the configuration specified in the loginConfig property.
Parameters:
  loginContextName -



setLoginExceptionResolver
public void setLoginExceptionResolver(LoginExceptionResolver loginExceptionResolver)(Code)



supports
public boolean supports(Class aClass)(Code)



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.