Failed trying to connect to the Policy Server. Ensure that the Agent Name and Shared Secret in smjsdkexample.properties matches that of a pre-existing agent in the Policy Store.
search cancel

Failed trying to connect to the Policy Server. Ensure that the Agent Name and Shared Secret in smjsdkexample.properties matches that of a pre-existing agent in the Policy Store.

book

Article ID: 366759

calendar_today

Updated On:

Products

SITEMINDER CA Single Sign-On

Issue/Introduction

This is an error when the SiteMinder SDK agent is trying to establish connection to Policy Server and fail.

This article is to provide basic steps on how to test the SDK agent so it can connect to Policy Server using "smjavaagentapi" included in SiteMinder SDK.

 

Audience: This is for advanced SiteMinder users and developers.

Environment

Installed SiteMinder SDK R12.8.6a version on Windows 10.

JDK 11.0.20.1+1 installed and its bin folder set in %PATH%

 

If using very old version of JDK then JCE patch must be applied.

Resolution

"<SDK Install folder>/samples/smjavaagentapi/JavaTestClient.java" has the following that you must pay attention to.

public class JavaTestClient
{
    // Logging
    private static PrintWriter logWriter    = null;
    private static final String CRLF        = System.getProperty("line.separator");
    private static final String OS_NAME     = System.getProperty("os.name");

    // Resource bundle (smjsdksample.properties)
    private static ResourceBundle bundle    = null;
    private static final String BUNDLE_NAME = "smjsdksample";

    private String clientIPAddr             = null;
    private static String USER_NAME         = null;
    private static String USER_PWD          = null;
    private static String SECTION_SEP       = "";
    public static String getStringFromBundleWithTrim(String propertyName)
    {
        return bundle.getString(propertyName).trim();
    }

"BUNDLE_NAME" is the file name (with properties extension) which this program will read the parameters from.

        Scanner reader = new Scanner (System.in);
        System.out.println("\nWelcome to the Interactive FTP Server\n");
        System.out.println("-------------------------------------\n");
        System.out.println("Do you want to connect through:\n");
        System.out.println("(1) 4.x Agent Interface\n");
        System.out.println("(2) 5.x Agent Interface(smreghost utility must be run before it)\n");
        System.out.println("-------------------------------------\n");
        System.out.println("Enter the Agent type(1/2) to connect: ");
        int input = reader.nextInt();
        
        Log(CRLF + CRLF + bundle.getString("AGENTAPI_HEADER") + CRLF);
        Log(CRLF + CRLF + bundle.getString("AGENTAPI_INIT") + CRLF);

        String agentIP = getStringFromBundleWithTrim("AGENT_IP");
        String agentName = getStringFromBundleWithTrim("OBJNAME_PREFIX") + "agent";
        String agentSecret = bundle.getString("AGENT_SECRET");
        testclient.clientIPAddr = agentIP;

        AgentAPI agentapi               = new AgentAPI();
        ServerDef serverdef             = new ServerDef();
        serverdef.serverIpAddress       = getStringFromBundleWithTrim("PS_IP");
        serverdef.connectionMin         = new Integer(bundle.getString("PS_CONMIN")).intValue();
        serverdef.connectionMax         = new Integer(bundle.getString("PS_CONMAX")).intValue();
        serverdef.connectionStep        = new Integer(bundle.getString("PS_CONSTEP")).intValue();
        serverdef.timeout               = new Integer(bundle.getString("PS_TIMEOUT")).intValue();
        serverdef.authenticationPort    = new Integer(bundle.getString("PS_AUPORT")).intValue();
        serverdef.authorizationPort     = new Integer(bundle.getString("PS_AZPORT")).intValue();
        serverdef.accountingPort        = new Integer(bundle.getString("PS_ACPORT")).intValue();
        InitDef initdef = null;

As you can see this program is fetching the highlighted parameters from the "smjsdksample.properties"

 

Open "<SDK Install folder>/properties/smjsdksample.properties" in text editor and update the following information.

AGENT_IP                 = 192.168.0.122
AGENT_SECRET             = {secret}

 

PS_IP          = 192.168.0.123
PS_CONMIN      = 1
PS_CONMAX      = 3
PS_CONSTEP     = 1
PS_TIMEOUT     = 75
PS_AUPORT      = 44442
PS_AZPORT      = 44443
PS_ACPORT      = 44441

 

OBJNAME_PREFIX        = jsdksample-

Note that the sample program did not read "AGENT_NAME" from the smjsdksample.properties" file but instead it is reading "OBJNAME_PREFIX" and appending "agent" to it.
This makes the agentname "jsdksample-agent"

 

This means you have a Policy Server running on IP 192.168.0.123 and the SDK is installed on IP 192.168.0.122
You have created a 4.x agent manually with following information:
1. Agent Name: jsdksample-agent
2. Shared Secret: {secret}
3. Agent IP: 192.168.0.122

Run the "java-build.bat" and "java-run.bat".

Enter "1" when asked for Agent Type.

C:\SDK\samples\smjavaagentapi>java -Djava.library.path=..\..\bin -classpath .;..\..\properties;..\..\java\smjavasdk2.jar;..\..\java\smjavaagentapi.jar JavaTestClient

Welcome to the Interactive FTP Server

-------------------------------------

Do you want to connect through:

(1) 4.x Agent Interface

(2) 5.x Agent Interface(smreghost utility must be run before it)

-------------------------------------

Enter the Agent type(1/2) to connect:
1


>>>>>>>>>>>>>  SiteMinder Java Agent API Sample  <<<<<<<<<<<<<


++ Initialization ++

Policy Server IP Address.................:      192.168.0.123
Agent IP Address.........................:      192.168.0.122
Agent Name...............................:      jsdksample-agent
Agent Shared Secret......................:      {secret}
______________________________________________________________


++ SetAgentInstanceInfo ++

DoManagement (SET_AGENT_INSTANCE_INFO)...:      1 (YES)
______________________________________________________________


++ DoManagement ++

DoManagement (GET_AGENT_COMMANDS)........:      1 (YES)
______________________________________________________________


++ IsProtected ++

Resource Name............................:      /resfilter/private.html
Action...................................:      GET
IsProtected..............................:      2 (Resource is NOT Protected)
______________________________________________________________


++ Cleanup ++

UnInit...................................:      0 (SUCCESS)

>>>>>>>>>>>>>>>>>>>>>>>>>>>>  End  <<<<<<<<<<<<<<<<<<<<<<<<<<<

 

Sample program is using "jsdksample-agent" and its sharedsecret to communicate with Policy Server but if the matching agentname is not found in the policy store then the error will be displayed.

C:\SDK\samples\smjavaagentapi>java -Djava.library.path=..\..\bin -classpath .;..\..\properties;..\..\java\smjavasdk2.jar;..\..\java\smjavaagentapi.jar JavaTestClient

Welcome to the Interactive FTP Server

-------------------------------------

Do you want to connect through:

(1) 4.x Agent Interface

(2) 5.x Agent Interface(smreghost utility must be run before it)

-------------------------------------

Enter the Agent type(1/2) to connect:
1


>>>>>>>>>>>>>  SiteMinder Java Agent API Sample  <<<<<<<<<<<<<


++ Initialization ++

Policy Server IP Address.................:      192.168.0.123
Agent IP Address.........................:      192.168.0.122
Agent Name...............................:      jsdksample-agent
Agent Shared Secret......................:      {secret}
FATAL: Failed trying to connect to the Policy Server. Ensure that the Agent Name and Shared Secret in smjsdkexample.properties matches that of a pre-existing agent in the Policy Store.
C:\SDK\samples\smjavaagentapi>