List of usage examples for org.apache.shiro SecurityUtils setSecurityManager
public static void setSecurityManager(SecurityManager securityManager)
From source file:org.apache.isis.security.shiro.ShiroAuthenticatorOrAuthorizorTest.java
License:Apache License
@Test public void vetoingOverridden() throws Exception { Factory<SecurityManager> factory = new IniSecurityManagerFactory("classpath:shiro.ini"); SecurityManager securityManager = factory.getInstance(); SecurityUtils.setSecurityManager(securityManager); AuthenticationRequest ar = new AuthenticationRequestPassword("lonestarr", "vespa"); authOrAuth.authenticate(ar, null);//from w ww.j a v a 2 s. c o m Identifier removeCustomerIdentifier = Identifier.actionIdentifier("com.mycompany.myapp.Customer", "remove"); assertThat(authOrAuth.isVisibleInAnyRole(removeCustomerIdentifier), is(true)); }
From source file:org.apache.isis.security.shiro.ShiroAuthenticatorOrAuthorizorTest_isVisibleInAnyRole.java
License:Apache License
@Test public void vetoing() throws Exception { // given/*w w w.j av a 2s . co m*/ Factory<SecurityManager> factory = new IniSecurityManagerFactory("classpath:shiro.ini"); SecurityManager securityManager = factory.getInstance(); SecurityUtils.setSecurityManager(securityManager); AuthenticationRequest ar = new AuthenticationRequestPassword("darkhelmet", "ludicrousspeed"); authOrAuth.authenticate(ar, null); // when, then Identifier changeAddressIdentifier = Identifier.actionIdentifier("com.mycompany.myapp.Customer", "changeAddress", String.class, String.class); assertThat(authOrAuth.isVisibleInAnyRole(changeAddressIdentifier), is(true)); // when, then Identifier removeCustomerIdentifier = Identifier.actionIdentifier("com.mycompany.myapp.Customer", "remove"); assertThat(authOrAuth.isVisibleInAnyRole(removeCustomerIdentifier), is(false)); }
From source file:org.apache.isis.security.shiro.ShiroAuthenticatorOrAuthorizorTest_isVisibleInAnyRole.java
License:Apache License
@Test public void vetoingOverridden() throws Exception { // given//from www . j a va2s.c o m Factory<SecurityManager> factory = new IniSecurityManagerFactory("classpath:shiro.ini"); SecurityManager securityManager = factory.getInstance(); SecurityUtils.setSecurityManager(securityManager); AuthenticationRequest ar = new AuthenticationRequestPassword("lonestarr", "vespa"); authOrAuth.authenticate(ar, null); // when, then Identifier removeCustomerIdentifier = Identifier.actionIdentifier("com.mycompany.myapp.Customer", "remove"); assertThat(authOrAuth.isVisibleInAnyRole(removeCustomerIdentifier), is(true)); }
From source file:org.apache.usergrid.security.CustomResolverTest.java
License:Apache License
@BeforeClass public static void setSecurityManager() { DefaultSecurityManager manager = new DefaultSecurityManager(); SecurityUtils.setSecurityManager(manager); }
From source file:org.apache.usergrid.security.CustomResolverTest.java
License:Apache License
@AfterClass public static void tearDownShiro() { doClearSubject();//from w ww.j a va 2 s . co m try { org.apache.shiro.mgt.SecurityManager securityManager = SecurityUtils.getSecurityManager(); LifecycleUtils.destroy(securityManager); } 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:org.apache.usergrid.ServiceITSetupImpl.java
License:Apache License
public ServiceITSetupImpl() { super();/*from w w w .j a v a 2s . co m*/ managementService = springResource.getBean(ManagementService.class); applicationCreator = springResource.getBean(ApplicationCreator.class); tokenService = springResource.getBean(TokenService.class); providerFactory = springResource.getBean(SignInProviderFactory.class); properties = springResource.getBean("properties", Properties.class); smf = springResource.getBean(ServiceManagerFactory.class); exportService = springResource.getBean(ExportService.class); importService = springResource.getBean(ImportService.class); try { appInfoMigrationPlugin = springResource.getBean(GuiceFactory.class).getObject() .getInstance(AppInfoMigrationPlugin.class); } catch (Exception e) { logger.error("Unable to instantiate AppInfoMigrationPlugin", e); } //set our security manager for shiro SecurityUtils.setSecurityManager(springResource.getBean(org.apache.shiro.mgt.SecurityManager.class)); }
From source file:org.atteo.moonshine.shiro.ShiroService.java
License:Apache License
@Override public void start() { SecurityUtils.setSecurityManager(securityManager); }
From source file:org.atteo.moonshine.shiro.ShiroService.java
License:Apache License
@Override public void close() { SecurityUtils.setSecurityManager(null); ThreadContext.unbindSecurityManager(); ThreadContext.unbindSubject(); }
From source file:org.aw20.plugin.login.LoginExtension.java
License:Open Source License
@Override public void pluginStart(PluginManagerInterface manager, xmlCFML systemParameters) { manager.addRequestListener(this); userFormField = systemParameters.getString("server.plugin.login.userfield"); if (userFormField == null || userFormField.length() == 0) { manager.log("[LoginPlugin] <server>.<plugin>.<login>.<userfield>: no userfield specified"); userFormField = null;/*from w w w . j a v a2 s . c o m*/ return; } passwordFormField = systemParameters.getString("server.plugin.login.passwordfield"); if (passwordFormField == null || passwordFormField.length() == 0) { manager.log("[LoginPlugin] <server>.<plugin>.<login>.<passwordfield>: no passwordfield specified"); userFormField = null; return; } returnFormField = systemParameters.getString("server.plugin.login.returnfield"); if (returnFormField == null || returnFormField.length() == 0) { manager.log("[LoginPlugin] <server>.<plugin>.<login>.<returnfield>: no returnfield specified"); userFormField = null; return; } manager.log("[LoginPlugin] userfield=" + userFormField + "; passwordfield=" + passwordFormField + "; returnfield=" + returnFormField); String iniFile = systemParameters.getString("server.plugin.login.ini"); if (iniFile == null || iniFile.length() == 0) { manager.log("[LoginPlugin] <server>.<plugin>.<login>.<ini>: No INI path given"); userFormField = null; return; } File iniF = new File(iniFile); if (!iniF.exists()) { manager.log("[LoginPlugin] <server>.<plugin>.<login>.<ini>: " + iniF + " was not found"); userFormField = null; return; } manager.log("[LoginPlugin] iniFile=" + iniFile); // Setup the factory factory = new IniSecurityManagerFactory(iniFile); SecurityUtils.setSecurityManager(factory.getInstance()); }
From source file:org.codehaus.griffon.runtime.shiro.SubjectProvider.java
License:Apache License
@Override public Subject get() { SecurityUtils.setSecurityManager(securityManager); return SecurityUtils.getSubject(); }