[flexcoders] flashgateway.Gateway.getHttpRequest

2005-04-11 Thread rb_dickey


Hi,

Has anyone seen this behavior?  I'm using Tomcat 5.5.7, and I have a 
web app configured with FORM authentication, which uses a custom 
mxml-based form. 

The authentication piece works great, but I can't get the userId 
from the HttpRequest.getUserPrincipal().getName() consistently. The 
first call to getUserPrincipal() returns a null. This is not suppose 
to happen unless the user is not authenticated, but they have been.  
What's even more strange is that if I refresh the page, the 
getUserPrincipal() call then returns the userId as expected.
The RO is basically doing the following:

 HttpRequest request = flashgateway.Gateway.getHttpRequest();
 String userId = request.getUserPrincipal().getName();

I know there are some inconsistencies re: Tomcat and the 
getUserPrincipal() call but I thought that was fixed in 5.5.7...is 
there another way to do this natively in ActionScript to bypass the 
RO? Any other suggestions are welcomed.

As always, TIA for any info.

Regards,
Rob





 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 





RE: [flexcoders] flashgateway.Gateway.getHttpRequest().getSession(true);

2005-03-17 Thread Peter Farland
Hi Devis,

I thought I answered this question for you on Monday?


-Original Message-
From: Peter Farland
Sent: Monday, March 14, 2005 10:15 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Servlet Session

I'd suggest you don't use the session servlet in Flex 1.5. Instead, I'd just 
write a normal plain old java object façade that calls the thread-localstatic 
helpers on flashgateway.Gateway

public static HttpServletRequest getHttpRequest()
public static HttpServletResponse getHttpResponse()
public static ServletConfig getServletConfig()

You can get access to the current session from the HttpRequest.

HttpSession session = flashgateway.Gateway.getHttpRequest().getSession(true);


See:

http://www.macromedia.com/support/documentation/en/flex/1_5/migration.html#sessions



Anyway, here's some more detailed instructions:



1. Write some RemoteObject service as a Java class:

-

package sample.session;

import flex.messaging.HttpContext;

import javax.servlet.http.HttpSession;

/**
* A sample Remoting Service that gets and sets 
* attributes from the current session...
*/
public class Session
{
public Session()
{
}

public Object getSessionObject(String name)
{
HttpSession session = HttpContext.getHttpRequest().getSession(true);
return session.getAttribute(name);
}

public void setSessionObject(String name, Object o)
{
HttpSession session = HttpContext.getHttpRequest().getSession(true);
session.setAttribute(name, o);
}
}

-


2. Then add this to your remote-objects whitelist in flex-config.xml:

object name=mySessionService
!-- use-custom-authenticationfalse/use-custom-authentication --
sourcesample.session.Session/source
typestateless-class/type
allow-unnamed-accessfalse/allow-unnamed-access
/object


3. Then change your mx:RemoteObject tag to use this named service:

mx:RemoteObject id=sessionService named=mySessionService/

(Also add fault and result handlers!!)


4. Update your script to use this new RemoteObject by id sessionService.





Re: [flexcoders] flashgateway.Gateway.getHttpRequest().getSession(true);

2005-03-17 Thread [EMAIL PROTECTED]
thank's peter,
sorry but i have had problem with mail mail server :-(
Devis
Peter Farland ha scritto:
Hi Devis,
I thought I answered this question for you on Monday?
-Original Message-
From: Peter Farland
Sent: Monday, March 14, 2005 10:15 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Servlet Session
I'd suggest you don't use the session servlet in Flex 1.5. Instead, I'd just 
write a normal plain old java object façade that calls the thread-local static 
helpers on flashgateway.Gateway
public static HttpServletRequest getHttpRequest()
public static HttpServletResponse getHttpResponse()
public static ServletConfig getServletConfig()
You can get access to the current session from the HttpRequest.
HttpSession session = flashgateway.Gateway.getHttpRequest().getSession(true);
See:
http://www.macromedia.com/support/documentation/en/flex/1_5/migration.html#sessions

Anyway, here's some more detailed instructions:

1. Write some RemoteObject service as a Java class:
-
package sample.session;
import flex.messaging.HttpContext;
import javax.servlet.http.HttpSession;
/**
* A sample Remoting Service that gets and sets 
* attributes from the current session...
*/
public class Session
{
public Session()
{
}

public Object getSessionObject(String name)
{
HttpSession session = HttpContext.getHttpRequest().getSession(true);
return session.getAttribute(name);
}
public void setSessionObject(String name, Object o)
{
HttpSession session = HttpContext.getHttpRequest().getSession(true);
session.setAttribute(name, o);
}
}
-
2. Then add this to your remote-objects whitelist in flex-config.xml:
object name=mySessionService
!-- use-custom-authenticationfalse/use-custom-authentication --
sourcesample.session.Session/source
typestateless-class/type
allow-unnamed-accessfalse/allow-unnamed-access
/object
3. Then change your mx:RemoteObject tag to use this named service:
mx:RemoteObject id=sessionService named=mySessionService/
(Also add fault and result handlers!!)
4. Update your script to use this new RemoteObject by id sessionService.

Yahoo! Groups Links