use of ee.ria.xroad.common.CodedException in project X-Road by nordic-institute.
the class ProxyMessageDecoder method handleSoap.
private void handleSoap(BodyDescriptor bd, InputStream is, String partContentType, Map<String, String> soapPartHeaders) {
try {
LOG.trace("Looking for SOAP, got: {}, {}", bd.getMimeType(), bd.getCharset());
switch(bd.getMimeType().toLowerCase()) {
case TEXT_XML:
case XOP_XML:
break;
default:
throw new CodedException(X_INVALID_CONTENT_TYPE, "Invalid content type for SOAP message: %s", bd.getMimeType());
}
Soap soap = new SaxSoapParserImpl().parse(partContentType, is);
if (soap instanceof SoapFault) {
callback.fault((SoapFault) soap);
} else {
callback.soap((SoapMessageImpl) soap, soapPartHeaders);
verifier.addMessagePart(getHashAlgoId(), (SoapMessageImpl) soap);
}
} catch (Exception ex) {
throw translateException(ex);
}
}
use of ee.ria.xroad.common.CodedException in project X-Road by nordic-institute.
the class ProxyMessageDecoder method parse.
/**
* Attempts to decode the proxy SOAP message from the given input stream.
*
* @param is input stream from which to decode the message
* @throws Exception if the stream content type does not match the expected one
*/
public void parse(InputStream is) throws Exception {
LOG.trace("parse()");
String baseContentType = HttpFields.valueParameters(contentType, null);
if (faultAllowed && baseContentType.equalsIgnoreCase(TEXT_XML)) {
parseFault(is);
} else if (baseContentType.equalsIgnoreCase(MULTIPART_MIXED)) {
parseMultipart(is);
} else {
throw new CodedException(X_INVALID_CONTENT_TYPE, "Invalid content type: %s", baseContentType);
}
}
use of ee.ria.xroad.common.CodedException in project X-Road by nordic-institute.
the class CustomSSLSocketFactory method connectSocket.
@Override
public Socket connectSocket(int timeout, Socket socket, HttpHost host, InetSocketAddress remoteAddress, InetSocketAddress localAddress, HttpContext context) throws IOException {
Socket connected = super.connectSocket(timeout, socket, host, remoteAddress, localAddress, context);
try {
if (!(connected instanceof SSLSocket)) {
throw new Exception("Failed to create SSL socket");
}
X509Certificate cert = getPeerCertificate((SSLSocket) connected);
log.trace("Peer certificate: {}", cert);
checkServerTrusted(getServiceId(context), cert);
} catch (Exception e) {
IOUtils.closeQuietly(connected);
throw new CodedException(X_SSL_AUTH_FAILED, e);
}
return connected;
}
use of ee.ria.xroad.common.CodedException in project X-Road by nordic-institute.
the class ServerMessageProcessor method verifyClientStatus.
private void verifyClientStatus() {
ClientId client = requestServiceId.getClientId();
String status = ServerConf.getMemberStatus(client);
if (!ClientType.STATUS_REGISTERED.equals(status)) {
throw new CodedException(X_UNKNOWN_MEMBER, "Client '%s' not found", client);
}
}
use of ee.ria.xroad.common.CodedException in project X-Road by nordic-institute.
the class ServerMessageProcessor method handleException.
private void handleException(Exception ex) throws Exception {
if (encoder != null) {
CodedException exception;
if (ex instanceof CodedException.Fault) {
exception = (CodedException.Fault) ex;
} else {
exception = translateWithPrefix(SERVER_SERVERPROXY_X, ex);
}
monitorAgentNotifyFailure(exception);
opMonitoringData.setFaultCodeAndString(exception);
opMonitoringData.setResponseOutTs(getEpochMillisecond(), false);
encoder.fault(SoapFault.createFaultXml(exception));
encoder.close();
} else {
throw ex;
}
}
Aggregations