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(); } } }
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
Add comment