cancel
Showing results for 
Search instead for 
Did you mean: 

JcoServiceProvider and SSO

0 Kudos

Hi,

Obviously, the JcoServiceProvider is using my SSO identity for authentication. I want to do the same from a standalone java program using JCO.

I configured a JCO service provider for the CSS system from the widget configuration. Now I am trying to connect to the same system with JCO with all the params including SNC and using my X509 cert, but I get the message -

RFC_ERROR_LOGON_FAILURE: SNC name of the partner system not in ACL system

Where can I find all the parameters that the widget configuration is using to make a successful connection? I can probably use the same params in my standalone JCO program.

Regards,

Vinay

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello,

Does connection to CSS system works in SAP Widget Foundation?

Eriks

0 Kudos

Hi Eriks,

Yes it does. And I am trying to figure out what connection parameters the foundation is using.

Regards,

Vinay

Former Member
0 Kudos

Hello,

Inside SAP network Secude is used for SSO.

Following JCO parameters should be set:

jco.client.snc_mode=1

jco.client.snc_partnername="p:CN=CSN, O=SAP-AG, C=DE"

jco.client.snc_lib="C:/Program Files/SECUDE/SECUDE for R3/secude.dll"


package example;

import java.util.Properties;

import com.sap.mw.jco.IFunctionTemplate;
import com.sap.mw.jco.JCO;
import com.sap.mw.jco.JCO.Field;
import com.sap.mw.jco.JCO.ParameterList;
import com.sap.mw.jco.JCO.Table;

public class Example {
	
	private JCO.Client client;
	
	public void connect(Properties properties){
        client = JCO.createClient(properties);
        client.connect();
	}
	
	public void disconnect(){
        client.disconnect();
	}
	
    private void displayParameters(String parameterType, ParameterList parameters) {
        if (parameters == null) {
            System.out.println("No " + parameterType + " parameters");
        } else {
            for (JCO.FieldIterator iter = parameters.fields(); iter.hasMoreFields();) {
                Field field = iter.nextField();
                System.out.println(parameterType + " parameter: " + field.getName());
            }
        }
    }
    
    /**
     * Calls ME_GET_CURRENT_USER_ID without parameters and prints Export parameter "USERNAME"
     */
    public void call_ME_GET_CURRENT_USER_ID(){
    	JCO.Repository repository = new JCO.Repository("RepositoryName", client);
        IFunctionTemplate template = repository.getFunctionTemplate("ME_GET_CURRENT_USER_ID");

        JCO.Function function = template.getFunction();

        // Function metadata display
        ParameterList parameters;
        parameters = function.getImportParameterList();
        displayParameters("Import", parameters);

        parameters = function.getExportParameterList();
        displayParameters("Export", parameters);

        parameters = function.getTableParameterList();
        displayParameters("Table", parameters);
        
        client.execute(function);
        
        //function.writeXML("c:\\ME_GET_CURRENT_USER_ID.xml");

        String username = function.getExportParameterList().getField("USERNAME").getString();
        System.out.println("Current logged user obtained by RFC function call is: " + username);

    }


    public static void main(String[] args) {
    	try {
       	
            Properties properties = new Properties();
            properties.setProperty("jco.client.ashost", args[0]);
            properties.setProperty("jco.client.sysnr", args[1]);
            properties.setProperty("jco.client.client", args[2]);
            properties.setProperty("jco.client.lang", args[3]);
			properties.setProperty("jco.client.snc_mode", args[4]);
			
			if ("1".equals(args[4])) {
				properties.setProperty("jco.client.snc_partnername", args[5]);
				properties.setProperty("jco.client.snc_lib", args[6]);
			} else {
				properties.setProperty("jco.client.user", args[5]);
				properties.setProperty("jco.client.passwd", args[6]);
			}

            Example jcoExample = new Example();
            jcoExample.connect(properties);
            
            jcoExample.call_ME_GET_CURRENT_USER_ID();
            
            jcoExample.disconnect();
            
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

0 Kudos

Hi Eriks,

Thanks for the sample code.

I have been using similar code, but additionally I am sending my certificate too, and for some reason it doesn't work. Now I removed the user and password params as in your code and it works surprisingly!

One more question - I am able to execute the ME_GET_CURRENT_USER_ID function. But some other functions give an error which says "NO_AUTHORITY". Is it because I do not have the rights to execute the function or some other JCO params which I have to set?

Regards,

Vinay

Former Member
0 Kudos

Hello,

I think your user is missing authorizations to execute particular function

Eriks

Answers (0)