use of com.helger.as2lib.exception.OpenAS2Exception in project as2-server by phax.
the class XMLCommandRegistry method loadMultiCommand.
protected void loadMultiCommand(@Nonnull final IMicroElement aCommand, @Nullable final MultiCommand parent) throws OpenAS2Exception {
final MultiCommand cmd = new MultiCommand();
cmd.initDynamicComponent(getSession(), AS2XMLHelper.getAllAttrsWithLowercaseName(aCommand));
if (parent != null)
parent.getCommands().add(cmd);
else
addCommand(cmd);
for (final IMicroElement aChildElement : aCommand.getAllChildElements()) {
final String sChildName = aChildElement.getNodeName();
if (sChildName.equals("command"))
loadCommand(aChildElement, cmd);
else if (sChildName.equals("multicommand"))
loadMultiCommand(aChildElement, cmd);
else
throw new OpenAS2Exception("Undefined child tag: " + sChildName);
}
}
use of com.helger.as2lib.exception.OpenAS2Exception in project as2-server by phax.
the class XMLCommandRegistry method load.
public void load(@Nonnull final InputStream in) throws OpenAS2Exception {
final IMicroDocument aDoc = MicroReader.readMicroXML(in);
final IMicroElement eRoot = aDoc.getDocumentElement();
clearCommands();
for (final IMicroElement eElement : eRoot.getAllChildElements()) {
final String sNodeName = eElement.getTagName();
if (sNodeName.equals("command"))
loadCommand(eElement, null);
else if (sNodeName.equals("multicommand"))
loadMultiCommand(eElement, null);
else
throw new OpenAS2Exception("Undefined tag: " + sNodeName);
}
}
use of com.helger.as2lib.exception.OpenAS2Exception in project as2-peppol-servlet by phax.
the class AS2ServletSBDModule method _checkIfEndpointCertificateMatches.
private static void _checkIfEndpointCertificateMatches(@Nonnull final EndpointType aRecipientEndpoint, @Nonnull final String sMessageID) throws OpenAS2Exception {
final X509Certificate aOurCert = AS2PeppolServletConfiguration.getAPCertificate();
if (aOurCert == null)
throw new OpenAS2Exception("The certificate of this AP is not configured!");
final String sRecipientCertString = aRecipientEndpoint.getCertificate();
X509Certificate aRecipientCert = null;
try {
aRecipientCert = CertificateHelper.convertStringToCertficate(sRecipientCertString);
} catch (final CertificateException t) {
throw new OpenAS2Exception(sMessageID + " Internal error: Failed to convert looked up endpoint certificate string '" + sRecipientCertString + "' to an X.509 certificate!", t);
}
if (aRecipientCert == null) {
// No certificate found - most likely because of invalid SMP entry
throw new OpenAS2Exception(sMessageID + " No certificate found in looked up endpoint! Is this AP maybe NOT contained in an SMP?");
}
// Certificate found
if (s_aLogger.isDebugEnabled())
s_aLogger.debug(sMessageID + " Conformant recipient certificate present: " + aRecipientCert.toString());
// Compare serial numbers
if (!aOurCert.getSerialNumber().equals(aRecipientCert.getSerialNumber())) {
final String sErrorMsg = sMessageID + " Certificate retrieved from SMP lookup (" + aRecipientCert + ") does not match this APs configured Certificate (" + aOurCert + ") - different serial numbers - ignoring document";
s_aLogger.error(sErrorMsg);
throw new OpenAS2Exception(sErrorMsg);
}
if (s_aLogger.isDebugEnabled())
s_aLogger.debug(sMessageID + " The certificate of the SMP lookup matches our certificate");
}
use of com.helger.as2lib.exception.OpenAS2Exception in project as2-peppol-servlet by phax.
the class AS2ServletSBDModule method _checkIfReceiverEndpointURLMatches.
private static void _checkIfReceiverEndpointURLMatches(@Nonnull final EndpointType aRecipientEndpoint, @Nonnull final String sMessageID) throws OpenAS2Exception {
// Get our public endpoint address from the configuration
final String sOwnAPUrl = AS2PeppolServletConfiguration.getAS2EndpointURL();
if (StringHelper.hasNoText(sOwnAPUrl))
throw new OpenAS2Exception("The endpoint URL of this AP is not configured!");
if (s_aLogger.isDebugEnabled())
s_aLogger.debug(sMessageID + " Our AP URL is " + sOwnAPUrl);
final String sRecipientAPUrl = SMPClientReadOnly.getEndpointAddress(aRecipientEndpoint);
if (s_aLogger.isDebugEnabled())
s_aLogger.debug(sMessageID + " Recipient AP URL is " + sRecipientAPUrl);
// Is it for us?
if (sRecipientAPUrl == null || !sRecipientAPUrl.contains(sOwnAPUrl)) {
final String sErrorMsg = sMessageID + " Internal error: The request is targeted for '" + sRecipientAPUrl + "' and is not for us (" + sOwnAPUrl + ")";
s_aLogger.error(sErrorMsg);
throw new OpenAS2Exception(sErrorMsg);
}
}
Aggregations