start(FlexContext.getServletConfig());
}
try
{
AuthenticatedUser user = null;
String password = extractPassword(credentials);
if (password != null)
{
// Test for the presence of a response here (rather than request) because NIO
// endpoints require the alternate code path and they don't populate the response
// in FlexContext.
HttpServletResponse response = FlexContext.getHttpResponse();
if (response != null)
{
HttpServletRequest request = FlexContext.getHttpRequest();
user = appSecurity.authenticate(username, password, request.getSession(true));
}
else
{
ServletContext servletContext = FlexContext.getServletConfig().getServletContext();
WebApplication webApp = ((jrun.servlet.JRunServletContext)servletContext).getWebApplication();
HttpSession tempSession = webApp.getSessionService().createSession("temp");
user = appSecurity.authenticate(username, password, tempSession);
tempSession.invalidate();
}
return user.getPrincipal();
}
}
catch (Exception ex)
{
SecurityException se;