Show TOC

Using P4 Protocol Over a Secure ConnectionLocate this document in the navigation structure

Use

You can set up a secure P4 communication using SSL or HTTPS protocols as underlying transport layers.

Prerequisites
  • You have configured your AS Java to use SSL. More information: Configuring the Use of SSL on the AS Java .

  • You have configured the port for secure connections on the ICM for AS Java. Then, the client uses that port to open the secure connection in its request to AS Java.

Procedure

In your client code, obtain the InitialContext to connect to the remote object using the following properties:

  1. Specify the port for the secure connection with the provider URL property java.naming.provider.url , add the requested protocol schema to the URL (P4S:// or P4HTTPS://).

  2. Specify the underlying transport layer you want to use. Use the TransportLayerQueue property with value ssl for P4 over an SSL connection, or value httptunneling_ssl for P4 over an HTTPS connection.

Example

The following example shows client code that obtains InitialContext using a specific transport layer. This transport layer ( SSL or HTTPS ) is specified by the transportType parameter provided in the command line when the following client code is executed:

            public class ExampleTransportTypesSwitching {

  private static InitialContext ctx = null;
  
  public static void main(String[] args) {
                        init ("P4S://", "localhost", "50006", "User", "Password", "ssl");
  }
  
                public static void init(String schema, String host, String port, String user, String pass, String transportType) {
                        try {
                                Properties p = new Properties();
                                if (schema == null) {
                                        schema = "P4://";
                                }
                                p.put("java.naming.factory.initial", "com.sap.engine.services.jndi.InitialContextFactoryImpl");
                                p.put("java.naming.provider.url", schema + host + ":" + port);
                                p.put("java.naming.security.principal", user);
                                p.put("java.naming.security.credentials", pass);
                                // Parameter transportType for Transport Layer Queue has value 
                                // "None", "ssl", "httptunneling_ssl" or "httptunneling".
       p.put("TransportLayerQueue", transportType);
                                ctx = new InitialContext(p);
                                System.out.println("NamingClient context: " + ctx);
                        } catch(NamingException e) {
                                e.printStackTrace();
                                }
                }

}