Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 

Introduction


SAP Cloud Integration platform provides capability to add custom adapters to the Integration tooling via SAP ADK Framework. Please refer the blog if you are not sure how to do that. This blog assumes you are already familiar with the adapter development and already developed a custom adapter.

In this blog we are going to look at how we can enable certificate based authentication in a servlet based adapter. In fact the adapter we are going to build will support both basic and certificate based authentication.

 

Steps



  1. First we need a servlet based adapter to start with. You can refer the blog for building a custom adapter.

  2. Since what we need is a servlet based adapter, you need to implement a class which extends CamelHttpTransportServlet. You can refer to the official camel page for more information on camel servlet. Once the adapter is built you should be able to deploy it and test it by calling the servlet by an http client.

  3. Now to implement the authentication methods following steps must be followed.

    1. The authentication is provided in the form of an authentication filter which needs to be specified in the web.xml. Open the web.xml of the adapter project you created and specify the below filter definition.
      <filter>
      <filter-name>ADKAuthenticationFilter</filter-name>
      <filter-class>com.sap.it.api.asdk.cloud.authentication.ADKAuthenticationFilter</filter-class>
      </filter>
      <filter-mapping>
      <filter-name>ADKAuthenticationFilter</filter-name>
      <url-pattern>/*</url-pattern>
      </filter-mapping>​

      Here, the ADKAuthenticationFilter is the filter class. You can specify any url-pattern according to the requirement.

    2. The package com.sap.it.api.asdk.cloud.authentication needs to be imported explicitly. So, open the pom file and locate the maven-bundle-plugin. Here, under configuration mention the Import-Package instruction. Below is a sample plugin definition with the required Import-Package
      <plugin>
      <groupId>org.apache.felix</groupId>
      <artifactId>maven-bundle-plugin</artifactId>
      <extensions>true</extensions>
      <configuration>
      <excludeDependencies>true</excludeDependencies>
      <instructions>
      <Import-Package>com.sap.it.api.asdk.cloud.authentication,*</Import-Package>
      </instructions>
      </configuration>
      </plugin>

      Do not forget the '*' at the end of the Import-Package.



  4. That's it! Now you can deploy the adapter and test it. It will support both basic and certificate based authentication. You will be able to call the servlet only by either one of the authentication methods.