当前位置: 首页>>代码示例>>Java>>正文


Java SecurityContext.getAuthenticatedAccount方法代码示例

本文整理汇总了Java中io.undertow.security.api.SecurityContext.getAuthenticatedAccount方法的典型用法代码示例。如果您正苦于以下问题:Java SecurityContext.getAuthenticatedAccount方法的具体用法?Java SecurityContext.getAuthenticatedAccount怎么用?Java SecurityContext.getAuthenticatedAccount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.undertow.security.api.SecurityContext的用法示例。


在下文中一共展示了SecurityContext.getAuthenticatedAccount方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: wrap

import io.undertow.security.api.SecurityContext; //导入方法依赖的package包/类
@Override
public StreamSinkConduit wrap(ConduitFactory<StreamSinkConduit> factory, HttpServerExchange exchange) {
    SecurityContext sc = exchange.getSecurityContext();
    Account account = sc.getAuthenticatedAccount();
    if (account != null) {
        try (SingleSignOn sso = manager.createSingleSignOn(account, sc.getMechanismName())) {
            Session session = getSession(exchange);
            registerSessionIfRequired(sso, session);
            exchange.getResponseCookies().put(cookieName, new CookieImpl(cookieName, sso.getId()).setHttpOnly(httpOnly).setSecure(secure).setDomain(domain).setPath(path));
        }
    }
    return factory.create();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:SingleSignOnAuthenticationMechanism.java

示例2: isUserInRole

import io.undertow.security.api.SecurityContext; //导入方法依赖的package包/类
@Override
public boolean isUserInRole(final String role) {
    if (role == null) {
        return false;
    }
    //according to the servlet spec this aways returns false
    if (role.equals("*")) {
        return false;
    }
    SecurityContext sc = exchange.getSecurityContext();
    Account account = sc.getAuthenticatedAccount();
    if (account == null) {
        return false;
    }
    ServletRequestContext servletRequestContext = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);

    if (role.equals("**")) {
        Set<String> roles = servletRequestContext.getDeployment().getDeploymentInfo().getSecurityRoles();
        if (!roles.contains("**")) {
            return true;
        }
    }

    final ServletChain servlet = servletRequestContext.getCurrentServlet();
    final Deployment deployment = servletContext.getDeployment();
    final AuthorizationManager authorizationManager = deployment.getDeploymentInfo().getAuthorizationManager();
    return authorizationManager.isUserInRole(role, account, servlet.getManagedServlet().getServletInfo(), this, deployment);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:HttpServletRequestImpl.java

示例3: getUserPrincipal

import io.undertow.security.api.SecurityContext; //导入方法依赖的package包/类
@Override
public Principal getUserPrincipal() {
    SecurityContext securityContext = exchange.getSecurityContext();
    Principal result = null;
    Account account = null;
    if (securityContext != null && (account = securityContext.getAuthenticatedAccount()) != null) {
        result = account.getPrincipal();
    }
    return result;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:HttpServletRequestImpl.java

示例4: getUserPrincipal

import io.undertow.security.api.SecurityContext; //导入方法依赖的package包/类
@Override
public Principal getUserPrincipal() {
    SecurityContext sc = exchange.getSecurityContext();
    if(sc == null) {
        return null;
    }
    Account authenticatedAccount = sc.getAuthenticatedAccount();
    if(authenticatedAccount == null) {
        return null;
    }
    return authenticatedAccount.getPrincipal();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:AsyncWebSocketHttpServerExchange.java

示例5: isUserInRole

import io.undertow.security.api.SecurityContext; //导入方法依赖的package包/类
@Override
public boolean isUserInRole(String role) {
    SecurityContext sc = exchange.getSecurityContext();
    if(sc == null) {
        return false;
    }
    Account authenticatedAccount = sc.getAuthenticatedAccount();
    if(authenticatedAccount == null) {
        return false;
    }
    return authenticatedAccount.getRoles().contains(role);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:AsyncWebSocketHttpServerExchange.java

示例6: authenticate

import io.undertow.security.api.SecurityContext; //导入方法依赖的package包/类
@Override
public AuthenticationMechanismOutcome authenticate(HttpServerExchange exchange, SecurityContext securityContext) {
  Account account = securityContext.getAuthenticatedAccount();
  if(account != null) {
    if(logger.isDebugEnabled()) {
      logger.debug("User {} already logged in - nothing to do", account.getPrincipal().getName());
    }

    return AuthenticationMechanismOutcome.AUTHENTICATED;
  }

  try {
    HeaderValues header = authorizationHeader(exchange);
    if(header == null) {
      return AuthenticationMechanismOutcome.NOT_AUTHENTICATED;
    }

    String authorization = header.getFirst();
    byte[] bytes = authorizationBytes(securityContext, authorization);
    String[] credentials = authorizationCredentials(securityContext, bytes);

    account = verify(credentials, securityContext.getIdentityManager()).orElseThrow(
      () -> new AuthenticationException(AuthenticationMechanismOutcome.NOT_AUTHENTICATED,
        "Authentication failed to log the user"));
  } catch (AuthenticationException e) {
    securityContext.authenticationFailed(e.getMessage(), MECHANISM_NAME);
    return e.outcome;
  }

  securityContext.authenticationComplete(account, MECHANISM_NAME, !stateless);
  return AuthenticationMechanismOutcome.AUTHENTICATED;
}
 
开发者ID:vvergnolle,项目名称:vas,代码行数:33,代码来源:RestAuthenticationMechanism.java

示例7: getUndertowUser

import io.undertow.security.api.SecurityContext; //导入方法依赖的package包/类
private String getUndertowUser(final HttpServerExchange exchange) {
    SecurityContext context = exchange.getSecurityContext();
    if (context != null) {
        Account account = context.getAuthenticatedAccount();
        if (account != null) {
            // An account must always return a Principal otherwise it is not an Account.
            return account.getPrincipal().getName();
        }
    }

    return null;
}
 
开发者ID:wildfly-security,项目名称:elytron-web,代码行数:13,代码来源:TestResponseHandler.java

示例8: getAccount

import io.undertow.security.api.SecurityContext; //导入方法依赖的package包/类
private static Pac4jAccount getAccount(final HttpServerExchange exchange) {
    final SecurityContext securityContext = exchange.getSecurityContext();
    if (securityContext != null) {
        final Account account = securityContext.getAuthenticatedAccount();
        if (account instanceof Pac4jAccount) {
            return (Pac4jAccount) account;
        }
    }
    return null;
}
 
开发者ID:pac4j,项目名称:undertow-pac4j-demo,代码行数:11,代码来源:DemoHandlers.java


注:本文中的io.undertow.security.api.SecurityContext.getAuthenticatedAccount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。