Search in sources :

Example 1 with SecurityCategoryId

use of ee.ria.xroad.common.identifier.SecurityCategoryId in project X-Road by nordic-institute.

the class ServerConfTest method getRequiredCategories.

/**
 * Tests getting required categories.
 */
@Test
public void getRequiredCategories() {
    ServiceId service1 = createTestServiceId(client(1), service(1, 1), SERVICE_VERSION);
    Collection<SecurityCategoryId> securityCategories = ServerConf.getRequiredCategories(service1);
    assertEquals(1, securityCategories.size());
    assertEquals(SecurityCategoryId.create(XROAD_INSTANCE, SECURITY_CATEGORY + 1), securityCategories.iterator().next());
}
Also used : SecurityCategoryId(ee.ria.xroad.common.identifier.SecurityCategoryId) ServiceId(ee.ria.xroad.common.identifier.ServiceId) TestUtil.createTestServiceId(ee.ria.xroad.proxy.conf.TestUtil.createTestServiceId) Test(org.junit.Test)

Example 2 with SecurityCategoryId

use of ee.ria.xroad.common.identifier.SecurityCategoryId in project X-Road by nordic-institute.

the class CachingServerConfTest method getRequiredCategories.

/**
 * Tests getting required categories.
 */
@Test
public void getRequiredCategories() {
    ServiceId service1 = createTestServiceId(client(1), service(1, 1), SERVICE_VERSION);
    Collection<SecurityCategoryId> securityCategories = ServerConf.getRequiredCategories(service1);
    assertEquals(1, securityCategories.size());
    assertEquals(SecurityCategoryId.create(XROAD_INSTANCE, SECURITY_CATEGORY + 1), securityCategories.iterator().next());
}
Also used : SecurityCategoryId(ee.ria.xroad.common.identifier.SecurityCategoryId) ServiceId(ee.ria.xroad.common.identifier.ServiceId) TestUtil.createTestServiceId(ee.ria.xroad.proxy.conf.TestUtil.createTestServiceId) Test(org.junit.Test)

Example 3 with SecurityCategoryId

use of ee.ria.xroad.common.identifier.SecurityCategoryId in project X-Road by nordic-institute.

the class ServerMessageProcessor method verifySecurityCategory.

private void verifySecurityCategory(ServiceId service) throws Exception {
    Collection<SecurityCategoryId> required = ServerConf.getRequiredCategories(service);
    if (required == null || required.isEmpty()) {
        // Service requires nothing, we are satisfied.
        return;
    }
    Collection<SecurityCategoryId> provided = GlobalConf.getProvidedCategories(getClientAuthCert());
    for (SecurityCategoryId cat : required) {
        if (provided.contains(cat)) {
            // All OK.
            return;
        }
    }
    throw new CodedException(X_SECURITY_CATEGORY, "Service requires security categories (%s), but client only satisfies (%s)", StringUtils.join(required, ", "), StringUtils.join(provided, ", "));
}
Also used : CodedException(ee.ria.xroad.common.CodedException) SecurityCategoryId(ee.ria.xroad.common.identifier.SecurityCategoryId)

Aggregations

SecurityCategoryId (ee.ria.xroad.common.identifier.SecurityCategoryId)3 ServiceId (ee.ria.xroad.common.identifier.ServiceId)2 TestUtil.createTestServiceId (ee.ria.xroad.proxy.conf.TestUtil.createTestServiceId)2 Test (org.junit.Test)2 CodedException (ee.ria.xroad.common.CodedException)1