List of usage examples for org.apache.shiro.util ThreadContext unbindSubject
public static Subject unbindSubject()
From source file:com.github.sdorra.shiro.ShiroRule.java
License:Open Source License
/** * Method description/*from w ww . ja v a 2 s .c om*/ * */ 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); }
From source file:com.glaf.shiro.ShiroSecurity.java
License:Apache License
public static void logout() { try {/*from w w w. j a v a 2 s. c om*/ Subject currentUser = SecurityUtils.getSubject(); currentUser.logout(); ThreadContext.unbindSubject(); logger.debug(" shior logout."); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:com.zhengxuetao.shiro.LoginFromDBTest.java
@After public void tearDown() throws Exception { ThreadContext.unbindSubject();//Subject ??? //SecurityUtils.getSubject().logout(); }
From source file:com.zhengxuetao.shiro.LoginFromRealmTest.java
@After public void tearDown() throws Exception { ThreadContext.unbindSubject();//Subject ??? //SecurityUtils.getSubject().logout(); }
From source file:com.zhengxuetao.shiro.LoginTest.java
@After public void tearDown() throws Exception { ThreadContext.unbindSubject();//Subject ??? }
From source file:ddf.catalog.event.retrievestatus.AbstractDownloadsStatusEventPublisherTest.java
License:Open Source License
@After public void tearDownTest() { // Remove the security from the thread after every test ThreadContext.unbindSecurityManager(); ThreadContext.unbindSubject(); }
From source file:ddf.catalog.security.ingest.IngestPluginTest.java
License:Open Source License
@Test public void testCreateProcessGoodSubject() throws Exception { IngestPlugin ingestPlugin = new IngestPlugin(); ingestPlugin.setPermissionStrings(new String[] { "role=admin" }); Subject subject = mock(Subject.class); when(subject.isPermitted(any(Permission.class))).thenReturn(true); ThreadContext.bind(subject);//w w w. j ava 2 s .com CreateRequest request = mock(CreateRequest.class); CreateRequest response = ingestPlugin.process(request); assertThat(response, not(equalTo(null))); ThreadContext.unbindSubject(); }
From source file:ddf.catalog.security.ingest.IngestPluginTest.java
License:Open Source License
@Test public void testUpdateProcessGoodSubject() throws Exception { IngestPlugin ingestPlugin = new IngestPlugin(); ingestPlugin.setPermissionStrings(new String[] { "role=admin" }); Subject subject = mock(Subject.class); when(subject.isPermitted(any(Permission.class))).thenReturn(true); ThreadContext.bind(subject);//from ww w .jav a 2 s . c o m UpdateRequest request = mock(UpdateRequest.class); UpdateRequest response = ingestPlugin.process(request); assertThat(response, not(equalTo(null))); ThreadContext.unbindSubject(); }
From source file:ddf.catalog.security.ingest.IngestPluginTest.java
License:Open Source License
@Test public void testDeleteProcessGoodSubject() throws Exception { IngestPlugin ingestPlugin = new IngestPlugin(); ingestPlugin.setPermissionStrings(new String[] { "role=admin" }); Subject subject = mock(Subject.class); when(subject.isPermitted(any(Permission.class))).thenReturn(true); ThreadContext.bind(subject);/* w w w . j a v a 2 s.c o m*/ DeleteRequest request = mock(DeleteRequest.class); DeleteRequest response = ingestPlugin.process(request); assertThat(response, not(equalTo(null))); ThreadContext.unbindSubject(); }
From source file:ddf.catalog.security.ingest.IngestPluginTest.java
License:Open Source License
@Test(expected = StopProcessingException.class) public void testCreateProcessBadSubject() throws Exception { IngestPlugin ingestPlugin = new IngestPlugin(); ingestPlugin.setPermissionStrings(new String[] { "role=admin" }); Subject subject = mock(Subject.class); when(subject.isPermitted(any(Permission.class))).thenReturn(false); ThreadContext.bind(subject);//from www . ja va 2 s. co m CreateRequest request = mock(CreateRequest.class); CreateRequest response = ingestPlugin.process(request); ThreadContext.unbindSubject(); }