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;
}
});
}
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;
}
});
}
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());
}
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);
}
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..
}
Aggregations