当前位置: 首页>>代码示例>>Java>>正文


Java EndpointType类代码示例

本文整理汇总了Java中com.helger.peppol.smp.EndpointType的典型用法代码示例。如果您正苦于以下问题:Java EndpointType类的具体用法?Java EndpointType怎么用?Java EndpointType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EndpointType类属于com.helger.peppol.smp包,在下文中一共展示了EndpointType类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: _checkIfReceiverEndpointURLMatches

import com.helger.peppol.smp.EndpointType; //导入依赖的package包/类
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);
  }
}
 
开发者ID:phax,项目名称:as2-peppol-servlet,代码行数:29,代码来源:AS2ServletSBDModule.java

示例2: _getReceiverEndpoint

import com.helger.peppol.smp.EndpointType; //导入依赖的package包/类
/**
 * @param aRecipientID
 *        PEPPOL Recipient ID
 * @param aDocTypeID
 *        PEPPOL document type ID
 * @param aProcessID
 *        PEPPOL process ID
 * @return The access point URL to be used or <code>null</code>
 * @throws OpenAS2Exception
 *         In case the endpoint address could not be resolved.
 */
@Nullable
private static EndpointType _getReceiverEndpoint (@Nullable final IParticipantIdentifier aRecipientID,
                                                  @Nullable final IDocumentTypeIdentifier aDocTypeID,
                                                  @Nullable final IProcessIdentifier aProcessID,
                                                  @Nonnull final String sMessageID) throws OpenAS2Exception
{
  // Get configured client
  final SMPClientReadOnly aSMPClient = AS2PeppolServletConfiguration.getSMPClient ();
  if (aSMPClient == null)
    throw new OpenAS2Exception (sMessageID + " No SMP client configured!");

  if (aRecipientID == null || aDocTypeID == null || aProcessID == null)
    return null;

  try
  {
    if (s_aLogger.isDebugEnabled ())
    {
      s_aLogger.debug (sMessageID +
                       " Looking up the endpoint of recipient " +
                       aRecipientID.getURIEncoded () +
                       " at SMP URL '" +
                       aSMPClient.getSMPHostURI () +
                       "' for " +
                       aRecipientID.getURIEncoded () +
                       " and " +
                       aDocTypeID.getURIEncoded () +
                       " and " +
                       aProcessID.getURIEncoded ());
    }

    // Query the SMP
    return aSMPClient.getEndpoint (aRecipientID, aDocTypeID, aProcessID, ESMPTransportProfile.TRANSPORT_PROFILE_AS2);
  }
  catch (final Throwable t)
  {
    throw new OpenAS2Exception (sMessageID +
                                " Failed to retrieve endpoint of recipient " +
                                aRecipientID.getURIEncoded (),
                                t);
  }
}
 
开发者ID:phax,项目名称:as2-peppol-servlet,代码行数:54,代码来源:AS2ServletSBDModule.java

示例3: _checkIfEndpointCertificateMatches

import com.helger.peppol.smp.EndpointType; //导入依赖的package包/类
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");
}
 
开发者ID:phax,项目名称:as2-peppol-servlet,代码行数:50,代码来源:AS2ServletSBDModule.java

示例4: handle

import com.helger.peppol.smp.EndpointType; //导入依赖的package包/类
public void handle (@Nonnull final String sAction,
                    @Nonnull final IMessage aMsg,
                    @Nullable final Map <String, Object> aOptions) throws OpenAS2Exception
{
  try
  {
    // Interpret content as SBD
    final StandardBusinessDocument aSBD = new SBDMarshaller ().read (aMsg.getData ().getInputStream ());
    if (aSBD == null)
      throw new IllegalArgumentException ("Failed to interpret the passed document as a Standard Business Document!");

    if (AS2PeppolServletConfiguration.isReceiverCheckEnabled ())
    {
      final PeppolSBDHDocument aDD = new PeppolSBDHDocumentReader ().extractData (aSBD);
      final String sMessageID = aDD.getInstanceIdentifier ();

      // Get the endpoint information required from the recipient
      final EndpointType aReceiverEndpoint = _getReceiverEndpoint (aDD.getReceiverAsIdentifier (),
                                                                   aDD.getDocumentTypeAsIdentifier (),
                                                                   aDD.getProcessAsIdentifier (),
                                                                   sMessageID);

      if (aReceiverEndpoint == null)
      {
        throw new OpenAS2Exception (sMessageID +
                                    " Failed to resolve endpoint for provided receiver/documentType/process - not handling document");
      }
      // Check if the message is for us
      _checkIfReceiverEndpointURLMatches (aReceiverEndpoint, sMessageID);

      // Get the recipient certificate from the SMP
      _checkIfEndpointCertificateMatches (aReceiverEndpoint, sMessageID);
    }
    else
    {
      s_aLogger.info ("Endpoint checks for the AS2 AP are disabled");
    }

    // Handle incoming document via SPI
    for (final IAS2IncomingSBDHandlerSPI aHandler : m_aHandlers)
      aHandler.handleIncomingSBD (aSBD);
  }
  catch (final Exception ex)
  {
    // Something went wrong
    throw WrappedOpenAS2Exception.wrap (ex);
  }
}
 
开发者ID:phax,项目名称:as2-peppol-servlet,代码行数:49,代码来源:AS2ServletSBDModule.java


注:本文中的com.helger.peppol.smp.EndpointType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。