Search in sources :

Example 1 with ClientId

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

the class AllowedMethodsMessage method startUp.

@Override
protected void startUp() throws Exception {
    super.startUp();
    ServerConf.reload(new TestSuiteServerConf() {

        @Override
        public List<ServiceId> getAllowedServicesByDescriptionType(ClientId serviceProvider, ClientId client, DescriptionType descriptionType) {
            assertThat("Wrong client in query", client, is(expectedClientQuery));
            assertThat("Wrong service provider in query", serviceProvider, is(expectedProviderQuery));
            return expectedServices;
        }
    });
}
Also used : DescriptionType(ee.ria.xroad.common.conf.serverconf.model.DescriptionType) TestSuiteServerConf(ee.ria.xroad.proxy.testsuite.TestSuiteServerConf) ClientId(ee.ria.xroad.common.identifier.ClientId) List(java.util.List)

Example 2 with ClientId

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

the class ListMethodsMessage method startUp.

@Override
protected void startUp() throws Exception {
    super.startUp();
    ServerConf.reload(new TestSuiteServerConf() {

        @Override
        public List<ServiceId> getServicesByDescriptionType(ClientId serviceProvider, DescriptionType descriptionType) {
            assertThat("Client id does not match expected", serviceProvider, is(expectedClientId));
            return expectedServices;
        }
    });
}
Also used : DescriptionType(ee.ria.xroad.common.conf.serverconf.model.DescriptionType) TestSuiteServerConf(ee.ria.xroad.proxy.testsuite.TestSuiteServerConf) ClientId(ee.ria.xroad.common.identifier.ClientId) List(java.util.List)

Example 3 with ClientId

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

the class ProxyMonitorServiceHandlerImpl method verifyAccess.

private void verifyAccess() {
    final ClientId owner = ServerConf.getIdentifier().getOwner();
    final ClientId client = requestMessage.getSoap().getClient();
    if (owner.equals(client)) {
        return;
    }
    // Grant access for configured monitoring client (if any)
    ClientId monitoringClient = MonitoringConf.getInstance().getMonitoringClient();
    if (monitoringClient != null && monitoringClient.equals(client)) {
        return;
    }
    throw new CodedException(ErrorCodes.X_ACCESS_DENIED, "Request is not allowed: %s", requestMessage.getSoap().getService());
}
Also used : CodedException(ee.ria.xroad.common.CodedException) ClientId(ee.ria.xroad.common.identifier.ClientId)

Example 4 with ClientId

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

the class ProxyMonitorServiceHandlerImpl method isOwner.

private boolean isOwner() {
    final ClientId owner = ServerConf.getIdentifier().getOwner();
    final ClientId client = requestMessage.getSoap().getClient();
    return owner.equals(client);
}
Also used : ClientId(ee.ria.xroad.common.identifier.ClientId)

Example 5 with ClientId

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

the class ProxyMonitorServiceHandlerTest method shouldThrowWhenAccessNotAllowed.

@Test
public void shouldThrowWhenAccessNotAllowed() throws Exception {
    // setup
    ProxyMonitorServiceHandlerImpl handlerToTest = new ProxyMonitorServiceHandlerImpl();
    // the allowed monitoring client from test resources monitoring metricNames
    final ClientId nonAllowedClient = ClientId.create(EXPECTED_XR_INSTANCE, "COM", "justSomeClient");
    final SoapMessageImpl mockSoap = mock(SoapMessageImpl.class);
    when(mockSoap.getClient()).thenReturn(nonAllowedClient);
    when(mockProxyMessage.getSoap()).thenReturn(mockSoap);
    thrown.expect(CodedException.class);
    thrown.expect(faultCodeEquals(ErrorCodes.X_ACCESS_DENIED));
    thrown.expectMessage(containsString("Request is not allowed"));
    handlerToTest.canHandle(MONITOR_SERVICE_ID, mockProxyMessage);
    // execution
    handlerToTest.shouldVerifyAccess();
// expecting an exception..
}
Also used : ClientId(ee.ria.xroad.common.identifier.ClientId) SoapMessageImpl(ee.ria.xroad.common.message.SoapMessageImpl) Test(org.junit.Test)

Aggregations

ClientId (ee.ria.xroad.common.identifier.ClientId)227 Test (org.junit.Test)129 ClientType (ee.ria.xroad.common.conf.serverconf.model.ClientType)46 XRoadId (ee.ria.xroad.common.identifier.XRoadId)40 HashSet (java.util.HashSet)35 List (java.util.List)33 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)29 ServiceId (ee.ria.xroad.common.identifier.ServiceId)26 ArrayList (java.util.ArrayList)24 ResourceNotFoundException (org.niis.xroad.restapi.openapi.ResourceNotFoundException)24 X509Certificate (java.security.cert.X509Certificate)20 Collectors (java.util.stream.Collectors)19 ServiceClientAccessRightDto (org.niis.xroad.securityserver.restapi.dto.ServiceClientAccessRightDto)19 ResponseEntity (org.springframework.http.ResponseEntity)19 ClientNotFoundException (org.niis.xroad.securityserver.restapi.service.ClientNotFoundException)18 Optional (java.util.Optional)17 Set (java.util.Set)17 CodedException (ee.ria.xroad.common.CodedException)16 Slf4j (lombok.extern.slf4j.Slf4j)16 SecurityServerId (ee.ria.xroad.common.identifier.SecurityServerId)15