You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by Ronny Shibley <rs...@codefish.com> on 2015/04/03 14:28:42 UTC

Flex BlazeDS RemoteObject HttpHeader

Dear Flex Users.

I am trying to pass parameters to RemoteObject service calls. Basically I
need to pass the app version, username, userid... without having to modify
all my existing functions...

I want be able to retrieve those in a servlet filter.

Anyone done this before ?

Kind Regards,


Ronny Shibley, Eng



Software Architect | Codefish | www.codefish.com

t +961 5 450824 | m +961 70 250650



<https://goo.gl/maps/UcEGK>

Re: Flex BlazeDS RemoteObject HttpHeader

Posted by Ronny Shibley <rs...@codefish.com>.
Thanks Keegan and Chris.

I finally got it to work by adding the variable to AsyncToken Headers and
overriden the JavaAdapter in order to retrieved it from IMessage
getHeader("var").

@Chris: So looking forward to migrate to Apache BlazeDS. Will try it over
the weekend :)


Kind Regards,


Ronny Shibley, Eng



Software Architect | Codefish | www.codefish.com

t +961 5 450824 | m +961 70 250650



<https://goo.gl/maps/UcEGK>

On Fri, Apr 3, 2015 at 7:17 PM, Christofer Dutz <ch...@c-ware.de>
wrote:

> In my applications I use spring-flex using BlazeDS and authenticate the
> channel-set
>
> https://github.com/spring-projects/spring-flex#readme
>
> Especially have a look at the examples especially this one as I think it
> does what you are looking for:
>
> https://github.com/spring-projects/spring-flex/tree/master/spring-flex-samples/spring-flex-testdrive/secured
>
> It works great with Apache BalzeDS, which we released a few weeks ago.
>
> Chris
>
> PS: Think I should fork that repo, do sume adjustments that it works with
> Apache BlazeDS instead of Adobe BlazeDS and issue a pull-request ;-)
>
>
> -----Ursprüngliche Nachricht-----
> Von: KSands@loftware.com [mailto:KSands@loftware.com]
> Gesendet: Freitag, 3. April 2015 15:02
> An: users@flex.apache.org
> Betreff: RE: Flex BlazeDS RemoteObject HttpHeader
>
> Hi,
>
> I had to do something like that a couple years ago, but with GraniteDS.
> Basically I had to send the locale of the user to the server so any error
> messages they might receive from the server would be in the correct
> language.  I was able to add a new property to the token’s message.headers
> object.  On the server side I was able to get the granite context and
> access the header with my property on it.  We ended up storing it as an
> attribute on the session, but you can do what you like.
>
> Client side where login occurs
> public function doLogin(user:String, pwd:String, locale:String,
> channelSet:ChannelSet = null):void{
>        var token:AsyncToken = null;
>
> token = RemoteObject(service).channelSet.login(user,pwd);
>
>        // Adding locale to headers so the server
>        // can access the user's locale.
>        // Adding the locale to the CommandMessage's headers map.
>        token.message.headers[“com.foo.locale”] = locale;
>        token.addResponder(responder);
> }
>
> Server side where login occurs
> @Override
> public void login(Object credentials, String charset) throws
> SecurityServiceException {
>
> HttpGraniteContext graniteContext =
> (HttpGraniteContext)GraniteContext.getCurrentInstance();
>        String locale =
> (String)graniteContext.getAMFContext().getRequest().getHeader(LOCALE_HEADER);
>
> }
>
> Keegan Sands
> Technical Lead
> T: +1-603-570-4633
> www.loftware.com<http://www.loftware.com/>
>
> From: Ronny Shibley [mailto:rshibley@codefish.com]
> Sent: Friday, April 03, 2015 8:29 AM
> To: users@flex.apache.org
> Subject: Flex BlazeDS RemoteObject HttpHeader
>
> Dear Flex Users.
>
> I am trying to pass parameters to RemoteObject service calls. Basically I
> need to pass the app version, username, userid... without having to modify
> all my existing functions...
>
> I want be able to retrieve those in a servlet filter.
>
> Anyone done this before ?
>
>
> Kind Regards,
>
>
>
> Ronny Shibley, Eng
>
>
>
> Software Architect | Codefish | www.codefish.com<http://www.codefish.com>
>
> t +961 5 450824<tel:%2B961%205%20450824> | m +961 70 250650
> <tel:%2B961%2070%20250650>
>
>
>
> [cid:image001.png@01D00AF0.78A9FF20]<https://goo.gl/maps/UcEGK>
>

AW: Flex BlazeDS RemoteObject HttpHeader

Posted by Christofer Dutz <ch...@c-ware.de>.
In my applications I use spring-flex using BlazeDS and authenticate the channel-set 

https://github.com/spring-projects/spring-flex#readme

Especially have a look at the examples especially this one as I think it does what you are looking for:
https://github.com/spring-projects/spring-flex/tree/master/spring-flex-samples/spring-flex-testdrive/secured

It works great with Apache BalzeDS, which we released a few weeks ago.

Chris

PS: Think I should fork that repo, do sume adjustments that it works with Apache BlazeDS instead of Adobe BlazeDS and issue a pull-request ;-)


-----Ursprüngliche Nachricht-----
Von: KSands@loftware.com [mailto:KSands@loftware.com] 
Gesendet: Freitag, 3. April 2015 15:02
An: users@flex.apache.org
Betreff: RE: Flex BlazeDS RemoteObject HttpHeader

Hi,

I had to do something like that a couple years ago, but with GraniteDS.  Basically I had to send the locale of the user to the server so any error messages they might receive from the server would be in the correct language.  I was able to add a new property to the token’s message.headers object.  On the server side I was able to get the granite context and access the header with my property on it.  We ended up storing it as an attribute on the session, but you can do what you like.

Client side where login occurs
public function doLogin(user:String, pwd:String, locale:String,  channelSet:ChannelSet = null):void{
       var token:AsyncToken = null;

token = RemoteObject(service).channelSet.login(user,pwd);

       // Adding locale to headers so the server
       // can access the user's locale.
       // Adding the locale to the CommandMessage's headers map.
       token.message.headers[“com.foo.locale”] = locale;
       token.addResponder(responder);
}

Server side where login occurs
@Override
public void login(Object credentials, String charset) throws SecurityServiceException {

HttpGraniteContext graniteContext = (HttpGraniteContext)GraniteContext.getCurrentInstance();
       String locale = (String)graniteContext.getAMFContext().getRequest().getHeader(LOCALE_HEADER);

}

Keegan Sands
Technical Lead
T: +1-603-570-4633
www.loftware.com<http://www.loftware.com/>

From: Ronny Shibley [mailto:rshibley@codefish.com]
Sent: Friday, April 03, 2015 8:29 AM
To: users@flex.apache.org
Subject: Flex BlazeDS RemoteObject HttpHeader

Dear Flex Users.

I am trying to pass parameters to RemoteObject service calls. Basically I need to pass the app version, username, userid... without having to modify all my existing functions...

I want be able to retrieve those in a servlet filter.

Anyone done this before ?


Kind Regards,



Ronny Shibley, Eng



Software Architect | Codefish | www.codefish.com<http://www.codefish.com>

t +961 5 450824<tel:%2B961%205%20450824> | m +961 70 250650<tel:%2B961%2070%20250650>



[cid:image001.png@01D00AF0.78A9FF20]<https://goo.gl/maps/UcEGK>

RE: Flex BlazeDS RemoteObject HttpHeader

Posted by KS...@loftware.com.
Hi,

I had to do something like that a couple years ago, but with GraniteDS.  Basically I had to send the locale of the user to the server so any error messages they might receive from the server would be in the correct language.  I was able to add a new property to the token’s message.headers object.  On the server side I was able to get the granite context and access the header with my property on it.  We ended up storing it as an attribute on the session, but you can do what you like.

Client side where login occurs
public function doLogin(user:String, pwd:String, locale:String,  channelSet:ChannelSet = null):void{
       var token:AsyncToken = null;

token = RemoteObject(service).channelSet.login(user,pwd);

       // Adding locale to headers so the server
       // can access the user's locale.
       // Adding the locale to the CommandMessage's headers map.
       token.message.headers[“com.foo.locale”] = locale;
       token.addResponder(responder);
}

Server side where login occurs
@Override
public void login(Object credentials, String charset) throws SecurityServiceException {

HttpGraniteContext graniteContext = (HttpGraniteContext)GraniteContext.getCurrentInstance();
       String locale = (String)graniteContext.getAMFContext().getRequest().getHeader(LOCALE_HEADER);

}

Keegan Sands
Technical Lead
T: +1-603-570-4633
www.loftware.com<http://www.loftware.com/>

From: Ronny Shibley [mailto:rshibley@codefish.com]
Sent: Friday, April 03, 2015 8:29 AM
To: users@flex.apache.org
Subject: Flex BlazeDS RemoteObject HttpHeader

Dear Flex Users.

I am trying to pass parameters to RemoteObject service calls. Basically I need to pass the app version, username, userid... without having to modify all my existing functions...

I want be able to retrieve those in a servlet filter.

Anyone done this before ?


Kind Regards,



Ronny Shibley, Eng



Software Architect | Codefish | www.codefish.com<http://www.codefish.com>

t +961 5 450824<tel:%2B961%205%20450824> | m +961 70 250650<tel:%2B961%2070%20250650>



[cid:image001.png@01D00AF0.78A9FF20]<https://goo.gl/maps/UcEGK>