使用自定义身份验证提供程序登录IBM Cognos SDK

时间:2015-12-23 16:00:26

标签: java cognos cognos-10 cognos-bi

我正在尝试使用SDK登录cognos,但不断收到以下错误:

AxisFault
 faultCode: Client
 faultSubcode: 
 faultString: CM-REQ-4342 An error occurred with the client.
 faultActor: 
 faultNode: 
 faultDetail: 
    {http://developer.cognos.com/schemas/bibus/3/}exception:
                    <severity>error</severity>
                    <errorCode>cmAuthenticateFailed</errorCode>
                    <ns1:message>
                        <messageString>CM-CAM-4005 Unable to authenticate. Check your security directory server connection and confirm the credentials entered at login.</messageString>
                    <detail>
                    <exception xmlns:cm="http://developer.cognos.com/schemas/bibus/3/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="bus:CAMException">
                        <severity xsi:type="bus:severityEnum">error</severity>
                        <errorCode>-36</errorCode>
                        <errorCodeString xml:space="preserve" xsi:type="xsd:string">camAuthUserRecoverable</errorCodeString>
                        <messages soapenc:arrayType="bus:message[2]" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="SOAP-ENC:Array">
                            <item xsi:type="bus:message">
                                <messageString xml:space="preserve" xsi:type="xsd:string"/>
                            </item>
                            <item xsi:type="bus:message">
                                <nestingLevel xsi:type="xsd:integer">1</nestingLevel>
                                <messageString xml:space="preserve" xsi:type="xsd:string"> Enter your authentication credentials.</messageString>
                            </item>
                        </messages>
                        <promptInfo xsi:type="bus:promptInfo">
                            <captions soapenc:arrayType="xsd:string[2]" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="SOAP-ENC:Array">
                                <item xml:space="preserve" xsi:type="xsd:string"/>
                                <item xml:space="preserve" xsi:type="xsd:string"> Enter your authentication credentials.</item>
                            </captions>
                            <displayObjects soapenc:arrayType="bus:displayObject[6]" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="SOAP-ENC:Array">
                                <item xsi:type="bus:displayObject">
                                    <type xml:space="preserve" xsi:type="xsd:string">text</type>
                                    <name xml:space="preserve" xsi:type="xsd:string">FormUsername</name>
                                    <caption xml:space="preserve" xsi:type="xsd:string">User ID</caption>
                                </item>
                                <item xsi:type="bus:displayObject">
                                    <type xml:space="preserve" xsi:type="xsd:string">textnoecho</type>
                                    <name xml:space="preserve" xsi:type="xsd:string">FormUserPassword</name>
                                    <caption xml:space="preserve" xsi:type="xsd:string">Password</caption>
                                </item>
                                <item xsi:type="bus:displayObject">
                                    <type xml:space="preserve" xsi:type="xsd:string">singleselect</type>
                                    <name xml:space="preserve" xsi:type="xsd:string">CAMSiteName</name>
                                    <caption xml:space="preserve" xsi:type="xsd:string">Site</caption>
                                    <promptOptions soapenc:arrayType="bus:promptOption[1]" xsi:type="SOAP-ENC:Array">
                                        <item xsi:type="bus:promptOption">
                                            <id xml:space="preserve" xsi:type="xsd:string">1</id>
                                            <value xml:space="preserve" xsi:type="xsd:string">Mexico</value>
                                            <default xml:space="preserve" xsi:type="xsd:boolean">false</default>
                                        </item>
                                    </promptOptions>
                                </item>
                                <item xsi:type="bus:displayObject">
                                    <type xml:space="preserve" xsi:type="xsd:string">singleselect</type>
                                    <name xml:space="preserve" xsi:type="xsd:string">CAMAuthType</name>
                                    <caption xml:space="preserve" xsi:type="xsd:string">Authentication Type</caption>
                                    <promptOptions soapenc:arrayType="bus:promptOption[5]" xsi:type="SOAP-ENC:Array">
                                        <item xsi:type="bus:promptOption">
                                            <id xml:space="preserve" xsi:type="xsd:string">3</id>
                                            <value xml:space="preserve" xsi:type="xsd:string">AD/Kerberos </value>
                                            <default xml:space="preserve" xsi:type="xsd:boolean">false</default>
                                        </item>
                                        <item xsi:type="bus:promptOption">
                                            <id xml:space="preserve" xsi:type="xsd:string">1</id>
                                            <value xml:space="preserve" xsi:type="xsd:string">SRP</value>
                                            <default xml:space="preserve" xsi:type="xsd:boolean">true</default>
                                        </item>
                                        <item xsi:type="bus:promptOption">
                                            <id xml:space="preserve" xsi:type="xsd:string">6</id>
                                            <value xml:space="preserve" xsi:type="xsd:string">PKI</value>
                                            <default xml:space="preserve" xsi:type="xsd:boolean">false</default>
                                        </item>
                                        <item xsi:type="bus:promptOption">
                                            <id xml:space="preserve" xsi:type="xsd:string">5</id>
                                            <value xml:space="preserve" xsi:type="xsd:string">RSA SecurID</value>
                                            <default xml:space="preserve" xsi:type="xsd:boolean">false</default>
                                        </item>
                                        <item xsi:type="bus:promptOption">
                                            <id xml:space="preserve" xsi:type="xsd:string">4</id>
                                            <value xml:space="preserve" xsi:type="xsd:string">LDAP</value>
                                            <default xml:space="preserve" xsi:type="xsd:boolean">false</default>
                                        </item>
                                    </promptOptions>
                                </item>
                                <item xsi:type="bus:displayObject">
                                    <type xml:space="preserve" xsi:type="xsd:string">hidden</type>
                                    <name xml:space="preserve" xsi:type="xsd:string">h_CAM_action</name>
                                    <value xml:space="preserve" xsi:type="xsd:string">logonAs</value>
                                </item>
                                <item xsi:type="bus:displayObject">
                                    <type xml:space="preserve" xsi:type="xsd:string">hidden</type>
                                    <name xml:space="preserve" xsi:type="xsd:string">CAMNamespace</name>
                                    <value xml:space="preserve" xsi:type="xsd:string">BLNSProvider</value>
                                </item>
                            </displayObjects>
                        </promptInfo>
                    </exception>
                    </detail>
                    </ns1:message>

我知道我的用户名和密码准确无误。

这是代码,它是从here中删除的。

public class CognosTest {
    private static String dispatcherURL = "http://domain:port/p2pd/servlet/dispatch";
    private static String nameSpaceID = "BLNSProvider";
    private static String userName = "username";
    private static String password = "password";

    public static void main(String[] args) {
        ContentManagerService_PortType cmService = null;
        ContentManagerService_ServiceLocator cmServiceLocator = new ContentManagerService_ServiceLocator();
        StringBuffer credentialXML = new StringBuffer();
        String encodedCredentials;
        XmlEncodedXML xmlCredentials = new XmlEncodedXML();

        // Step 1. Connect to Cognos services
        try {
            URL url = new URL(dispatcherURL);
            cmService = cmServiceLocator.getcontentManagerService(url);
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (ServiceException e) {
            e.printStackTrace();
        }

        // Step 2. Logon to Cognos.
        credentialXML.append("<credential>");
        credentialXML.append("<namespace>").append(nameSpaceID).append("</namespace>");
        credentialXML.append("<username>").append(userName).append("</username>");
        credentialXML.append("<password>").append(password).append("</password>");
        credentialXML.append("</credential>");

        encodedCredentials = credentialXML.toString();
        xmlCredentials.set_value(encodedCredentials);

        try {
            cmService.logon(xmlCredentials, null);
            SOAPHeaderElement temp = ((Stub)cmService).getResponseHeader("http://developer.cognos.com/schemas/bibus/3/", "biBusHeader");
            BiBusHeader CMbibus = (BiBusHeader)temp.getValueAsType(new QName ("http://developer.cognos.com/schemas/bibus/3/", "biBusHeader"));
            ((Stub)cmService).setHeader("http://developer.cognos.com/schemas/bibus/3/", "biBusHeader", CMbibus);
        } catch (RemoteException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }

        // Step 3. Log out from Cognos.
        try {
            cmService.logoff();
        } catch (RemoteException e) {
            e.printStackTrace();
        }
    }

}

我的代码与该文档中的代码之间的区别在于命名空间ID。我正在尝试连接的cognos使用具有Java类名称的自定义Java身份验证提供程序

com.bmc.bbds.auth.cognos.providers.BDSAuthenticationProvider

感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

自定义Java身份验证提供程序(CJAP)的类名对于SDK身份验证而言并不重要。命名空间ID是相关因素,可以在命名空间节点上的Cognos Configuration中找到标题为&#34; Namespace ID。&#34;因此,BLNSProvider可能是适当的值。

根据您所包含的Cognos的响应,您的CJAP看起来需要的字段多于标准用户名和密码。您需要在作为身份验证发送的credentialXml对象中包含这些值的条目,以便使用该CJAP成功向Cognos进行身份验证。