本文整理了Java中org.eclipse.jetty.server.Request.getAuthentication
方法的一些代码示例,展示了Request.getAuthentication
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getAuthentication
方法的具体详情如下:
包路径:org.eclipse.jetty.server.Request
类名称:Request
方法名:getAuthentication
[英]Get the authentication.
[中]获取身份验证。
代码示例来源:origin: nz.ac.auckland.common/common-jetty8
@Override
public Authentication validateRequest(ServletRequest request, ServletResponse response, boolean mandatory) throws ServerAuthException {
return ((Request)request).getAuthentication();
}
代码示例来源:origin: works.lmz.common/common-jetty-remoteuser
@Override
public Authentication validateRequest(ServletRequest request, ServletResponse response, boolean mandatory) throws ServerAuthException {
return ((Request)request).getAuthentication();
}
代码示例来源:origin: org.ops4j.pax.web/pax-web-jetty
private OsgiAuth getOsgiAuth() {
OsgiAuth auth;
if (request.getAuthentication() instanceof OsgiAuth) {
auth = (OsgiAuth) request.getAuthentication();
} else {
auth = new OsgiAuth();
request.setAuthentication(auth);
}
return auth;
}
代码示例来源:origin: org.eclipse.jetty/jetty-security
try
Authentication authentication = baseRequest.getAuthentication();
if (authentication==null || authentication==Authentication.NOT_CHECKED)
authentication=authenticator==null?Authentication.UNAUTHENTICATED:authenticator.validateRequest(request, response, isAuthMandatory);
Authentication auth=baseRequest.getAuthentication();
if (auth instanceof Authentication.User)
代码示例来源:origin: org.graniteds/granite-server
@Override
public void prelogin(HttpSession session, Object httpRequest, String servletName) {
if (session == null) // Cannot prelogin() without a session
return;
if (session.getAttribute(AuthenticationContext.class.getName()) instanceof Jetty8AuthenticationContext)
return;
Request request = (Request)httpRequest;
Authentication authentication = request.getAuthentication();
UserIdentity.Scope scope = request.getUserIdentityScope();
Jetty8AuthenticationContext authorizationContext = new Jetty8AuthenticationContext(scope, authentication);
session.setAttribute(AuthenticationContext.class.getName(), authorizationContext);
}
代码示例来源:origin: jenkinsci/winstone
/**
* Extract the user authentication
* @param request The request to extract from
* @return The string to log for authenticated user.
*/
protected String getAuthentication(Request request)
{
Authentication authentication = request.getAuthentication();
if (authentication instanceof Authentication.User)
return ((Authentication.User)authentication).getUserIdentity().getUserPrincipal().getName();
// TODO extract the user name if it is Authentication.Deferred and return as '?username'
return null;
}
代码示例来源:origin: org.graniteds/granite-server
Authentication authentication = request.getAuthentication();
UserIdentity.Scope scope = request.getUserIdentityScope();
代码示例来源:origin: com.nitorcreations/willow-logging-jetty
@Override
public Principal getPrincipal() {
Authentication authentication = request.getAuthentication();
if (authentication instanceof Authentication.User) {
return ((Authentication.User) authentication).getUserIdentity()
.getUserPrincipal();
}
return null;
}
代码示例来源:origin: org.overlord/overlord-commons-auth-jetty8
Authentication authentication = jettyRequest.getAuthentication();
User userAuth = (User) authentication;
UserIdentity userIdentity = userAuth.getUserIdentity();
代码示例来源:origin: os-libera/OpenVirteX
@Override
public void handle(final String target, final Request baseRequest,
final HttpServletRequest request, final HttpServletResponse response)
throws IOException, ServletException {
if (baseRequest.getAuthentication() == null
|| baseRequest.getAuthentication().equals(
Authentication.UNAUTHENTICATED)) {
response.sendError(Response.SC_UNAUTHORIZED, "Permission denied.");
baseRequest.setHandled(true);
return;
}
if (target.equals("/status")) {
this.monitoringService.handle(request, response);
} else if (target.equals("/tenant")) {
this.tenantService.handle(request, response);
} else if (target.equals("/admin")) {
this.adminService.handle(request, response);
} else {
response.sendError(Response.SC_NOT_FOUND, target
+ " is not a service offered by OVX");
}
baseRequest.setHandled(true);
}
代码示例来源:origin: org.gatein.wci/wci-jetty8
private void _login(Request req, Response resp, Credentials credentials) throws ServletException
{
HttpSession session = req.getSession();
if(session.getAttribute(SessionAuthentication.__J_AUTHENTICATED) == null)
{
synchronized (session)
{
if(session.getAttribute(SessionAuthentication.__J_AUTHENTICATED) == null)
{
req.login(credentials.getUsername(), credentials.getPassword());
session.setAttribute(SessionAuthentication.__J_AUTHENTICATED, req.getAuthentication());
}
}
}
}
代码示例来源:origin: org.keycloak/keycloak-jetty-core
protected Authentication register(Request request, KeycloakPrincipal<RefreshableKeycloakSecurityContext> principal) {
request.setAttribute(AdapterDeploymentContext.class.getName(), deploymentContext);
Authentication authentication = request.getAuthentication();
if (!(authentication instanceof KeycloakAuthentication)) {
UserIdentity userIdentity = createIdentity(principal);
authentication = createAuthentication(userIdentity, request);
request.setAuthentication(authentication);
}
return authentication;
}
代码示例来源:origin: org.keycloak/spring-boot-container-bundle
protected Authentication register(Request request, KeycloakPrincipal<RefreshableKeycloakSecurityContext> principal) {
request.setAttribute(AdapterDeploymentContext.class.getName(), deploymentContext);
Authentication authentication = request.getAuthentication();
if (!(authentication instanceof KeycloakAuthentication)) {
UserIdentity userIdentity = createIdentity(principal);
authentication = createAuthentication(userIdentity, request);
request.setAuthentication(authentication);
}
return authentication;
}
代码示例来源:origin: org.overlord/overlord-commons-auth-jetty8
Authentication authentication = jettyRequest.getAuthentication();
User userAuth = (User) authentication;
UserIdentity userIdentity = userAuth.getUserIdentity();
代码示例来源:origin: org.graniteds/granite-server
public void logout() throws SecurityServiceException {
ServletGraniteContext graniteContext = (ServletGraniteContext)GraniteContext.getCurrentInstance();
if (graniteContext instanceof HttpGraniteContext) {
Request request = (Request)graniteContext.getRequest();
Authentication authentication = request.getAuthentication();
if (authentication instanceof Authentication.User)
((Authentication.User)authentication).logout();
if (request.getSession(false) != null) {
endLogout();
request.getSession(false).invalidate();
}
}
else {
HttpSession session = graniteContext.getSession();
if (session != null) {
AuthenticationContext authenticationContext = (AuthenticationContext)session.getAttribute(AuthenticationContext.class.getName());
authenticationContext.logout();
session.removeAttribute(AuthenticationContext.class.getName());
endLogout();
session.invalidate();
}
}
}
代码示例来源:origin: org.graniteds/granite-server
if (graniteContext instanceof HttpGraniteContext) {
Request request = (Request)graniteContext.getRequest();
Authentication authentication = request.getAuthentication();
if (authentication instanceof Authentication.User)
((Authentication.User)authentication).logout();
代码示例来源:origin: org.graniteds/granite-server
public Principal login(Object credentials, String charset) throws SecurityServiceException {
String[] decoded = decodeBase64Credentials(credentials, charset);
ServletGraniteContext graniteContext = (ServletGraniteContext)GraniteContext.getCurrentInstance();
Principal principal = null;
if (graniteContext instanceof HttpGraniteContext) {
HttpServletRequest httpRequest = graniteContext.getRequest();
Request request = (Request)httpRequest;
Authentication authentication = request.getAuthentication();
UserIdentity.Scope scope = request.getUserIdentityScope();
Jetty8AuthenticationContext authenticationContext = new Jetty8AuthenticationContext(scope, authentication);
principal = authenticationContext.authenticate(decoded[0], decoded[1]);
if (principal != null)
graniteContext.getSession().setAttribute(AuthenticationContext.class.getName(), authenticationContext);
}
else {
AuthenticationContext authenticationContext = (AuthenticationContext)graniteContext.getSession().getAttribute(AuthenticationContext.class.getName());
if (authenticationContext != null)
principal = authenticationContext.authenticate(decoded[0], decoded[1]);
else
return null;
}
if (principal == null)
throw SecurityServiceException.newInvalidCredentialsException("Wrong username or password");
graniteContext.setPrincipal(principal);
endLogin(credentials, charset);
return principal;
}
代码示例来源:origin: org.graniteds/granite-server
public Principal login(Object credentials, String charset) throws SecurityServiceException {
String[] decoded = decodeBase64Credentials(credentials, charset);
ServletGraniteContext graniteContext = (ServletGraniteContext)GraniteContext.getCurrentInstance();
Principal principal = null;
if (graniteContext instanceof HttpGraniteContext) {
HttpServletRequest httpRequest = graniteContext.getRequest();
Request request = (Request)httpRequest;
Authentication authentication = request.getAuthentication();
UserIdentity.Scope scope = request.getUserIdentityScope();
Jetty9AuthenticationContext authenticationContext = new Jetty9AuthenticationContext(scope, authentication);
principal = authenticationContext.authenticate(decoded[0], decoded[1]);
if (principal != null)
graniteContext.getSession().setAttribute(AuthenticationContext.class.getName(), authenticationContext);
}
else {
AuthenticationContext authenticationContext = (AuthenticationContext)graniteContext.getSession().getAttribute(AuthenticationContext.class.getName());
if (authenticationContext != null)
principal = authenticationContext.authenticate(decoded[0], decoded[1]);
else
return null;
}
if (principal == null)
throw SecurityServiceException.newInvalidCredentialsException("Wrong username or password");
graniteContext.setPrincipal(principal);
endLogin(credentials, charset);
return principal;
}
代码示例来源:origin: jboss-fuse/fabric8
@Override
public void log(Request request, Response response) {
try {
if (!enabled) {
return;
}
StorageService s = storage.getService();
if (s == null) {
return;
}
if (ignorePathMap != null && ignorePathMap.getMatch(request.getRequestURI()) != null)
return;
String output = "{ " +
"\"host\": \"" + host + "\", " +
"\"@timestamp\": \"" + InsightUtils.formatDate(request.getTimeStamp()) + "\", " +
"\"remote\": \"" + request.getRemoteAddr() + "\", " +
"\"user\": \"" + (request.getAuthentication() instanceof Authentication.User ? ((Authentication.User)request.getAuthentication()).getUserIdentity().getUserPrincipal().getName() : "") + "\", " +
"\"method\": \"" + request.getMethod() + "\", " +
"\"uri\": \"" + request.getUri().toString() + "\", " +
"\"protocol\": \"" + request.getProtocol() + "\", " +
"\"status\": \"" + response.getStatus() + "\", " +
"\"responseLength\": \"" + response.getContentCount() + "\" " +
" }";
s.store(type, request.getTimeStamp(), output);
}
catch (Exception e)
{
LOG.warn(e);
}
}
代码示例来源:origin: jenkinsci/winstone
Authentication authentication = request.getAuthentication();
String remoteUser;
if (authentication instanceof Authentication.User) {
内容来源于网络,如有侵权,请联系作者删除!