javax.ejb.EJBAccessException Java Examples

The following examples show how to use javax.ejb.EJBAccessException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ReportingQueryIT.java    From development with Apache License 2.0 6 votes vote down vote up
@Test(expected = EJBAccessException.class)
public void getAvailableReportsForOrgAdmin_NotAuthorized()
        throws Exception {
    runTX(new Callable<Void>() {
        @Override
        public Void call() throws Exception {
            container.login(String.valueOf(supplierUserA.getKey()),
                    UserRoleType.SUBSCRIPTION_MANAGER.name());
            try {
                reportService
                        .getAvailableReportsForOrgAdmin(ReportType.ALL);
            } catch (EJBException e) {
                throw e.getCausedByException();
            }
            return null;
        }
    });
}
 
Example #2
Source File: AccountServiceBeanPermissionIT.java    From development with Apache License 2.0 6 votes vote down vote up
@Test
public void updateCustomerDiscount_asReseller() throws Exception {
    // given
    container.login(givenReseller().getKey(),
            UserRoleType.RESELLER_MANAGER.name());

    // when
    try {
        as.updateCustomerDiscount(new VOOrganization());
        fail();
    } catch (EJBException e) {

        // then
        assertTrue(e.getCausedByException() instanceof EJBAccessException);
    }
}
 
Example #3
Source File: VatServiceBeanPermissionIT.java    From development with Apache License 2.0 6 votes vote down vote up
@Test
public void saveAllVats_asBroker() throws Exception {
    // given
    container.login(givenBroker().getKey(),
            UserRoleType.BROKER_MANAGER.name());

    // when
    try {
        vatService.saveAllVats(new VOVatRate(),
                new ArrayList<VOCountryVatRate>(),
                new ArrayList<VOOrganizationVatRate>());
        fail("EJBException expected as operation must fail due to not allowed role!");
    } catch (EJBException e) {

        // then
        assertTrue(e.getCausedByException() instanceof EJBAccessException);
    }
}
 
Example #4
Source File: PricingServiceBeanMarketplacesIT.java    From development with Apache License 2.0 6 votes vote down vote up
@Test
public void getPricingForMarketplace_invalidRole() throws Exception {
    // given
    container.login(givenTechProvider().getKey(),
            UserRoleType.TECHNOLOGY_MANAGER.name());

    // when
    try {
        pricingService.getPricingForMarketplace(OPEN_MP_ID);
        fail();
    } catch (EJBException e) {

        // then
        assertTrue(e.getCausedByException() instanceof EJBAccessException);
    }
}
 
Example #5
Source File: PricingServiceBeanContainerIT.java    From development with Apache License 2.0 6 votes vote down vote up
@Test
public void getPartnerRevenueSharesForMarketplace_invalidRole()
        throws Exception {

    // given
    container.login(mpOwnerUserKey, UserRoleType.TECHNOLOGY_MANAGER.name());

    // when
    try {
        pricingService.getPartnerRevenueSharesForMarketplace(MARKETPLACEID);
        fail();
    } catch (EJBException e) {

        // then
        assertTrue(e.getCausedByException() instanceof EJBAccessException);
    }
}
 
Example #6
Source File: AccountServiceBeanPermissionIT.java    From development with Apache License 2.0 6 votes vote down vote up
@Test
public void updateCustomerDiscount_asBroker() throws Exception {
    // given
    container.login(givenBroker().getKey(),
            UserRoleType.BROKER_MANAGER.name());

    // when
    try {
        as.updateCustomerDiscount(new VOOrganization());
        fail();
    } catch (EJBException e) {

        // then
        assertTrue(e.getCausedByException() instanceof EJBAccessException);
    }
}
 
Example #7
Source File: PricingServiceBeanAllStatesServiceRevenueSharesIT.java    From development with Apache License 2.0 6 votes vote down vote up
@Test
public void getPartnerRevenueShareForAllStatesService_invalidRole()
        throws Exception {
    setupWithContainer();
    // given
    container.login(mpOwnerUserKey, UserRoleType.TECHNOLOGY_MANAGER.name());

    // when
    try {
        pricingService.getPartnerRevenueShareForAllStatesService(
                new POServiceForPricing());
        fail();
    } catch (EJBException e) {

        // then
        assertTrue(e.getCausedByException() instanceof EJBAccessException);
    }
}
 
Example #8
Source File: AccountServiceBeanPermissionIT.java    From development with Apache License 2.0 6 votes vote down vote up
@Test
public void getServicePaymentConfiguration_asBroker() throws Exception {
    // given
    container.login(givenBroker().getKey(),
            UserRoleType.BROKER_MANAGER.name());

    try {
        // when
        as.getServicePaymentConfiguration();
        fail();
    } catch (EJBException e) {

        // then
        assertTrue(e.getCausedByException() instanceof EJBAccessException);
    }
}
 
Example #9
Source File: VatServiceBeanPermissionIT.java    From development with Apache License 2.0 6 votes vote down vote up
@Test
public void saveDefaultVat_asBroker() throws Exception {
    // given
    container.login(givenBroker().getKey(),
            UserRoleType.BROKER_MANAGER.name());

    // when
    try {
        vatService.saveDefaultVat(new VOVatRate());
        fail("EJBException expected as operation must fail due to not allowed role!");
    } catch (EJBException e) {

        // then
        assertTrue(e.getCausedByException() instanceof EJBAccessException);
    }
}
 
Example #10
Source File: LandingpageServiceBeanIT.java    From development with Apache License 2.0 6 votes vote down vote up
@Test(expected = EJBAccessException.class)
public void resetLandingpage_invalidRole() throws Throwable {
    // given
    String invalidRole = UserRoleType.ORGANIZATION_ADMIN.name();
    container.login(mpOwnerUserKey, invalidRole);

    // when
    try {
        landingpageServiceLocal.resetLandingpage(MARKETPLACEID);
    } catch (EJBException e) {
        throw e.getCause();
    }

    // then
    fail();
}
 
Example #11
Source File: RESTExceptionMapperTest.java    From datawave with Apache License 2.0 6 votes vote down vote up
@Test
public void testToResponse_EJBAccessException() {
    Exception e = new EJBAccessException("Caller unauthorized");
    StackTraceElement[] traceArr = new StackTraceElement[1];
    traceArr[0] = new StackTraceElement("dummyClass", "dummyMethod", null, 0);
    
    e.setStackTrace(traceArr);
    
    Response response = rem.toResponse(e);
    MultivaluedMap<String,Object> responseMap = response.getHeaders();
    
    Assert.assertEquals(403, response.getStatus());
    Assert.assertEquals(6, responseMap.size());
    Assert.assertEquals(Lists.newArrayList(true), responseMap.get(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS));
    Assert.assertEquals(Lists.newArrayList("*"), responseMap.get(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN));
    Assert.assertEquals(Lists.newArrayList(864000), responseMap.get(HttpHeaders.ACCESS_CONTROL_MAX_AGE));
    Assert.assertEquals(Lists.newArrayList("403-1"), responseMap.get(Constants.ERROR_CODE));
    Assert.assertEquals(Lists.newArrayList("null/null"), responseMap.get(Constants.RESPONSE_ORIGIN));
    Assert.assertEquals(Lists.newArrayList("X-SSL-ClientCert-Subject, X-ProxiedEntitiesChain, X-ProxiedIssuersChain, Accept, Accept-Encoding"),
                    responseMap.get(HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS));
}
 
Example #12
Source File: PricingServiceBeanServiceRevenueSharesIT.java    From development with Apache License 2.0 6 votes vote down vote up
@Test
public void getPartnerRevenueShareForService_invalidRole()
        throws Exception {
    setupWithContainer();
    // given
    container.login(mpOwnerUserKey, UserRoleType.TECHNOLOGY_MANAGER.name());

    // when
    try {
        pricingService.getPartnerRevenueShareForService(
                new POServiceForPricing());
        fail();
    } catch (EJBException e) {

        // then
        assertTrue(e.getCausedByException() instanceof EJBAccessException);
    }
}
 
Example #13
Source File: PricingServiceBeanContainerIT.java    From development with Apache License 2.0 6 votes vote down vote up
@Test
public void getMarketplaceRevenueShares_invalidRole() throws Exception {

    // given
    container.login(mpOwnerUserKey, UserRoleType.TECHNOLOGY_MANAGER.name());

    // when
    try {
        pricingService.getMarketplaceRevenueShares(MARKETPLACEID);
        fail();
    } catch (EJBException e) {

        // then
        assertTrue(e.getCausedByException() instanceof EJBAccessException);
    }
}
 
Example #14
Source File: LandingpageServiceBeanIT.java    From development with Apache License 2.0 6 votes vote down vote up
@Test(expected = EJBAccessException.class)
public void availableServices_invalidRole() throws Throwable {
    // given
    String invalidRole = UserRoleType.ORGANIZATION_ADMIN.name();
    container.login(mpOwnerUserKey, invalidRole);

    // when
    try {
        landingpageServiceLocal.availableServices(MARKETPLACEID);
    } catch (EJBException e) {
        throw e.getCause();
    }

    // then
    fail();
}
 
Example #15
Source File: VatServiceBeanPermissionIT.java    From development with Apache License 2.0 6 votes vote down vote up
@Test
public void saveOrganizationVats_asReseller() throws Exception {
    // given
    container.login(givenReseller().getKey(),
            UserRoleType.RESELLER_MANAGER.name());

    // when
    try {
        vatService.saveOrganizationVats(
                new ArrayList<VOOrganizationVatRate>());
        fail("EJBException expected as operation must fail due to not allowed role!");
    } catch (EJBException e) {

        // then
        assertTrue(e.getCausedByException() instanceof EJBAccessException);
    }
}
 
Example #16
Source File: VatServiceBeanPermissionIT.java    From development with Apache License 2.0 6 votes vote down vote up
@Test
public void saveOrganizationVats_asBroker() throws Exception {
    // given
    container.login(givenBroker().getKey(),
            UserRoleType.BROKER_MANAGER.name());

    // when
    try {
        vatService.saveOrganizationVats(
                new ArrayList<VOOrganizationVatRate>());
        fail("EJBException expected as operation must fail due to not allowed role!");
    } catch (EJBException e) {

        // then
        assertTrue(e.getCausedByException() instanceof EJBAccessException);
    }
}
 
Example #17
Source File: ServiceProvisioningServiceBeanPermissionIT.java    From development with Apache License 2.0 6 votes vote down vote up
@Test
public void updateService_asBroker() throws Exception {
    // given
    container.login(1L, UserRoleType.BROKER_MANAGER.name());

    // when
    try {
        sps.updateService(new VOServiceDetails(), null);
        fail();
    } catch (EJBException e) {

        // then
        assertTrue(e.getCausedByException() instanceof EJBAccessException);
    }

}
 
Example #18
Source File: ServiceProvisioningServiceBeanPermissionIT.java    From development with Apache License 2.0 6 votes vote down vote up
@Test
public void savePriceModelForCustomer_asReseller() throws Exception {
    // given
    container.login(1L, UserRoleType.RESELLER_MANAGER.name());

    // when
    try {
        sps.savePriceModelForCustomer(new VOServiceDetails(),
                new VOPriceModel(), new VOOrganization());
        fail();
    } catch (EJBException e) {

        // then
        assertTrue(e.getCausedByException() instanceof EJBAccessException);
    }

}
 
Example #19
Source File: ServiceProvisioningServiceBeanPermissionIT.java    From development with Apache License 2.0 6 votes vote down vote up
@Test
public void savePriceModelForCustomer_asBroker() throws Exception {
    // given
    container.login(1L, UserRoleType.BROKER_MANAGER.name());

    // when
    try {
        sps.savePriceModelForCustomer(new VOServiceDetails(),
                new VOPriceModel(), new VOOrganization());
        fail();
    } catch (EJBException e) {

        // then
        assertTrue(e.getCausedByException() instanceof EJBAccessException);
    }
}
 
Example #20
Source File: ServiceProvisioningServiceBeanPermissionIT.java    From development with Apache License 2.0 6 votes vote down vote up
@Test
public void savePriceModelForSubscription_asReseller() throws Exception {
    // given
    container.login(1L, UserRoleType.RESELLER_MANAGER.name());

    // when
    try {
        sps.savePriceModelForSubscription(new VOServiceDetails(),
                new VOPriceModel());
        fail();
    } catch (EJBException e) {

        // then
        assertTrue(e.getCausedByException() instanceof EJBAccessException);
    }
}
 
Example #21
Source File: VatServiceBeanPermissionIT.java    From development with Apache License 2.0 6 votes vote down vote up
@Test
public void saveCountryVats_asReseller() throws Exception {
    // given
    container.login(givenReseller().getKey(),
            UserRoleType.RESELLER_MANAGER.name());

    // when
    try {
        vatService.saveCountryVats(new ArrayList<VOCountryVatRate>());
        fail("EJBException expected as operation must fail due to not allowed role!");
    } catch (EJBException e) {

        // then
        assertTrue(e.getCausedByException() instanceof EJBAccessException);
    }
}
 
Example #22
Source File: PublishServiceBeanPermissionIT.java    From development with Apache License 2.0 6 votes vote down vote up
@Test
public void getBrokerOrganizations_asReseller() throws Exception {
    // given
    container.login(givenReseller().getKey(),
            UserRoleType.RESELLER_MANAGER.name());

    try {
        // when
        publishService.getBrokers(0L);
        fail();
    } catch (EJBException e) {

        // then
        assertTrue(e.getCausedByException() instanceof EJBAccessException);
    }
}
 
Example #23
Source File: RESTExceptionMapperTest.java    From datawave with Apache License 2.0 6 votes vote down vote up
@Test
public void testToResponse_EJBAccessException2() {
    Exception e = new EJBAccessException("Caller is legit");
    StackTraceElement[] traceArr = new StackTraceElement[1];
    traceArr[0] = new StackTraceElement("dummyClass", "dummyMethod", null, 0);
    
    e.setStackTrace(traceArr);
    
    Response response = rem.toResponse(e);
    MultivaluedMap<String,Object> responseMap = response.getHeaders();
    
    Assert.assertEquals(500, response.getStatus());
    Assert.assertEquals(6, responseMap.size());
    Assert.assertEquals(Lists.newArrayList(true), responseMap.get(HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS));
    Assert.assertEquals(Lists.newArrayList("*"), responseMap.get(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN));
    Assert.assertEquals(Lists.newArrayList(864000), responseMap.get(HttpHeaders.ACCESS_CONTROL_MAX_AGE));
    Assert.assertEquals(Lists.newArrayList("500-1"), responseMap.get(Constants.ERROR_CODE));
    Assert.assertEquals(Lists.newArrayList("null/null"), responseMap.get(Constants.RESPONSE_ORIGIN));
    Assert.assertEquals(Lists.newArrayList("X-SSL-ClientCert-Subject, X-ProxiedEntitiesChain, X-ProxiedIssuersChain, Accept, Accept-Encoding"),
                    responseMap.get(HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS));
}
 
Example #24
Source File: SubscriptionsServiceBeanIT.java    From development with Apache License 2.0 6 votes vote down vote up
@Test(expected = EJBAccessException.class)
public void getSubscriptionsForOrgSize_NotAuthorized() throws Exception {
    runTX(new Callable<Void>() {
        @Override
        public Void call() throws Exception {
            container.login(String.valueOf(admin.getKey()));
            try {
                service.getSubscriptionsForOrgSize(
                        new HashSet<SubscriptionStatus>(), new Pagination());
            } catch (EJBException e) {
                throw e.getCausedByException();
            }
            return null;
        }
    });
}
 
Example #25
Source File: PublishServiceBeanPermissionIT.java    From development with Apache License 2.0 6 votes vote down vote up
@Test
public void getResellerOrganizations_asReseller() throws Exception {
    // given
    container.login(givenReseller().getKey(),
            UserRoleType.RESELLER_MANAGER.name());

    try {
        // when
        publishService.getResellers(0L);
        fail();
    } catch (EJBException e) {

        // then
        assertTrue(e.getCausedByException() instanceof EJBAccessException);
    }
}
 
Example #26
Source File: MarketplaceServiceManagePartnerBeanRolesIT.java    From development with Apache License 2.0 5 votes vote down vote up
@Test
public void updateMarketplace_ResellerManager() throws Exception {
    container.login(user.getKey(), ROLE_RESELLER_MANAGER);
    try {
        service.updateMarketplace(null, null, null);
        fail();
    } catch (EJBException ex) {
        assertTrue(ex.getCause() instanceof EJBAccessException);
    }
}
 
Example #27
Source File: TriggerDefinitionServiceBeanIT.java    From development with Apache License 2.0 5 votes vote down vote up
@Test(expected = EJBAccessException.class)
public void testUpdateTrigger_WrongUserRole() throws Exception {

    VOTriggerDefinition trigger = createTriggerForSupp1();

    container.login(nonAdminKey, UserRoleType.MARKETPLACE_OWNER.name());
    updateTriggerDefinition(trigger);
    Assert.fail();
}
 
Example #28
Source File: TriggerDefinitionServiceBeanIT.java    From development with Apache License 2.0 5 votes vote down vote up
@Test(expected = EJBAccessException.class)
public void testDeleteTriggerDefinition_WrongRole()
        throws Exception, DeletionConstraintException {
    VOTriggerDefinition trigger = createTriggerForSupp1();

    container.login(nonAdminKey, UserRoleType.MARKETPLACE_OWNER.name());
    deleteTriggerDefinition(trigger.getKey());
    Assert.fail();
}
 
Example #29
Source File: TriggerDefinitionServiceBeanIT.java    From development with Apache License 2.0 5 votes vote down vote up
@Test(expected = EJBAccessException.class)
public void getTriggerTypes_nonAdmin() throws Exception {
    // given
    container.login(nonAdminKey, UserRoleType.MARKETPLACE_OWNER.name());

    // when
    try {
        triggerDefinitionService.getTriggerTypes();
    } catch (EJBException ex) {
        throw ex.getCausedByException();
    }

    // then
    // exception
}
 
Example #30
Source File: ServiceProvisioningPotentialCompatibleServicesIT.java    From development with Apache License 2.0 5 votes vote down vote up
@Test(expected = EJBAccessException.class)
public void getPotentialCompatibleServices_TechnologyManager()
        throws Exception {
    container.login(userKey, UserRoleType.TECHNOLOGY_MANAGER.name());
    try {
        sps.getPotentialCompatibleServices(null);
    } catch (EJBException e) {
        throw e.getCausedByException();
    }
}