本文整理汇总了Java中org.apache.catalina.authenticator.Constants类的典型用法代码示例。如果您正苦于以下问题:Java Constants类的具体用法?Java Constants怎么用?Java Constants使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Constants类属于org.apache.catalina.authenticator包,在下文中一共展示了Constants类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: logout
import org.apache.catalina.authenticator.Constants; //导入依赖的package包/类
public boolean logout(HttpServletRequest servletRequest)
{
if (servletRequestMatches(servletRequest))
{
Session session = getSession(request, false);
if (session != null)
{
session.setPrincipal(null);
session.setAuthType(null);
session.removeNote(Constants.SESS_USERNAME_NOTE);
session.removeNote(Constants.SESS_PASSWORD_NOTE);
}
return true;
}
return false;
}
示例2: logout
import org.apache.catalina.authenticator.Constants; //导入依赖的package包/类
public boolean logout(HttpServletRequest request)
{
if (this.request != null && this.request.getRequest() == request)
{
Session session = getSession(this.request, false);
if (session != null)
{
session.setPrincipal(null);
session.setAuthType(null);
session.removeNote(Constants.SESS_USERNAME_NOTE);
session.removeNote(Constants.SESS_PASSWORD_NOTE);
}
return true;
}
return false;
}
示例3: matchRequest
import org.apache.catalina.authenticator.Constants; //导入依赖的package包/类
/**
* Does this request match the saved one (so that it must be the redirect
* we signalled after successful authentication?
*
* @param request The request to be verified
*/
protected boolean matchRequest(Request request) {
// Has a session been created?
Session session = request.getSessionInternal(false);
if (session == null)
return (false);
// Is there a saved request?
SavedRequest sreq = (SavedRequest)
session.getNote(Constants.FORM_REQUEST_NOTE);
if (sreq == null)
return (false);
// Is there a saved principal?
if (session.getNote(Constants.FORM_PRINCIPAL_NOTE) == null)
return (false);
// Does the request URI match?
String requestURI = request.getRequestURI();
if (requestURI == null)
return (false);
return (requestURI.equals(sreq.getRequestURI()));
}
示例4: processFormLogin
import org.apache.catalina.authenticator.Constants; //导入依赖的package包/类
/**
* Process form login authenticator action.
*
* @param request The request.
* @param response The HTTP response.
* @param config Web-application login configuration.
*
* @throws IOException If an I/O error happens sending data in the response.
*/
protected void processFormLogin(final Request request,
final HttpServletResponse response, final LoginConfig config)
throws IOException {
final boolean debug = this.log.isDebugEnabled();
// get user credentials from the form
final String loginName = request.getParameter(Constants.FORM_USERNAME);
final String password = request.getParameter(Constants.FORM_PASSWORD);
// validate the user in the realm
if (debug)
this.log.debug("form authenticating login name " + loginName);
final Principal principal =
this.context.getRealm().authenticate(loginName, password);
// process authenticated user
this.processAuthenticatedUser(request, response, config, principal,
loginName, password, false);
}
示例5: processFormLogin
import org.apache.catalina.authenticator.Constants; //导入依赖的package包/类
/**
* Process form login authenticator action.
*
* @param request The request.
* @param response The HTTP response.
* @param config Web-application login configuration.
*
* @throws IOException If an I/O error happens sending data in the response.
*/
protected void processFormLogin(Request request,
HttpServletResponse response, LoginConfig config)
throws IOException {
final boolean debug = this.log.isDebugEnabled();
// get user credentials from the form
final String loginName = request.getParameter(Constants.FORM_USERNAME);
final String password = request.getParameter(Constants.FORM_PASSWORD);
// validate the user in the realm
if (debug)
this.log.debug("form authenticating login name " + loginName);
Principal principal =
this.context.getRealm().authenticate(loginName, password);
// process authenticated user
this.processAuthenticatedUser(request, response, config, principal,
loginName, password, false);
}
示例6: test09
import org.apache.catalina.authenticator.Constants; //导入依赖的package包/类
@Test
public void test09() {
// Simple SSO case
String id = "0123456789";
String cookie = Constants.SINGLE_SIGN_ON_COOKIE + "=" + id;
// Assert.assertEquals(cookie, CookieFilter.filter(cookie, id));
}
示例7: updateCredentials
import org.apache.catalina.authenticator.Constants; //导入依赖的package包/类
/**
* Updates the SingleSignOnEntry to reflect the latest security
* information associated with the caller.
*
* @param principal the <code>Principal</code> returned by the latest
* call to <code>Realm.authenticate</code>.
* @param authType the type of authenticator used (BASIC, CLIENT_CERT,
* DIGEST or FORM)
* @param username the username (if any) used for the authentication
* @param password the password (if any) used for the authentication
*/
public void updateCredentials(Principal principal, String authType,
String username, String password) {
this.principal = principal;
this.authType = authType;
this.username = username;
this.password = password;
this.canReauthenticate =
(Constants.BASIC_METHOD.equals(authType)
|| Constants.FORM_METHOD.equals(authType));
}
示例8: getPrincipal
import org.apache.catalina.authenticator.Constants; //导入依赖的package包/类
/**
* Return the <code>Principal</code> associated with the given user name.
*/
protected Principal getPrincipal(String username) {
return authenticate(username,
new JAASCallbackHandler(this, username, null, null, null, null,
null, null, null, Constants.CERT_METHOD));
}
示例9: test09
import org.apache.catalina.authenticator.Constants; //导入依赖的package包/类
@Test
public void test09() {
// Simple SSO case
String id = "0123456789";
String cookie = Constants.SINGLE_SIGN_ON_COOKIE + "=" + id;
Assert.assertEquals(cookie, CookieFilter.filter(cookie, id));
}
示例10: redirectToAuthorizationServer
import org.apache.catalina.authenticator.Constants; //导入依赖的package包/类
/**
* Respond with a redirect to the OpenID Connect provider authorization
* endpoint.
*
* @param request The request.
* @param response The response.
*
* @throws IOException If an I/O error happens sending the response.
*/
protected void redirectToAuthorizationServer(final Request request,
final HttpServletResponse response)
throws IOException {
final StringBuilder urlBuf = new StringBuilder(256);
urlBuf.append(this.opConfig.getAuthorizationEndpoint())
.append("?scope=")
.append(URLEncoder.encode("openid email", UTF8.name()))
.append("&response_type=code")
.append("&client_id=")
.append(URLEncoder.encode(this.clientId, UTF8.name()))
.append("&redirect_uri=")
.append(URLEncoder.encode(
this.getBaseURL(request) + Constants.FORM_ACTION,
UTF8.name()))
.append("&state=")
.append(URLEncoder.encode(
request.getSessionInternal().getIdInternal(),
UTF8.name()));
if (this.hostedDomain != null)
urlBuf.append("&hd=").append(
URLEncoder.encode(this.hostedDomain, UTF8.name()));
final String url = urlBuf.toString();
if (this.log.isDebugEnabled())
this.log.debug("redirecting to " + url);
response.sendRedirect(url);
}
示例11: login
import org.apache.catalina.authenticator.Constants; //导入依赖的package包/类
public Principal login(String username, String password, HttpServletRequest servletRequest)
{
Realm realm = container.getRealm();
if (realm == null)
return null;
Principal principal = realm.authenticate(username, password);
if (principal == null)
return null;
if (servletRequestMatches(servletRequest))
{
request.setAuthType(AUTH_TYPE);
request.setUserPrincipal(principal);
Session session = getSession(request, true);
// Cache the authentication information in our session.
if (session != null)
{
session.setAuthType(AUTH_TYPE);
session.setPrincipal(principal);
if (username != null)
session.setNote(Constants.SESS_USERNAME_NOTE, username);
else
session.removeNote(Constants.SESS_USERNAME_NOTE);
if (password != null)
session.setNote(Constants.SESS_PASSWORD_NOTE, password);
else
session.removeNote(Constants.SESS_PASSWORD_NOTE);
}
}
return principal;
}
示例12: login
import org.apache.catalina.authenticator.Constants; //导入依赖的package包/类
public Principal login(String username, String password, HttpServletRequest servletRequest)
{
Realm realm = container.getRealm();
if (realm == null)
return null;
Principal principal = realm.authenticate(username, password);
if (principal != null)
{
if (this.request != null && this.request.getRequest() == servletRequest)
{
request.setAuthType("flexmessaging"); //was "flashgateway"
request.setUserPrincipal(principal);
Session session = getSession(request, true);
// Cache the authentication information in our session, if any
if (session != null)
{
session.setAuthType("flexmessaging"); //was "flashgateway"
session.setPrincipal(principal);
if (username != null)
session.setNote(Constants.SESS_USERNAME_NOTE, username);
else
session.removeNote(Constants.SESS_USERNAME_NOTE);
if (password != null)
session.setNote(Constants.SESS_PASSWORD_NOTE, password);
else
session.removeNote(Constants.SESS_PASSWORD_NOTE);
}
}
}
return principal;
}
示例13: login
import org.apache.catalina.authenticator.Constants; //导入依赖的package包/类
public Principal login(String username, String password, HttpServletRequest servletRequest)
{
Realm realm = valve.getContainer().getRealm();
if (realm == null)
return null;
Principal principal = realm.authenticate(username, password);
if (principal == null)
return null;
if (servletRequestMatches(servletRequest))
{
request.setAuthType(AUTH_TYPE);
request.setUserPrincipal(principal);
Session session = getSession(request, true);
// Cache the authentication information in our session.
if (session != null)
{
session.setAuthType(AUTH_TYPE);
session.setPrincipal(principal);
if (username != null)
session.setNote(Constants.SESS_USERNAME_NOTE, username);
else
session.removeNote(Constants.SESS_USERNAME_NOTE);
if (password != null)
session.setNote(Constants.SESS_PASSWORD_NOTE, password);
else
session.removeNote(Constants.SESS_PASSWORD_NOTE);
}
}
return principal;
}
示例14: getPrincipal
import org.apache.catalina.authenticator.Constants; //导入依赖的package包/类
/**
* Return the <code>Principal</code> associated with the given user name.
*/
@Override
protected Principal getPrincipal(String username) {
return authenticate(username,
new JAASCallbackHandler(this, username, null, null, null, null,
null, null, null, Constants.CERT_METHOD));
}
示例15: savedRequestURL
import org.apache.catalina.authenticator.Constants; //导入依赖的package包/类
/**
* Return the request URI (with the corresponding query string, if any)
* from the saved request so that we can redirect to it.
*
* @param session Our current session
*/
protected String savedRequestURL(Session session) {
SavedRequest saved =
(SavedRequest) session.getNote(Constants.FORM_REQUEST_NOTE);
if (saved == null)
return (null);
StringBuffer sb = new StringBuffer(saved.getRequestURI());
if (saved.getQueryString() != null) {
sb.append('?');
sb.append(saved.getQueryString());
}
return (sb.toString());
}