Package org.beangle.security.core

Examples of org.beangle.security.core.Authentication


    //Resource resource = getResource();
    restrictionService.apply(query, getRestrictions());
  }

  protected UserToken getAuthentication() {
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    if (null == auth) throw new AuthenticationException();
    UserToken user = (UserToken) auth.getPrincipal();
    if (null == user.getId()) throw new AuthenticationException();
    return user;
  }
View Full Code Here


  public void onApplicationEvent(BusinessEvent event) {
    BusinessLogBean log = new BusinessLogBean();
    log.setOperateAt(event.getIssueAt());
    log.setOperation(StringUtils.defaultIfBlank(event.getDescription(), "  "));
    log.setResource(StringUtils.defaultIfBlank(event.getResource(), "  "));
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    if (null == auth) return;
    log.setOperater(auth.getName());
    Object details = auth.getDetails();
    if ((details instanceof WebAuthenticationDetails)) {
      WebAuthenticationDetails webDetails = (WebAuthenticationDetails) details;
      log.setIp(webDetails.getAgent().getIp());
      log.setAgent(webDetails.getAgent().toString());
      log.setEntry(sessionRegistry.getResource(webDetails.getSessionId()));
View Full Code Here

  public void onApplicationEvent(BusinessEvent event) {
    BusinessLogBean log = new BusinessLogBean();
    log.setOperateAt(event.getIssueAt());
    log.setOperation(StringUtils.defaultIfBlank(event.getDescription(), "  "));
    log.setResource(StringUtils.defaultIfBlank(event.getResource(), "  "));
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    if (null == auth) return;
    log.setOperator(auth.getName());
    Object details = auth.getDetails();
    if ((details instanceof WebAuthenticationDetails)) {
      WebAuthenticationDetails webDetails = (WebAuthenticationDetails) details;
      log.setIp(webDetails.getAgent().getIp());
      log.setAgent(webDetails.getAgent().getOs() + " " + webDetails.getAgent().getBrowser());
      log.setEntry(sessionRegistry.getResource(webDetails.getSessionId()));
View Full Code Here

public final class SecurityUtils {

  private static ThreadLocal<String> resource = new ThreadLocal<String>();

  public static UserToken getPrincipal() {
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    if (null == auth) throw new AuthenticationException();
    UserToken user = (UserToken) auth.getPrincipal();
    if (null == user.getId()) throw new AuthenticationException();
    return user;
  }
View Full Code Here

    if (StringUtils.isBlank(username) || StringUtils.isBlank(password)) { return "failure"; }
    username = username.trim();
    HttpServletRequest request = getRequest();
    UsernamePasswordAuthentication auth = new UsernamePasswordAuthentication(username, password);
    auth.setDetails(authenticationDetailsSource.buildDetails(request));
    Authentication authRequest = auth;
    try {
      authRequest = authenticationManager.authenticate(authRequest);
      sessionRegistry.register(authRequest, request.getSession().getId());
      SecurityContextHolder.getContext().setAuthentication(authRequest);
    } catch (AuthenticationException e) {
View Full Code Here

    while (iter.hasNext()) {
      AuthenticationProvider provider = iter.next();
      if (!provider.supports(toTest)) {
        continue;
      }
      Authentication result;
      try {
        result = provider.authenticate(auth);
        if (result != null) {
          copyDetails(auth, result);
          // sessionController.checkAuthenticationAllowed(result);
View Full Code Here

   * 没有登录或匿名账户不进行session处理
   * @param request
   * @return
   */
  protected boolean shouldCare(HttpServletRequest request) {
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    return null != auth && !(AnonymousAuthentication.class.isAssignableFrom(auth.getClass()));
  }
View Full Code Here

  protected String determineExpiredUrl(HttpServletRequest request, SessionStatus info) {
    return expiredUrl;
  }

  private void doLogout(HttpServletRequest request, HttpServletResponse response) {
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    handlerStack.logout(request, response, auth);
  }
View Full Code Here

   *
   * @param request
   * @param response
   * @return */
  protected boolean requiresAuthentication(HttpServletRequest request, HttpServletResponse response) {
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    if (auth == null) { return true; }
    if (null != authenticationAliveChecker && !authenticationAliveChecker.check(auth, request)) {
      unsuccessfulAuthentication(request, response, null);
      return true;
    } else {
View Full Code Here

    filterChain.doFilter(request, response);
  }

  /** Do the actual authentication for a pre-authenticated user. */
  private void doAuthenticate(HttpServletRequest request, HttpServletResponse response) {
    Authentication authResult = null;
    PreauthAuthentication auth = getPreauthAuthentication(request, response);
    if (auth == null) {
      logger.debug("No pre-authenticated principal found in request");
      return;
    } else {
View Full Code Here

TOP

Related Classes of org.beangle.security.core.Authentication

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.