import javax.servlet.http.Cookie;\r
import javax.servlet.http.HttpServletRequest;\r
\r
+import org.apache.wicket.RequestCycle;\r
import org.apache.wicket.protocol.http.WebResponse;\r
import org.apache.wicket.resource.ContextRelativeResource;\r
import org.apache.wicket.util.resource.ResourceStreamNotFoundException;\r
// grab real user model and preserve certificate serial number\r
UserModel user = getUserModel(model.username);\r
if (user != null) {\r
- GitBlitWebSession session = GitBlitWebSession.get();\r
- session.authenticationType = AuthenticationType.CERTIFICATE;\r
+ RequestCycle requestCycle = RequestCycle.get();\r
+ if (requestCycle != null) {\r
+ // flag the Wicket session, if this is a Wicket request\r
+ GitBlitWebSession session = GitBlitWebSession.get();\r
+ session.authenticationType = AuthenticationType.CERTIFICATE;\r
+ }\r
X509Metadata metadata = HttpUtils.getCertificateMetadata(httpRequest);\r
logger.info(MessageFormat.format("{0} authenticated by client certificate {1} from {2}",\r
user.username, metadata.serialNumber, httpRequest.getRemoteAddr()));\r
// Grab cookie from Browser Session\r
UserModel user = authenticate(cookies);\r
if (user != null) {\r
- GitBlitWebSession session = GitBlitWebSession.get();\r
- session.authenticationType = AuthenticationType.COOKIE;\r
+ RequestCycle requestCycle = RequestCycle.get();\r
+ if (requestCycle != null) {\r
+ // flag the Wicket session, if this is a Wicket request\r
+ GitBlitWebSession session = GitBlitWebSession.get();\r
+ session.authenticationType = AuthenticationType.COOKIE;\r
+ }\r
logger.info(MessageFormat.format("{0} authenticated by cookie from {1}",\r
user.username, httpRequest.getRemoteAddr()));\r
return user;\r