How can I check Spring Security for user authentication and get roles from Flex? -
I am using Spring, Spring Security, Blaze's, Flex and Spring Flex.
I know that I can hook up to channelSet.login ()
and channelSet.logout ()
in the Spring Protection for authentication. channelSet.authenticated
apparently only knows about the current Flex session, because it always closes as false , as long as you channelSet. Login ()
do not call.
What do I want to do:
- Check with Flex to know if a user is already in one session.
- If so, I want the user names and roles.
UPDATE
I thought I would add a description of the solution used with the answer given below so that it would be easy for someone else to I used the stack overflow response to make the security console
injectable. I will not rewrite the code from that reply in this answer, so look for it for SecurityContextFacade
.
securityServiceImpl.java
Public class protection service applies the original security service {Private SecurityContactFacade SecurityContaxFacade; @ Secure ({"ROLE_PEON"}) public map & lt; String, Object & gt; GetUserDetails () {map & lt; String, Object & gt; UserSessionDetails = New Hashmap & lt; String, Object & gt; (); Security reference reference = securitycontactfactedgatecontext (); Authentication auth = context.getAuthentication (); UserDetails userDetails = (UserDetails) auth.getPrincipal (); ArrayList roles = new ArrayList (); Given authority [] The Reillaus = User Daffel Gate officer (); For (int i = 0; i
securityContext.xml
& lt; Security: http auto-config = "true" & gt; & Lt ;! - Do not certify Flex app - & gt; & Lt; Security: Block-url pattern = "/ flexAppDir / **" access = "IS_AUTHENTICATED_ANONYMOUSLY" /> & Lt ;! - Do not certify remote calls - & gt; & Lt; Security: blocking-url pattern = "/ message broker / amfsecure" access = "IS_AUTHENTICATED_ANONYMOUSLY" /> & Lt; / Security: http & gt; & Lt; Security: global-law-security secure-annotation = "enabled" /> & Lt; Bean id = "security service" class = "ext.domain.project.service.SecurityServiceImpl" & gt; & Lt; Property Name = "SecurityContextFacade" ref = "SecurityContextFaked" /> & Lt; / Bean & gt; & Lt; Bean id = "SecurityContextFace" class = "ext.domain.spring.security.SecurityContextHolderFacade" />
flexContext.xml
& lt; Flex: Message-broker & gt; & Lt; Flex: safe /> & Lt; / Flex: message-broker & gt; & Lt; Flex: remoting-destination ref = "security service" /> & Lt; Security: http auto-config = "true" session-protected-security = "none" />
FlexSecurityTest.mxml
& lt; Mx: application ... creationComplete = "init ()" & gt; & Lt; Mx: script & gt; & Lt ;! [Cdata [[bindable] private warranty user data: user develope; // Private Function Init () to keep user details for custom VOs: zero {security.getUserDetails (); } Private Function showFault (E: FaultEvent): Zero {if (e.fault.faultCode == "Client.Authorization") {Alert.show ("You need to login."); // Show login form} Other {// Submit a ticket}} Personal Function Showstate (E: resultant event): zero {userDetails = new UserDetails (); UserDetails.username = e.result.username; UserDetails.roles = E. Res. Rol; // show the show user}] & gt; & Lt; / Mx: script & gt; & Lt; Mx: Remote object id = "security" destination = "security service" & gt; & Lt; Mx: method name = "getUserDetails" mistake = "default (event)" result = "showResult (event)" /> & Lt; / Mx: RemoteObject & gt; ... & lt; / Mx: Applications & gt;
If you use, you can use org.springframework.flex.security Can get the GetUserDetails method implemented. Authentication highlights
Public map & lt; String, Object & gt; GetUserDetails () {Return AuthenticationAdditional Availability Authentication Usage (); }
Comments
Post a Comment