Hey Adam,
got run_as and the secured annotations working with your sample, thx ! I had to do some mods because i do the authentication in EJB and i use a converter that transfer the EJB/JAAS UserDetails into the SecuriyContextHolder of Spring.
PHP Code:
<bean id="preAuthenticatedAuthenticationProvider"
class="org.springframework.security.providers.preauth.PreAuthenticatedAuthenticationProvider">
<security:custom-authentication-provider />
<property name="preAuthenticatedUserDetailsService" ref="preAuthenticatedUserDetailsService" />
</bean>
<bean id="preAuthenticatedUserDetailsService"
class="org.springframework.security.providers.preauth.PreAuthenticatedGrantedAuthoritiesUserDetailsService" />
<bean id="accessDecisionManager" class="org.springframework.security.vote.UnanimousBased">
<property name="allowIfAllAbstainDecisions" value="false"/>
<property name="decisionVoters">
<list><bean class="org.springframework.security.vote.RoleVoter"/></list>
</property>
</bean>
<bean id="objectDefinitionSource"
class="org.springframework.security.annotation.SecuredMethodDefinitionSource" />
<bean id="securityInterceptor"
class="org.springframework.security.intercept.method.aopalliance.MethodSecurityInterceptor">
<property name="validateConfigAttributes" value="false"/>
<property name="authenticationManager" ref="_authenticationManager" />
<property name="accessDecisionManager" ref="accessDecisionManager" />
<property name="runAsManager" ref="runAsManager" />
<property name="objectDefinitionSource" ref="objectDefinitionSource" />
</bean>
<bean id="autoproxy"
class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator">
</bean>
<bean id="methodSecurityAdvisor"
class="org.springframework.security.intercept.method.aopalliance.MethodDefinitionSourceAdvisor" autowire="constructor">
</bean>
<bean id="runAsManager" class="org.springframework.security.runas.RunAsManagerImpl">
<property name="key" value="run_as_password" />
</bean>
<bean id="runAsAuthenticationProvider"
class="org.springframework.security.runas.RunAsImplAuthenticationProvider">
<property name="key" value="run_as_password" />
</bean>
<bean id="springbean"
class="com.tmp.dev.evaluation.clientbean.SpringbeanImpl">
</bean>
Security.log
Code:
2009-03-17 15:39:32,350 DEBUG [p: thread-pool-1; w: 3] org.springframework.security.intercept.method.AbstractFallbackMethodDefinitionSource: Adding security method [CacheKey[com.tmp.dev.evaluation.clientbean.SpringbeanImpl; public java.lang.String com.tmp.dev.evaluation.clientbean.SpringbeanImpl.print2()]] with attribute [[ROLE_PATIENT_MANAGER]]
2009-03-17 15:39:37,865 DEBUG [p: thread-pool-1; w: 3] org.springframework.security.intercept.method.AbstractFallbackMethodDefinitionSource: Adding security method [CacheKey[com.tmp.dev.evaluation.clientbean.SpringbeanImpl; public abstract java.lang.String com.tmp.dev.evaluation.clientbean.Springbean.callWs()]] with attribute [[RUN_AS_SERVER_IN_CLIENT, ROLE_PATIENT_MANAGER]]
2009-03-17 15:39:37,881 DEBUG [p: thread-pool-1; w: 3] org.springframework.security.intercept.AbstractSecurityInterceptor: Secure object: ReflectiveMethodInvocation: public abstract java.lang.String com.tmp.dev.evaluation.clientbean.Springbean.callWs(); target is of class [com.tmp.dev.evaluation.clientbean.SpringbeanImpl]; ConfigAttributes: [RUN_AS_SERVER_IN_CLIENT, ROLE_PATIENT_MANAGER]
2009-03-17 15:39:37,881 DEBUG [p: thread-pool-1; w: 3] org.springframework.security.intercept.AbstractSecurityInterceptor: Previously Authenticated: org.springframework.security.providers.preauth.PreAuthenticatedAuthenticationToken@80e23133: Principal: com.tmp.security.UserDetailsImpl@1f60800: Username: test; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_PATIENT_MANAGER, ROLE_PATIENT_PROCESSOR; Password: [PROTECTED]; Authenticated: true; Details: null; Granted Authorities: ROLE_PATIENT_MANAGER, ROLE_PATIENT_PROCESSOR
2009-03-17 15:39:37,881 DEBUG [p: thread-pool-1; w: 3] org.springframework.security.intercept.AbstractSecurityInterceptor: Authorization successful
2009-03-17 15:39:37,897 DEBUG [p: thread-pool-1; w: 3] org.springframework.security.intercept.AbstractSecurityInterceptor: Switching to RunAs Authentication: org.springframework.security.runas.RunAsUserToken@665a74ca: Principal: com.tmp.security.UserDetailsImpl@1f60800: Username: test; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Granted Authorities: ROLE_PATIENT_MANAGER, ROLE_PATIENT_PROCESSOR; Password: [PROTECTED]; Authenticated: true; Details: null; Granted Authorities: ROLE_RUN_AS_SERVER_IN_CLIENT, ROLE_PATIENT_MANAGER, ROLE_PATIENT_PROCESSOR; Original Class: org.springframework.security.providers.preauth.PreAuthenticatedAuthenticationToken
now the Security.log looks fine. "Switching to RunAs Authentication"
next step for me is, that i have to do a converter that pass the run_as information back to the EJB which calls the Springbean.
I'll keep monitoring the ticket you opend maybe it will make a smaller xml config possible .
thx again
Philipp