Announcement Announcement Module
Collapse
No announcement yet.
Login and ChannelSet Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Login and ChannelSet

    I am having some difficulty understanding how authentication works with Spring BlazeDS. I have looked through the testdrive examples, and I can understand that a ChannelSet is used, however, I am unsure about how to handle failures, or even determining whether the user is already logged in (it seems an IllegalOperationError is thrown if the user is already logged in).

    Does anyone know of some examples where one handles authentication failures with ChannelSet.login?

  • #2
    you can do something like this, if it's the flex side you were referring to:


    var token:AsyncToken = channelSet.login(username, password);
    token.addResponder(new Responder(loginHandler, faultHandler);

    hope this helps.

    Comment


    • #3
      Yes, the post was about the flex side.

      The code looks simple enough. Thanks!

      Comment


      • #4
        Help setting up Login and ChannelSet

        Can someone help me with the proper configuration for making the org.springframework.flex.messaging.security.Spring SecurityLoginCommand work?

        The reference documentation says that using the secured namespace is enough to get this working, but I'm thinking that this isn't right, since I'm not able to login properly using this login command.

        Here's my configuration:

        from spring config file:

        <flex:message-broker>
        <flex:secured />
        </flex:message-broker>

        from Login.mxml, using Cairngorm:

        <mx:AMFChannel id="myamf" uri="/localhost:8080/app/messagebroker/amf"/>

        <mx:ChannelSet id="channelSet" channels="{[myamf]}"/>

        private function doLogin() : void {
        var event : LoginEvent = new LoginEvent();
        event.login = loginTxt.text;
        event.password = passwordTxt.text;
        event.channelSet = channelSet;
        CairngormEventDispatcher.getInstance().dispatchEve nt( event );
        }

        from Login command object, which implements IResponder:

        override public function execute( event : CairngormEvent ) : void {
        var loginEvent : LoginEvent = LoginEvent( event );
        var login : String = loginEvent.login;
        var password : String = loginEvent.password;
        var channelSet : ChannelSet = loginEvent.channelSet;
        var token : AsyncToken = channelSet.login( login, password );
        token.addResponder( this );
        }

        override public function result( event : Object ) : void {
        ModelLocator.getInstance().authenticated = true;
        }

        override public function fault( event : Object ) : void {
        var faultEvent : FaultEvent = FaultEvent( event );
        var exception : String = faultEvent.fault.faultString;
        if ( exception.indexOf( "BadCredentials" ) != -1 ) {
        Alert.show( "User and/or Password Invalid!" );
        }
        }

        Nothing happens after the execute method is called in the command object.

        Any ideas?

        Comment


        • #5
          Channelset.login

          Hi,

          I am also new to this channelset login / spring security.

          But I can just explain what I have done and it seems to be working to an extent.

          Currently using SpringBlazeDSM2 and flex 3

          ok now in my flex Login form I have the username and password. and click of login button


          Code:
           var token:AsyncToken = ro.channelSet.login(username.text, password.text);
                         token.addResponder(new AsyncResponder(resultHandler, faultHandler));
          
           private function resultHandler(event:ResultEvent,token : AsyncToken):void
                      {
                      	
                      	
                           parentApplication.loadModule("amsmodule.swf");
            				 return;
                        
                      }

          on successful login I load another module. if failed throw a message in fault handler method.


          Now on the Spring side I have implemeted UserDetails and UserDetailService

          Code:
          public class MyUserDetails implements UserDetails {
          	private String username;
              private String password;
            
           
          	
          	 private boolean accountNonExpired;
               private boolean accountNonLocked;
               private boolean credentialsNonExpired=true;
               private boolean enabled=true;
               private String  designation;
          	
          // And getter setter
          
          }
          MyUserDetailsService Implementation

          Code:
          public class MyUserDetailsService implements UserDetailsService {
          	
          	 
          
          	public UserDetails loadUserByUsername(String username)
          			throws UsernameNotFoundException, DataAccessException  {
          //code to get user details from Database, based on user name sent	
          }

          In My web-application-security.xml

          Code:
          <security:authentication-provider user-service-ref="customUserDetailsService"/>
          And in my Web-application-config.xml

          Code:
          <bean id="customUserDetailsService" class="com.MyUserDetailsService" />

          ok I think i have given all the code, which is currently running for me.
          Hope this helps you.

          Comment


          • #6
            Thanks

            The problem was with the channel setting:

            Should be:

            <mx:AMFChannel id="myamf" uri="/app/messagebroker/amf"/>

            instead of :

            <mx:AMFChannel id="myamf" uri="/localhost:8080/app/messagebroker/amf"/>

            Comment


            • #7
              Login problem

              Originally posted by kannanMugundan View Post
              Hi,

              I am also new to this channelset login / spring security.

              But I can just explain what I have done and it seems to be working to an extent.

              Currently using SpringBlazeDSM2 and flex 3

              ok now in my flex Login form I have the username and password. and click of login button


              Code:
               var token:AsyncToken = ro.channelSet.login(username.text, password.text);
                             token.addResponder(new AsyncResponder(resultHandler, faultHandler));
              
               private function resultHandler(event:ResultEvent,token : AsyncToken):void
                          {
                          	
                          	
                               parentApplication.loadModule("amsmodule.swf");
                				 return;
                            
                          }

              on successful login I load another module. if failed throw a message in fault handler method.


              Now on the Spring side I have implemeted UserDetails and UserDetailService

              Code:
              public class MyUserDetails implements UserDetails {
              	private String username;
                  private String password;
                
               
              	
              	 private boolean accountNonExpired;
                   private boolean accountNonLocked;
                   private boolean credentialsNonExpired=true;
                   private boolean enabled=true;
                   private String  designation;
              	
              // And getter setter
              
              }
              MyUserDetailsService Implementation

              Code:
              public class MyUserDetailsService implements UserDetailsService {
              	
              	 
              
              	public UserDetails loadUserByUsername(String username)
              			throws UsernameNotFoundException, DataAccessException  {
              //code to get user details from Database, based on user name sent	
              }

              In My web-application-security.xml

              Code:
              <security:authentication-provider user-service-ref="customUserDetailsService"/>
              And in my Web-application-config.xml

              Code:
              <bean id="customUserDetailsService" class="com.MyUserDetailsService" />

              ok I think i have given all the code, which is currently running for me.
              Hope this helps you.


              Hello Mr. Kannan,

              I am new to spring and i am implementing spring security using FLEX -blazeds. What is "ro" in your code ?


              Can you please provide the Login form sample code, and how it is calling the Java function. ?


              Kindly try to post the complete code for it, it would be of great help !!

              Thanks

              Comment


              • #8
                Hi,

                ro is remote Object

                Code:
                <mx:RemoteObject id = "ro" destination = "LoginMgt" />
                Thanks

                Comment

                Working...
                X