Java Doc for PortletSessionContextIntegrationInterceptor.java in  » Security » acegi-security » org » acegisecurity » context » 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.context 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.acegisecurity.context.PortletSessionContextIntegrationInterceptor

PortletSessionContextIntegrationInterceptor
public class PortletSessionContextIntegrationInterceptor implements InitializingBean,HandlerInterceptor(Code)

This interceptor populates the SecurityContextHolder with information obtained from the PortletSession. It is applied to both ActionRequests and RenderRequests

The PortletSession will be queried to retrieve the SecurityContext that should be stored against the SecurityContextHolder for the duration of the portlet request. At the end of the request, any updates made to the SecurityContextHolder will be persisted back to the PortletSession by this interceptor.

If a valid SecurityContext cannot be obtained from the PortletSession for whatever reason, a fresh SecurityContext will be created and used instead. The created object will be of the instance defined by the PortletSessionContextIntegrationInterceptor.setContext(Class) method (which defaults to org.acegisecurity.context.SecurityContextImpl .

A PortletSession may be created by this interceptor if one does not already exist. If at the end of the portlet request the PortletSession does not exist, one will only be created if the current contents of the SecurityContextHolder are not the java.lang.Object.equals to a new instance of PortletSessionContextIntegrationInterceptor.context . This avoids needless PortletSession creation, and automates the storage of changes made to the SecurityContextHolder. There is one exception to this rule, that is if the PortletSessionContextIntegrationInterceptor.forceEagerSessionCreation property is true, in which case sessions will always be created irrespective of normal session-minimization logic (the default is false, as this is resource intensive and not recommended).

If for whatever reason no PortletSession should ever be created, the PortletSessionContextIntegrationInterceptor.allowSessionCreation property should be set to false. Only do this if you really need to conserve server memory and ensure all classes using the SecurityContextHolder are designed to have no persistence of the SecurityContext between web requests. Please note that if PortletSessionContextIntegrationInterceptor.forceEagerSessionCreation is true, the allowSessionCreation must also be true (setting it to false will cause a startup-time error).

This interceptor must be executed before

any authentication processing mechanisms. These mechanisms (specifically org.acegisecurity.ui.portlet.PortletProcessingInterceptor ) expect the SecurityContextHolder to contain a valid SecurityContext by the time they execute.

An important nuance to this interceptor is that (by default) the SecurityContext is stored into the APPLICATION_SCOPE of the PortletSession. This doesn't just mean you will be sharing it with all the other portlets in your webapp (which is generally a good idea). It also means that (if you have done all the other appropriate magic), you will share this SecurityContext with servlets in your webapp. This is very useful if you have servlets serving images or processing AJAX calls from your portlets since they can now use the HttpSessionContextIntegrationFilter to access the same SecurityContext object from the session. This allows these calls to be secured as well as the portlet calls.

Much of the logic of this interceptor comes from the HttpSessionContextIntegrationFilter class which fills the same purpose on the servlet side. Ben Alex and Patrick Burlson are listed as authors here because they are the authors of that class and there are blocks of code that essentially identical between the two. (Making this a good candidate for refactoring someday.)

Unlike HttpSessionContextIntegrationFilter, this interceptor does not check to see if it is getting applied multiple times. This shouldn't be a problem since the application of interceptors is under the control of the Spring Portlet MVC framework and tends to be more explicit and more predictable than the application of filters. However, you should still be careful to only apply this inteceptor to your request once.


author:
   John A. Lewis
author:
   Ben Alex
author:
   Patrick Burleson
since:
   2.0
version:
   $Id$


Field Summary
final public static  StringACEGI_SECURITY_CONTEXT_KEY
    
final protected static  Loglogger
    

Constructor Summary
public  PortletSessionContextIntegrationInterceptor()
    

Method Summary
public  voidafterActionCompletion(ActionRequest request, ActionResponse response, Object handler, Exception ex)
    
public  voidafterPropertiesSet()
    
public  voidafterRenderCompletion(RenderRequest request, RenderResponse response, Object handler, Exception ex)
    
public  SecurityContextgenerateNewContext()
     Creates a new SecurityContext object.
public  ClassgetContext()
    
public  booleanisAllowSessionCreation()
    
public  booleanisCloneFromPortletSession()
    
public  booleanisForceEagerSessionCreation()
    
public  booleanisUseApplicationScopePortletSession()
    
public  voidpostHandleRender(RenderRequest request, RenderResponse response, Object handler, ModelAndView modelAndView)
    
public  booleanpreHandleAction(ActionRequest request, ActionResponse response, Object handler)
    
public  booleanpreHandleRender(RenderRequest request, RenderResponse response, Object handler)
    
public  voidsetAllowSessionCreation(boolean allowSessionCreation)
    
public  voidsetCloneFromPortletSession(boolean cloneFromPortletSession)
    
public  voidsetContext(Class secureContext)
    
public  voidsetForceEagerSessionCreation(boolean forceEagerSessionCreation)
    
public  voidsetUseApplicationScopePortletSession(boolean useApplicationScopePortletSession)
    

Field Detail
ACEGI_SECURITY_CONTEXT_KEY
final public static String ACEGI_SECURITY_CONTEXT_KEY(Code)



logger
final protected static Log logger(Code)




Constructor Detail
PortletSessionContextIntegrationInterceptor
public PortletSessionContextIntegrationInterceptor() throws PortletException(Code)




Method Detail
afterActionCompletion
public void afterActionCompletion(ActionRequest request, ActionResponse response, Object handler, Exception ex) throws Exception(Code)



afterPropertiesSet
public void afterPropertiesSet() throws Exception(Code)



afterRenderCompletion
public void afterRenderCompletion(RenderRequest request, RenderResponse response, Object handler, Exception ex) throws Exception(Code)



generateNewContext
public SecurityContext generateNewContext() throws PortletException(Code)
Creates a new SecurityContext object. The specific class is determined by the setting of the PortletSessionContextIntegrationInterceptor.context property. the new SecurityContext
throws:
  PortletException - if the creation throws an InstantiationException oran IllegalAccessException, then this method will wrap them in aPortletException



getContext
public Class getContext()(Code)



isAllowSessionCreation
public boolean isAllowSessionCreation()(Code)



isCloneFromPortletSession
public boolean isCloneFromPortletSession()(Code)



isForceEagerSessionCreation
public boolean isForceEagerSessionCreation()(Code)



isUseApplicationScopePortletSession
public boolean isUseApplicationScopePortletSession()(Code)



postHandleRender
public void postHandleRender(RenderRequest request, RenderResponse response, Object handler, ModelAndView modelAndView) throws Exception(Code)



preHandleAction
public boolean preHandleAction(ActionRequest request, ActionResponse response, Object handler) throws Exception(Code)



preHandleRender
public boolean preHandleRender(RenderRequest request, RenderResponse response, Object handler) throws Exception(Code)



setAllowSessionCreation
public void setAllowSessionCreation(boolean allowSessionCreation)(Code)



setCloneFromPortletSession
public void setCloneFromPortletSession(boolean cloneFromPortletSession)(Code)



setContext
public void setContext(Class secureContext)(Code)



setForceEagerSessionCreation
public void setForceEagerSessionCreation(boolean forceEagerSessionCreation)(Code)



setUseApplicationScopePortletSession
public void setUseApplicationScopePortletSession(boolean useApplicationScopePortletSession)(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.