Hi there:
I have a Flex project that is successfully authenticating users using spring-security via spring-blazeds integration. For completeness sake, my backend is configured as follows:
spring-flex.xml
spring-security.xmlCode:<?xml version="1.0" encoding="UTF-8"?> <beans> <import resource="classpath:core/main-context.xml" /> <flex:message-broker> <flex:secured /> </flex:message-broker> <bean id="userService" class="com.mymodules.security.service.spring.UserServiceImpl"> <constructor-arg ref="userDao" /> <flex:remote-service /> </bean> </beans>
The above “userService” bean is an instance of my custom class, UserServiceImpl, which implements the interface org.springframework.security.userdetails.UserDetai lsService:Code:<?xml version="1.0" encoding="UTF-8"?> <beans> <http auto-config="true" session-fixation-protection="none"/> <authentication-provider user-service-ref='userService'/> </beans>
As most of you probably know, UserDetails contains the various roles associated with a user: these can be retrieved via the UserDetails.getAuthorities() method.Code:UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException;
For blazeDs configuration I have:
WEB-INF/flex/services-config.xml
Now, on the front-end, I have an ActionScript UserDelagate.as class which performs login/logout via a ChannelSet; the relavant snippet:Code:<?xml version="1.0" encoding="UTF-8"?> <services-config> <services> <default-channels> <channel ref="my-amf" /> </default-channels> </services> <channels> <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel"> <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint" /> <properties> <polling-enabled>false</polling-enabled> </properties> </channel-definition> </channels> </services-config>
Finally, on the clien-side, I inject the ChannelSet into the UserDelegate via spring-actionscript:Code:public function UserDelegate( channelSet:ChannelSet ) { this.service = channelSet; this.service.addEventListener( ResultEvent.RESULT, onSuccess ); this.service.addEventListener( FaultEvent.FAULT, onFailure ); } public function login( username:String, password:String ):void { service.login( username, password ); } public function logout():void { service.logout(); }
spring-client.xml
This is all presently working. Now, what I'd like to do is to extract the user roles from the UserDetails object resulting from the invocation of the UserService.loadUserByUsername method on the backend (which gets triggered by the UserDelegate.login method in the flex client). Can this be done in a single call? I'd like to avoid having to perform two distinct invocations (one for login and one for userService) every time the user logs in.Code:<?xml version="1.0" encoding="utf-8"?> <objects> <property file="properties.config" /> <!-- Remote Services --> <object id="channelSet" class="mx.messaging.ChannelSet"> <method-invocation name="addChannel"> <arg> <object id="amfChannel" class="mx.messaging.channels.AMFChannel"> <property name="url" value="http://${host}:${port}/${context-root}/messagebroker/amf" /> </object> </arg> </method-invocation> </object> <!-- Business Delegates --> <object id="delegateLocator" class="hc.control.delegates.DelegateLocator" factory-method="getInstance" > <property name="userDelegate"> <object class="hc.control.delegates.UserDelegate" > <constructor-arg ref="channelSet"/> </object> </property> </object> </objects>
Any help or ideas is greatly appreciated.
Thanks in advanced.


Reply With Quote
