X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms%2Fsrc%2Forg%2Fargeo%2Fcms%2Fauth%2FHttpRequestCallbackHandler.java;h=df971e687f0c31bbd2eaf957a376be0c736a9c76;hb=b6e64316eb5472b68f4673cbda3f1e375defe8fe;hp=191a114523fd595c054df750b96d8c67169b6ebd;hpb=b8da6ff850049dd39531c1e50f2eef38c4e3298e;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms/src/org/argeo/cms/auth/HttpRequestCallbackHandler.java b/org.argeo.cms/src/org/argeo/cms/auth/HttpRequestCallbackHandler.java index 191a11452..df971e687 100644 --- a/org.argeo.cms/src/org/argeo/cms/auth/HttpRequestCallbackHandler.java +++ b/org.argeo.cms/src/org/argeo/cms/auth/HttpRequestCallbackHandler.java @@ -4,9 +4,11 @@ import java.io.IOException; import javax.security.auth.callback.Callback; import javax.security.auth.callback.CallbackHandler; +import javax.security.auth.callback.LanguageCallback; import javax.security.auth.callback.UnsupportedCallbackException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; /** * Callback handler populating {@link HttpRequestCallback}s with the provided @@ -15,18 +17,29 @@ import javax.servlet.http.HttpServletResponse; public class HttpRequestCallbackHandler implements CallbackHandler { final private HttpServletRequest request; final private HttpServletResponse response; + final private HttpSession httpSession; public HttpRequestCallbackHandler(HttpServletRequest request, HttpServletResponse response) { this.request = request; + this.httpSession = request.getSession(false); this.response = response; } + public HttpRequestCallbackHandler(HttpSession httpSession) { + this.httpSession = httpSession; + this.request = null; + this.response = null; + } + @Override public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (Callback callback : callbacks) if (callback instanceof HttpRequestCallback) { ((HttpRequestCallback) callback).setRequest(request); ((HttpRequestCallback) callback).setResponse(response); + ((HttpRequestCallback) callback).setHttpSession(httpSession); + } else if (callback instanceof LanguageCallback) { + ((LanguageCallback) callback).setLocale(request.getLocale()); } }