@Nonnull public IJSExpression getAsJS() { final JSAssocArray ret = new JSAssocArray(); ret.add("key", m_cKey); if (m_eShiftKey.isDefined()) ret.add("shiftKey", m_eShiftKey.getAsBooleanValue(false)); if (m_eAltKey.isDefined()) ret.add("altKey", m_eAltKey.getAsBooleanValue(false)); if (m_eShiftKey.isDefined()) ret.add("ctrlKey", m_eCtrlKey.getAsBooleanValue(false)); if (m_eMetaKey.isDefined()) ret.add("metaKey", m_eMetaKey.getAsBooleanValue(false)); if (ret.size() == 1) { // Only the key present return JSExpr.lit(m_cKey); } return ret; }
protected void verify(@Nonnull final IMessage aMsg) throws OpenAS2Exception { final ICertificateFactory aCertFactory = m_aReceiverModule.getSession().getCertificateFactory(); final ICryptoHelper aCryptoHelper = AS2Helper.getCryptoHelper(); try { final boolean bDisableVerify = aMsg.getPartnership().isDisableVerify(); final boolean bMsgIsSigned = aCryptoHelper.isSigned(aMsg.getData()); final boolean bForceVerify = aMsg.getPartnership().isForceVerify(); if (bMsgIsSigned && bDisableVerify) { s_aLogger.info( "Message claims to be signed but signature validation is disabled" + aMsg.getLoggingText()); } else if (bMsgIsSigned || bForceVerify) { if (bForceVerify && !bMsgIsSigned) s_aLogger.info("Forced verify signature" + aMsg.getLoggingText()); else if (s_aLogger.isDebugEnabled()) s_aLogger.debug("Verifying signature" + aMsg.getLoggingText()); final X509Certificate aSenderCert = aCertFactory.getCertificateOrNull(aMsg, ECertificatePartnershipType.SENDER); boolean bUseCertificateInBodyPart; final ETriState eUseCertificateInBodyPart = aMsg.getPartnership().getVerifyUseCertificateInBodyPart(); if (eUseCertificateInBodyPart.isDefined()) { // Use per partnership bUseCertificateInBodyPart = eUseCertificateInBodyPart.getAsBooleanValue(); } else { // Use global value bUseCertificateInBodyPart = m_aReceiverModule.getSession().isCryptoVerifyUseCertificateInBodyPart(); } final MimeBodyPart aVerifiedData = aCryptoHelper.verify( aMsg.getData(), aSenderCert, bUseCertificateInBodyPart, bForceVerify); aMsg.setData(aVerifiedData); // Remember that message was signed and verified aMsg.setAttribute(AS2Message.ATTRIBUTE_RECEIVED_SIGNED, Boolean.TRUE.toString()); s_aLogger.info( "Successfully verified signature of incoming AS2 message" + aMsg.getLoggingText()); } } catch (final Exception ex) { s_aLogger.error( "Error verifying signature " + aMsg.getLoggingText() + ": " + ex.getMessage()); throw new DispositionException( DispositionType.createError("integrity-check-failed"), AbstractActiveNetModule.DISP_VERIFY_SIGNATURE_FAILED, ex); } }