Search in sources :

Example 1 with AuthorizationServiceImpl

use of org.glassfish.security.services.impl.authorization.AuthorizationServiceImpl in project Payara by payara.

the class CreateJavaMailResourceTest method setUp.

@Before
public void setUp() {
    System.out.println("\n\n *** Entering setup method *** \n\n");
    System.out.println("Current dir: " + System.getProperty("user.dir") + "\n");
    AuthorizationService foo = new AuthorizationServiceImpl();
    System.out.println("Direct instantiation: " + foo);
    habitat = getHabitat();
    foo = habitat.getService(AuthorizationService.class);
    System.out.println("Lookup via habitat: " + foo + "\n");
    resources = habitat.<Domain>getService(Domain.class).getResources();
    assertTrue(resources != null);
    parameters = new ParameterMap();
    context = new AdminCommandContextImpl(getLogger(CreateJavaMailResourceTest.class, ADMIN_LOGGER), new PropsFileActionReporter());
    cr = habitat.getService(CommandRunner.class);
    assertTrue(cr != null);
}
Also used : AdminCommandContextImpl(org.glassfish.api.admin.AdminCommandContextImpl) AuthorizationService(org.glassfish.security.services.api.authorization.AuthorizationService) ParameterMap(org.glassfish.api.admin.ParameterMap) Domain(com.sun.enterprise.config.serverbeans.Domain) PropsFileActionReporter(com.sun.enterprise.v3.common.PropsFileActionReporter) CommandRunner(org.glassfish.api.admin.CommandRunner) AuthorizationServiceImpl(org.glassfish.security.services.impl.authorization.AuthorizationServiceImpl) Before(org.junit.Before)

Example 2 with AuthorizationServiceImpl

use of org.glassfish.security.services.impl.authorization.AuthorizationServiceImpl in project Payara by payara.

the class SimpleAtzProviderTest method testService.

@Test
public void testService() throws Exception {
    final AuthorizationService authorizationService = new AuthorizationServiceImpl();
    Assert.assertNotNull(simpleAtzPrv);
    final AzEnvironment env = new AzEnvironmentImpl();
    final Attributes attrs = contextService.getEnvironmentAttributes();
    for (String attrName : attrs.getAttributeNames()) {
        env.addAttribute(attrName, attrs.getAttributeValue(attrName), true);
    }
    AzSubject azS = authorizationService.makeAzSubject(adminSubject());
    AzResult rt = simpleAtzPrv.getAuthorizationDecision(azS, authorizationService.makeAzResource(URI.create("admin://some/path")), authorizationService.makeAzAction("read"), env, null);
    AzResult.Decision ds = rt.getDecision();
    Assert.assertEquals(AzResult.Decision.PERMIT, ds);
}
Also used : Attributes(org.glassfish.security.services.api.common.Attributes) AuthorizationServiceImpl(org.glassfish.security.services.impl.authorization.AuthorizationServiceImpl) Test(org.junit.Test)

Aggregations

AuthorizationServiceImpl (org.glassfish.security.services.impl.authorization.AuthorizationServiceImpl)2 Domain (com.sun.enterprise.config.serverbeans.Domain)1 PropsFileActionReporter (com.sun.enterprise.v3.common.PropsFileActionReporter)1 AdminCommandContextImpl (org.glassfish.api.admin.AdminCommandContextImpl)1 CommandRunner (org.glassfish.api.admin.CommandRunner)1 ParameterMap (org.glassfish.api.admin.ParameterMap)1 AuthorizationService (org.glassfish.security.services.api.authorization.AuthorizationService)1 Attributes (org.glassfish.security.services.api.common.Attributes)1 Before (org.junit.Before)1 Test (org.junit.Test)1