Hello,
We need to authenticate our clients with SPNEGO automatically.
The Tomcat server already works, a simple test.jsp will give me the username I
need.
But how do I get the same String with jspx/myfaces?
This is what works:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<TITLE>SPNEGO/AD - Test</TITLE>
</HEAD>
<BODY>
<br>
<%
out.print(request.getRemoteUser()+"<br><br><br>");
if(request.isUserInRole("manager")){
out.print("Rolle manager -> JA<br>");
} else {
out.print("Rolle manager -> NEIN<br>");
}
%>
</BODY>
</HTML>
How do I access the request object. I tried in the backing bean this:
FacesContext faces = FacesContext.getCurrentInstance();
ExternalContext ext = faces.getExternalContext();
HttpServletRequest req = (HttpServletRequest) ext.getRequest();
String adUserName = req.getRemoteUser();
I also tried having a method like this in the backing:
public HttpServletRequest getRequest () {
FacesContext faces = FacesContext.getCurrentInstance();
ExternalContext ext = faces.getExternalContext();
return (HttpServletRequest) ext.getRequest();
}
and then accessing it in the jspx like this:
<tr:outputText value="Remote User: #{login.request.remoteUser}"></tr:outputText>
Both give me an empty string. Any hints?
Thank you,
Tobias