Pls, give some example Acegi usage in the servlets.
How can I use it in the servlets? I'd like to look at some example.
I'm not very experienced in jstl.
1.
What's value for: <form action="<c:url value='j_security_check'/>" method="POST">? How to set/get it? It seems action just has a value 'j_security_check' and that's all. Is it correct?
What to do with application-context XML settings?
<bean id="authenticationProcessingFilter" class="net.sf.acegisecurity.ui.webapp.Authenticati onProcessingFilter">.........
<property name="authenticationFailureUrl"><value>/acegilogin.jsp?login_error=1</value></property>
<property name="defaultTargetUrl"><value>/</value></property>
<property name="filterProcessesUrl"><value>/j_acegi_security_check</value></property>
........
<bean id="authenticationProcessingFilterEntryPoint" class="net.sf.acegisecurity.ui.webapp.Authenticati onProcessingFilterEntryPoint">
<property name="loginFormUrl"><value>/acegilogin.jsp</value></property>
........
2. The second part of the question.
I need instance-based ACL so I looked 'contacts.war'. I have 'transaction supported' component which should be controlled with ACL. So I used 'contacts example' and wrote:
.....
<bean id="backendContactManagerTarget" class="business.CommunityManagerImpl"/>......
I'm getting error:
.....
Context initialization failed org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'backendContactManagerTarget' defined in resource [/WEB-INF/applicationContext-hibernate.xml] of ServletContext: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: sessionFactory or hibernateTemplate is required java.lang.IllegalArgumentException: sessionFactory or hibernateTemplate is required.
That's correct. So I changed this bean to:
<bean id="backendCommunityManagerTarget" parent="baseTransactionProxy">
<property name="target" >
<bean class="CommunityManagerImpl">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
</property>
</bean>
So I'm getting several errors for every 'acegi filter' from the web.xml:
..........
INFO [DefaultListableBeanFactory] Creating shared instance of singleton bean 'channelProcessingFilter'
INFO [DefaultListableBeanFactory] Creating shared instance of singleton bean 'channelDecisionManager'
INFO [DefaultListableBeanFactory] Creating shared instance of singleton bean 'secureChannelProcessor'
INFO [DefaultListableBeanFactory] Creating shared instance of singleton bean 'insecureChannelProcessor'
INFO [ChannelProcessingFilter] Validated configuration attributes
INFO [DefaultListableBeanFactory] Creating shared instance of singleton bean 'authenticationProcessingFilter'
INFO [DefaultListableBeanFactory] Creating shared instance of singleton bean 'securityEnforcementFilter'
INFO [DefaultListableBeanFactory] Creating shared instance of singleton bean 'filterInvocationInterceptor'
INFO [DefaultListableBeanFactory] Creating shared instance of singleton bean 'httpRequestAccessDecisionManager'
INFO [AbstractSecurityInterceptor] Validated configuration attributes
INFO [DefaultListableBeanFactory] Creating shared instance of singleton bean 'authenticationProcessingFilterEntryPoint'
INFO [ContextLoader] Using context class [org.springframework.web.context.support.XmlWebAppl icationContext] for root WebApplicationContext
INFO [ContextLoader] Published root WebApplicationContext [org.springframework.web.context.support.XmlWebAppl icationContext: displayName=[Root XmlWebApplicationContext]; startup date=[Mon Nov 01 17:39:23 EET 2004]; root of ApplicationContext hierarchy; config locations=[/WEB-INF/applicationContext-hibernate.xml]; ] as ServletContext attribute with name [interface org.springframework.web.context.WebApplicationCont ext.ROOT]
1) ERROR [Engine] StandardContext[]Exception starting filter Acegi Authentication Processing Filter org.springframework.beans.factory.BeanIsAbstractEx ception: Tried to instantiate abstract bean definition '&baseTransactionProxy'
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:177)
.........
2) ERROR [Engine] StandardContext[]Exception starting filter Acegi Security System for Spring Auto Integration Filter org.springframework.beans.factory.BeanIsAbstractEx ception: Tried to instantiate abstract bean definition '&baseTransactionProxy'
.........
3) ERROR [Engine] StandardContext[]Exception starting filter Acegi Channel Processing Filter
org.springframework.beans.factory.BeanIsAbstractEx ception: Tried to instantiate abstract bean definition '&baseTransactionProxy'
.......
4) ERROR [Engine] StandardContext[]Exception starting filter Acegi HTTP Request Security Filter org.springframework.beans.factory.BeanIsAbstractEx ception: Tried to instantiate abstract bean definition '&baseTransactionProxy'
........
5) ERROR [Engine] StandardContext[]Exception starting filter Acegi HTTP BASIC Authorization Filter org.springframework.beans.factory.BeanIsAbstractEx ception: Tried to instantiate abstract bean definition '&baseTransactionProxy'
..........
But I have other 'transaction supported' componets and they work fine.
<bean id="baseTransactionProxy" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean"
abstract="true">
<property name="transactionManager">
<ref bean="transactionManager"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
..........
</props>
</property>
</bean>
<bean id="questionManager" parent="baseTransactionProxy">
<property name="target">
<bean class="business.QuestionnaireManagerImpl">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
</property>
</bean>
What's wrong with component which must be 'transactional + secured'?
I've tried another configuration:
<bean id="communityManagerFacade" class="org.springframework.aop.framework.ProxyFact oryBean">
<property name="proxyInterfaces"><value>business.CommunityMa nager</value></property>
<property name="target"><ref local="backendCommunityManagerTarget"/></property>
<property name="interceptorNames">
<list>
<idref local="publicCommunityManagerSecurity"/>
</list>
</property>
</bean>
........
<bean id="backendCommunityManagerTarget" parent="baseTransactionProxy">
<property name="target" >
<bean class="business.CommunityManagerImpl">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
</property>
</bean>
The result is the same - errors for every acegi filter.
3.
Where I can put my 'own' filter which corrects encoding, before or after 'Acegi filters'? I tried both approaches but result is the same.
<filter>
<filter-name>WebAction</filter-name>
<filter-class>web.WebAction</filter-class>
<init-param>
<param-name>requestEncoding</param-name>
<param-value>Cp1251</param-value>
</init-param>
</filter>
Thanks in advance.