本文整理了Java中org.apache.shiro.util.ThreadContext.unbindSecurityManager()
方法的一些代码示例,展示了ThreadContext.unbindSecurityManager()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ThreadContext.unbindSecurityManager()
方法的具体详情如下:
包路径:org.apache.shiro.util.ThreadContext
类名称:ThreadContext
方法名:unbindSecurityManager
[英]Convenience method that simplifies removal of the application's SecurityManager instance from the thread.
The implementation just helps reduce casting and remembering of the ThreadContext key name, i.e it is merely a convenient wrapper for the following:
return (SecurityManager)remove( SECURITY_MANAGER_KEY );
If you wish to just retrieve the object from the thread without removing it (so it can be retrieved later during thread execution), use the #getSecurityManager() method instead.
[中]简化从线程中删除应用程序的SecurityManager实例的便捷方法。
该实现只帮助减少对ThreadContext键名称的强制转换和记忆,也就是说,它只是以下内容的方便包装:return (SecurityManager)remove( SECURITY_MANAGER_KEY );
如果希望只从线程中检索对象而不删除它(以便稍后在线程执行期间检索),请使用#getSecurityManager()方法。
代码示例来源:origin: killbill/killbill
@AfterMethod(groups = "slow")
public void afterMethod() throws Exception {
if (hasFailed()) {
return;
}
super.afterMethod();
ThreadContext.unbindSecurityManager();
}
代码示例来源:origin: killbill/killbill
@AfterMethod(groups = "fast")
public void afterMethod() throws Exception {
if (hasFailed()) {
return;
}
eventBus.stop();
// Reset the security manager
ThreadContext.unbindSecurityManager();
}
代码示例来源:origin: killbill/killbill
protected void configureShiro() {
final Ini config = new Ini();
config.addSection("users");
config.getSection("users").put("pierre", "password, creditor");
config.getSection("users").put("stephane", "password, refunder");
config.addSection("roles");
config.getSection("roles").put("creditor", Permission.INVOICE_CAN_CREDIT.toString() + "," + Permission.INVOICE_CAN_ITEM_ADJUST.toString());
config.getSection("roles").put("refunder", Permission.PAYMENT_CAN_REFUND.toString());
// Reset the security manager
ThreadContext.unbindSecurityManager();
final Factory<SecurityManager> factory = new IniSecurityManagerFactory(config);
final SecurityManager securityManager = factory.getInstance();
SecurityUtils.setSecurityManager(securityManager);
}
}
代码示例来源:origin: org.seedstack.addons.ws/web-services-core
@Override
public void close(MessageContext context) {
ThreadContext.unbindSubject();
ThreadContext.unbindSecurityManager();
}
}
代码示例来源:origin: org.apache.polygene.libraries/org.apache.polygene.library.shiro-core
@Override
public void passivateService()
throws Exception
{
ThreadContext.unbindSubject();
ThreadContext.unbindSecurityManager();
}
代码示例来源:origin: apache/attic-polygene-java
@Override
public void passivateService()
throws Exception
{
ThreadContext.unbindSubject();
ThreadContext.unbindSecurityManager();
}
代码示例来源:origin: org.seedstack.seed/seed-shell-support
@Override
public void destroy() {
ses.shutdownNow();
ThreadContext.unbindSubject();
ThreadContext.unbindSecurityManager();
}
代码示例来源:origin: org.seedstack.seed/seed-shell
@Override
public void destroy() {
ses.shutdownNow();
ThreadContext.unbindSubject();
ThreadContext.unbindSecurityManager();
}
代码示例来源:origin: org.seedstack.seed/seed-security-core
@Override
public void afterTest(TestContext testContext) {
if (subject != null) {
LOGGER.info("Logging user out", testContext.testMethod());
subject.logout();
ThreadContext.unbindSecurityManager();
ThreadContext.unbindSubject();
}
}
代码示例来源:origin: apache/attic-polygene-java
public void interactionEnds()
{
ThreadContext.unbindSubject();
ThreadContext.unbindSecurityManager();
}
// END SNIPPET: thread-context
代码示例来源:origin: org.seedstack.seed/seed-shell
@Override
public void destroy() {
ses.shutdownNow();
consoleReader.shutdown();
ThreadContext.unbindSubject();
ThreadContext.unbindSecurityManager();
}
代码示例来源:origin: org.seedstack.seed/seed-shell-support
@Override
public void destroy() {
ses.shutdownNow();
consoleReader.shutdown();
ThreadContext.unbindSubject();
ThreadContext.unbindSecurityManager();
}
代码示例来源:origin: org.kill-bill.billing/killbill-util
@AfterMethod(groups = "slow")
public void afterMethod() throws Exception {
if (hasFailed()) {
return;
}
super.afterMethod();
ThreadContext.unbindSecurityManager();
}
代码示例来源:origin: org.kill-bill.billing/killbill-util
@AfterMethod(groups = "fast")
public void afterMethod() throws Exception {
if (hasFailed()) {
return;
}
eventBus.stop();
// Reset the security manager
ThreadContext.unbindSecurityManager();
}
代码示例来源:origin: juzu/juzu
@Override
public Response handle(Stage.Handler stage) {
if (descriptor != null) {
try {
if (manager == null) {
SecurityManagerProvider provider = new SecurityManagerProvider(descriptor.getConfig());
manager = provider.get();
}
start();
return descriptor.invoke(stage);
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
} finally {
ThreadContext.unbindSubject();
ThreadContext.unbindSecurityManager();
}
} else {
return stage.invoke();
}
}
代码示例来源:origin: com.github.sdorra/shiro-unit
/**
* Method description
*
*/
private void tearDownShiro()
{
try
{
SecurityManager securityManager = SecurityUtils.getSecurityManager();
LifecycleUtils.destroy(securityManager);
ThreadContext.unbindSecurityManager();
ThreadContext.unbindSubject();
ThreadContext.remove();
}
catch (UnavailableSecurityManagerException e)
{
// we don't care about this when cleaning up the test environment
// (for example, maybe the subclass is a unit test and it didn't
// need a SecurityManager instance because it was using only mock Subject instances)
}
SecurityUtils.setSecurityManager(null);
}
}
代码示例来源:origin: sonia.junit.shiro/shiro-unit
/**
* Method description
*
*/
private void tearDownShiro()
{
try
{
SecurityManager securityManager = SecurityUtils.getSecurityManager();
LifecycleUtils.destroy(securityManager);
ThreadContext.unbindSecurityManager();
ThreadContext.unbindSubject();
ThreadContext.remove();
}
catch (UnavailableSecurityManagerException e)
{
// we don't care about this when cleaning up the test environment
// (for example, maybe the subclass is a unit test and it didn't
// need a SecurityManager instance because it was using only mock Subject instances)
}
SecurityUtils.setSecurityManager(null);
}
}
代码示例来源:origin: com.ning.billing/killbill-util
protected void configureShiro() {
final Ini config = new Ini();
config.addSection("users");
config.getSection("users").put("pierre", "password, creditor");
config.getSection("users").put("stephane", "password, refunder");
config.addSection("roles");
config.getSection("roles").put("creditor", Permission.INVOICE_CAN_CREDIT.toString() + "," + Permission.INVOICE_CAN_ITEM_ADJUST.toString());
config.getSection("roles").put("refunder", Permission.PAYMENT_CAN_REFUND.toString());
// Reset the security manager
ThreadContext.unbindSecurityManager();
final Factory<SecurityManager> factory = new IniSecurityManagerFactory(config);
final SecurityManager securityManager = factory.getInstance();
SecurityUtils.setSecurityManager(securityManager);
}
}
代码示例来源:origin: org.kill-bill.billing/killbill-entitlement
protected void configureShiro() {
final Ini config = new Ini();
config.addSection("users");
config.getSection("users").put("EntitlementUser", "password, entitlement");
config.addSection("roles");
config.getSection("roles").put("entitlement", Permission.ACCOUNT_CAN_CREATE.toString() +
"," + Permission.ENTITLEMENT_CAN_CREATE.toString() +
"," + Permission.ENTITLEMENT_CAN_CHANGE_PLAN.toString() +
"," + Permission.ENTITLEMENT_CAN_PAUSE_RESUME.toString() +
"," + Permission.ENTITLEMENT_CAN_TRANSFER.toString() +
"," + Permission.ENTITLEMENT_CAN_CANCEL.toString());
// Reset the security manager
ThreadContext.unbindSecurityManager();
final Factory<SecurityManager> factory = new IniSecurityManagerFactory(config);
final SecurityManager securityManager = factory.getInstance();
SecurityUtils.setSecurityManager(securityManager);
}
代码示例来源:origin: org.kill-bill.billing/killbill-util
protected void configureShiro() {
final Ini config = new Ini();
config.addSection("users");
config.getSection("users").put("pierre", "password, creditor");
config.getSection("users").put("stephane", "password, refunder");
config.addSection("roles");
config.getSection("roles").put("creditor", Permission.INVOICE_CAN_CREDIT.toString() + "," + Permission.INVOICE_CAN_ITEM_ADJUST.toString());
config.getSection("roles").put("refunder", Permission.PAYMENT_CAN_REFUND.toString());
// Reset the security manager
ThreadContext.unbindSecurityManager();
final Factory<SecurityManager> factory = new IniSecurityManagerFactory(config);
final SecurityManager securityManager = factory.getInstance();
SecurityUtils.setSecurityManager(securityManager);
}
}
内容来源于网络,如有侵权,请联系作者删除!