本文整理汇总了Java中org.jboss.security.plugins.HostThreadLocal类的典型用法代码示例。如果您正苦于以下问题:Java HostThreadLocal类的具体用法?Java HostThreadLocal怎么用?Java HostThreadLocal使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HostThreadLocal类属于org.jboss.security.plugins包,在下文中一共展示了HostThreadLocal类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: authenticate
import org.jboss.security.plugins.HostThreadLocal; //导入依赖的package包/类
public boolean authenticate(Request request, HttpServletResponse response,
LoginConfig config) throws IOException {
// set remote host value
HostThreadLocal.set(request.getRemoteAddr());
log.trace("Authenticating user");
Principal principal = request.getUserPrincipal();
if (principal != null) {
log.trace("Already authenticated '" + principal.getName() + "'");
return true;
}
Realm realm = context.getRealm();
Session session = request.getSessionInternal(true);
String username = getUserId(request);
String password = getSessionCookie(request);
// Check if there is sso id as well as sessionkey
if (username == null || password == null) {
log.trace("Username is null or password(sessionkey) is null:fallback to form auth");
return super.authenticate(request, response, config);
}
principal = realm.authenticate(username, password);
if (principal == null) {
forwardToErrorPage(request, response, config);
return false;
}
session.setNote(Constants.SESS_USERNAME_NOTE, username);
session.setNote(Constants.SESS_PASSWORD_NOTE, password);
request.setUserPrincipal(principal);
register(request, response, principal, HttpServletRequest.FORM_AUTH, username, password);
return true;
}
示例2: getRealHost
import org.jboss.security.plugins.HostThreadLocal; //导入依赖的package包/类
/**
* @return the hostname of the client
*/
protected String getRealHost() {
return HostThreadLocal.get();
}