use of javax.security.auth.AuthPermission in project spring-framework by spring-projects.
the class CallbacksSecurityTests method testTrustedExecution.
@Test
public void testTrustedExecution() throws Exception {
beanFactory.setSecurityContextProvider(null);
Permissions perms = new Permissions();
perms.add(new AuthPermission("getSubject"));
ProtectionDomain pd = new ProtectionDomain(null, perms);
new AccessControlContext(new ProtectionDomain[] { pd });
final Subject subject = new Subject();
subject.getPrincipals().add(new TestPrincipal("user1"));
// request the beans from non-privileged code
Subject.doAsPrivileged(subject, new PrivilegedAction<Object>() {
@Override
public Object run() {
// sanity check
assertEquals("user1", getCurrentSubjectName());
assertEquals(false, NonPrivilegedBean.destroyed);
beanFactory.getBean("trusted-spring-callbacks");
beanFactory.getBean("trusted-custom-init-destroy");
// the factory is a prototype - ask for multiple instances
beanFactory.getBean("trusted-spring-factory");
beanFactory.getBean("trusted-spring-factory");
beanFactory.getBean("trusted-spring-factory");
beanFactory.getBean("trusted-factory-bean");
beanFactory.getBean("trusted-static-factory-method");
beanFactory.getBean("trusted-factory-method");
beanFactory.getBean("trusted-property-injection");
beanFactory.getBean("trusted-working-property-injection");
beanFactory.destroySingletons();
assertEquals(true, NonPrivilegedBean.destroyed);
return null;
}
}, provider.getAccessControlContext());
}
use of javax.security.auth.AuthPermission in project wildfly by wildfly.
the class AuthenticationTestCase method deployment.
/*
* Authentication Scenarios
*
* Client -> Bean
* Client -> Bean -> Bean
* Client -> Bean (Re-auth) -> Bean
* Client -> Servlet -> Bean
* Client -> Servlet (Re-auth) -> Bean
* Client -> Servlet -> Bean -> Bean
* Client -> Servlet -> Bean (Re Auth) -> Bean
*/
@Deployment
public static Archive<?> deployment() {
final Package currentPackage = AuthenticationTestCase.class.getPackage();
// using JavaArchive doesn't work, because of a bug in Arquillian, it only deploys wars properly
final WebArchive war = ShrinkWrap.create(WebArchive.class, "ejb3security.war").addPackage(WhoAmIBean.class.getPackage()).addPackage(EntryBean.class.getPackage()).addClass(WhoAmI.class).addClass(Util.class).addClass(Entry.class).addClasses(WhoAmIServlet.class, AuthenticationTestCase.class).addClasses(AbstractSecurityDomainSetup.class, EjbSecurityDomainSetup.class).addClass(TestSuiteEnvironment.class).addAsResource(currentPackage, "users.properties", "users.properties").addAsResource(currentPackage, "roles.properties", "roles.properties").addAsWebInfResource(currentPackage, "web.xml", "web.xml").addAsWebInfResource(currentPackage, "jboss-web.xml", "jboss-web.xml").addAsWebInfResource(currentPackage, "jboss-ejb3.xml", "jboss-ejb3.xml").addAsManifestResource(new StringAsset("Manifest-Version: 1.0\nDependencies: org.jboss.as.controller-client,org.jboss.dmr\n"), "MANIFEST.MF").addAsManifestResource(createPermissionsXmlAsset(// login module needs to modify pricipal to commit logging in
new AuthPermission("modifyPrincipals"), // AuthenticationTestCase#testAuthenticatedCall calls org.jboss.security.client.JBossSecurityClient#performSimpleLogin
new RuntimePermission("org.jboss.security.getSecurityContext"), new RuntimePermission("org.jboss.security.SecurityContextFactory.createSecurityContext"), new RuntimePermission("org.jboss.security.SecurityContextFactory.createUtil"), new RuntimePermission("org.jboss.security.plugins.JBossSecurityContext.setSubjectInfo"), new RuntimePermission("org.jboss.security.setSecurityContext"), // AuthenticationTestCase#execute calls ExecutorService#shutdownNow
new RuntimePermission("modifyThread"), // AuthenticationTestCase#execute calls sun.net.www.http.HttpClient#openServer under the hood
new SocketPermission(SERVER_HOST_PORT, "connect,resolve"), // TestSuiteEnvironment reads system properties
new PropertyPermission("management.address", "read"), new PropertyPermission("node0", "read"), new PropertyPermission("jboss.http.port", "read")), "permissions.xml");
war.addPackage(CommonCriteria.class.getPackage());
return war;
}
use of javax.security.auth.AuthPermission in project wildfly by wildfly.
the class IIOPSecurityInvocationTestCase method clientDeployment.
@Deployment(name = "client", testable = true)
@TargetsContainer("iiop-client")
public static Archive<?> clientDeployment() {
/*
* The @EJB annotation doesn't allow to specify the address dynamically. So, istead of
* @EJB(lookup = "corbaname:iiop:localhost:3628#IIOPTransactionalStatelessBean")
* private IIOPTransactionalHome home;
* we need to do this trick to get the ${node0} sys prop into ejb-jar.xml
* and have it injected that way.
*/
String ejbJar = FileUtils.readFile(IIOPSecurityInvocationTestCase.class, "ejb-jar.xml");
final Properties properties = new Properties();
properties.putAll(System.getProperties());
if (properties.containsKey("node1")) {
properties.put("node1", NetworkUtils.formatPossibleIpv6Address((String) properties.get("node1")));
}
final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "client.jar");
jar.addClasses(ClientEjb.class, IIOPSecurityStatelessHome.class, IIOPSecurityStatelessRemote.class, IIOPSecurityInvocationTestCase.class, Util.class).addAsManifestResource(IIOPSecurityInvocationTestCase.class.getPackage(), "jboss-ejb3.xml", "jboss-ejb3.xml").addAsManifestResource(new StringAsset(PropertiesValueResolver.replaceProperties(ejbJar, properties)), "ejb-jar.xml").addAsManifestResource(PermissionUtils.createPermissionsXmlAsset(new AuthPermission("modifyPrincipals")), "permissions.xml");
return jar;
}
use of javax.security.auth.AuthPermission in project scheduling by ow2-proactive.
the class RMDBManagerTest method setUp.
@Before
public void setUp() {
PAResourceManagerProperties.RM_NODES_LOCK_RESTORATION.updateProperty("true");
PAResourceManagerProperties.RM_ALIVE_EVENT_FREQUENCY.updateProperty("10000");
dbManager = RMDBManager.createInMemoryRMDBManager();
addNodeSourceData();
owner = new Client();
owner.setId(OWNER_ID);
provider = new Client();
provider.setId(PROVIDER_ID);
permission = new AuthPermission(PERMISSION_NAME);
}
Aggregations