org.jboss.security.AuthenticationManager.logout()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(4.9k)|赞(0)|评价(0)|浏览(101)

本文整理了Java中org.jboss.security.AuthenticationManager.logout()方法的一些代码示例,展示了AuthenticationManager.logout()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AuthenticationManager.logout()方法的具体详情如下:
包路径:org.jboss.security.AuthenticationManager
类名称:AuthenticationManager
方法名:logout

AuthenticationManager.logout介绍

[英]This method must be invoked to perform the logout of the incoming principal. The Subject associated with the principal is also provided, allowing implementations to perform any special cleanup based on the information contained in the Subject.
[中]必须调用此方法来执行传入主体的注销。还提供了与主体关联的主题,允许实现基于主题中包含的信息执行任何特殊清理。

代码示例

代码示例来源:origin: wildfly/wildfly

private void clearAccount(Account account) {
    Principal principal = (account instanceof AccountImpl) ? ((AccountImpl) account).getOriginalPrincipal() :
        account.getPrincipal();
    if (principal != null) {
      // perform the logout of the principal using the subject currently set in the security context.
      Subject subject = SecurityActions.getSubject();
      this.manager.logout(principal, subject);
    }
  }
}

代码示例来源:origin: wildfly/wildfly

@Override
  public void handleNotification(SecurityNotification notification) {
    if (notification.getEventType() == SecurityNotification.EventType.LOGGED_OUT) {
      Account account = notification.getAccount();
      Principal principal = (account instanceof AccountImpl) ? ((AccountImpl) account).getOriginalPrincipal() :
          account.getPrincipal();
      if (principal != null) {
        // perform the logout of the principal using the subject currently set in the security context.
        Subject subject = SecurityActions.getSubject();
        this.manager.logout(principal, subject);
      }

      // Clear old context
      SecurityActions.clearSecurityContext();
      SecurityActions.setSecurityRoles(null);

      // Set a new one in case re-authentication is done within the same thread
      org.jboss.security.SecurityContext securityContext = SecurityActions.createSecurityContext(securityDomain);
      notification.getExchange().putAttachment(UndertowSecurityAttachments.SECURITY_CONTEXT_ATTACHMENT, securityContext);

      SecurityActions.setSecurityContextOnAssociation(securityContext);
    }
  }
}

代码示例来源:origin: org.wildfly/wildfly-undertow

private void clearAccount(Account account) {
    Principal principal = (account instanceof AccountImpl) ? ((AccountImpl) account).getOriginalPrincipal() :
        account.getPrincipal();
    if (principal != null) {
      // perform the logout of the principal using the subject currently set in the security context.
      Subject subject = SecurityActions.getSubject();
      this.manager.logout(principal, subject);
    }
  }
}

代码示例来源:origin: org.jboss.eap/wildfly-undertow

private void clearAccount(Account account) {
    Principal principal = (account instanceof AccountImpl) ? ((AccountImpl) account).getOriginalPrincipal() :
        account.getPrincipal();
    if (principal != null) {
      // perform the logout of the principal using the subject currently set in the security context.
      Subject subject = SecurityActions.getSubject();
      this.manager.logout(principal, subject);
    }
  }
}

代码示例来源:origin: ModeShape/modeshape

@Override
  public void logout() {
    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug("Logging out security context....");
    }
    authenticationManager.logout(SimplePrincipal.newInstance(jaasSecurityContext.getUserName()), null);
    jaasSecurityContext.logout();
  }
}

代码示例来源:origin: org.jboss.eap/wildfly-undertow

@Override
  public void handleNotification(SecurityNotification notification) {
    if (notification.getEventType() == SecurityNotification.EventType.LOGGED_OUT) {
      Account account = notification.getAccount();
      Principal principal = (account instanceof AccountImpl) ? ((AccountImpl) account).getOriginalPrincipal() :
          account.getPrincipal();
      if (principal != null) {
        // perform the logout of the principal using the subject currently set in the security context.
        Subject subject = SecurityActions.getSubject();
        this.manager.logout(principal, subject);
      }

      // Clear old context
      SecurityActions.clearSecurityContext();
      SecurityActions.setSecurityRoles(null);

      // Set a new one in case re-authentication is done within the same thread
      org.jboss.security.SecurityContext securityContext = SecurityActions.createSecurityContext(securityDomain);
      notification.getExchange().putAttachment(UndertowSecurityAttachments.SECURITY_CONTEXT_ATTACHMENT, securityContext);

      SecurityActions.setSecurityContextOnAssociation(securityContext);
    }
  }
}

代码示例来源:origin: org.wildfly/wildfly-undertow

@Override
  public void handleNotification(SecurityNotification notification) {
    if (notification.getEventType() == SecurityNotification.EventType.LOGGED_OUT) {
      Account account = notification.getAccount();
      Principal principal = (account instanceof AccountImpl) ? ((AccountImpl) account).getOriginalPrincipal() :
          account.getPrincipal();
      if (principal != null) {
        // perform the logout of the principal using the subject currently set in the security context.
        Subject subject = SecurityActions.getSubject();
        this.manager.logout(principal, subject);
      }

      // Clear old context
      SecurityActions.clearSecurityContext();
      SecurityActions.setSecurityRoles(null);

      // Set a new one in case re-authentication is done within the same thread
      org.jboss.security.SecurityContext securityContext = SecurityActions.createSecurityContext(securityDomain);
      notification.getExchange().putAttachment(UndertowSecurityAttachments.SECURITY_CONTEXT_ATTACHMENT, securityContext);

      SecurityActions.setSecurityContextOnAssociation(securityContext);
    }
  }
}

相关文章

微信公众号

最新文章

更多