Skip to Content
0

BO CMS - Create HANA authentication

Nov 01, 2017 at 10:07 PM

37

avatar image
Former Member

Generally when try to create HANA authentication connection we login to

CMC --> Applications --> HANA Authentication --> Create Connection and complete the following form in BO CMC:

1.Hana Host

2.Hana Port:

3.Unique Identity Provider ID:

4.Service Provider Name:

5.Identity Provider Base64 Certificate:

6.Generate Button

This will create certificate that is import to Hana. The question is... Is there any way doing this using BO JAVA SDK API? I have done lots of work using JAVA SDK and would like to know if there any way I can leverage SDK to generate certificate so I can automate the process after daily data refresh.

Any info in regards to this topic will be gratefully appreciate it and will safe me lots of time.

Thanks in Adv.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
avatar image
Former Member Nov 03, 2017 at 01:11 AM
0

Got it... Batch file calls below code and call it the day. Thanks!


import com.crystaldecisions.sdk.occa.security.ILogonTokenMgr;
import com.crystaldecisions.sdk.exception.SDKException;
import com.crystaldecisions.sdk.framework.*;
import com.crystaldecisions.sdk.occa.infostore.*;
import com.crystaldecisions.sdk.plugin.desktop.samlserviceprovider.ISAMLServiceProvider;
import java.util.Properties;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;


public class createSamlHanaCert{
	public static void main (String[] args) throws SDKException, IOException {


		String strUserName = args[0];
	    String strPassword = args[1];
	    String strCms = args[2];
	    String strAuthType = args[3];	    
	    String strHost = args[4];
	    String strHanaPort = args[5];
	    String strPID = args[6];
	    String strSpID = args[7];
	    String strSavePath = args[8];	
		
	    System.out.println("Login CMS "+strCms);  	    
	    String strToken = "";
	    new Properties();
	    IEnterpriseSession boEnterpriseSession = null;
	    
	    try{	
			IInfoStore boInfoStore;
			IInfoObjects boInfoObjects;
			IInfoObject boObject;
			boEnterpriseSession = CrystalEnterprise.getSessionMgr().logon(strUserName, strPassword, strCms, strAuthType);
		    ILogonTokenMgr tokenMgr = boEnterpriseSession.getLogonTokenMgr();
	    	strToken = tokenMgr.getDefaultToken();			    	    
		    System.out.println("Login Completed - Token = "+strToken);
		    boInfoStore = (IInfoStore) boEnterpriseSession.getService("", "InfoStore");


		    boInfoObjects = boInfoStore.query("Select * from CI_SYSTEMOBJECTS where SI_PROGID='CrystalEnterprise.SAMLServiceProvider'");


		    if ( boInfoObjects.size() == 0 ) {
		        System.out.println("No HANA connection found") ;
		    } 
		    
		    OutputStream outputStream = new FileOutputStream (strSavePath);
		    Writer outputStreamWriter = new OutputStreamWriter (outputStream);
		    
		    // loop through the HANA connections     
		    for( int i=0; i < boInfoObjects.size(); i++ ) {
		         boObject = (IInfoObject) boInfoObjects.get(i) ;
				 boObject.getParentID();
				 ISAMLServiceProvider sp = (ISAMLServiceProvider) boObject;
				 
				 //Set Host/Port/SAML/SpID
				 sp.setSpHost(strHost);
				 sp.setSpPort(Integer.parseInt(strHanaPort));
				 sp.setIdPID(strPID);					 
				 sp.setSpID(strSpID);
				 
				 //Get Info
		         String connectionName = sp.getTitle();
		         String connectionCUID = sp.properties().get("SI_CUID").toString() ;
		         String	spHost = sp.getSpHost();
				 int spPort = sp.getSpPort();
				 String spIdPID = sp.getIdPID();
				 sp.getSiteUrl();
				 String	spSpID = sp.getSpID();
				 sp.getSpAcsUrl();
				 sp.getSpSloUrl();
				 String	spIdPBase64Certificate = sp.getIdPBase64Certificate() ;
		      
				 System.out.println( "------" );				 
				 System.out.println( "Old Certificate - " + spIdPBase64Certificate);
				 System.out.println( "------" );	
				 			 
				 String	spGenerateIdPBase64Certificate = sp.generateIdPBase64Certificate();
				 System.out.println( "New Certificate - " + spGenerateIdPBase64Certificate);
				 boInfoStore.commit(boInfoObjects);
				 
				 outputStreamWriter.write(spGenerateIdPBase64Certificate);
				 outputStreamWriter.close();
				 
				 System.out.println( "------" );
				 System.out.println( "connectionName - " + connectionName);
				 System.out.println( "connectionCUID - " + connectionCUID);
				 System.out.println( "spHost - " + spHost);
				 System.out.println( "spPort - " + spPort);
				 System.out.println( "spIdPID - " + spIdPID);
				 System.out.println( "spSpID - " + spSpID);
				 System.out.println( "------" );
		      }
		        
		}  catch(Exception e){
	    	System.out.println(new java.util.Date()+": error occured: "+e);
	    } 
	    finally { 	    	
	    	System.out.println("\n Releaseing BO Session!");  	    
	    	boEnterpriseSession.logoff();	    	
	    }	
	}
}
Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Nov 02, 2017 at 08:13 PM
0

Thanks Denis as always you are great help,

We are using BI 4.2 SP3. I believe I found a solution... now I have to code this to make sure it is working.

Here is the APIs: https://help.sap.com/doc/javadocs_bip_41/4.1/en-US/bip/en/index.html?com/crystaldecisions/sdk/plugin/desktop/samlserviceprovider/ISAMLServiceProviderBase.html

Thanks,

Waleed

Share
10 |10000 characters needed characters left characters exceeded