Getting error:401 while logging via REST CAM SSO

Post Reply
krishnadixit
Posts: 31
Joined: Fri Oct 14, 2011 6:44 am
OLAP Product: TM1, COGNOS
Version: TM1 9_5 Cognos Planning 8_4
Excel Version: 2007
Location: Mumbai, India

Getting error:401 while logging via REST CAM SSO

Post by krishnadixit »

Hello,
I've a java code to log into TM1 server that is using CAM security with (SSO) Single Sign-on. I am getting error: unauthorized 401. Following is my code:

Code: Select all

// to bypass SSL
javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier(
		    new javax.net.ssl.HostnameVerifier(){
       
  @Override
  public boolean verify(String hostname,javax.net.ssl.SSLSession sslSession) {
    if (hostname.equals("Adminhost")) {
      return true;
    }
    return false;
  } 
});

URL u = new URL(urlString);
//Open connection
HttpURLConnection c = (HttpURLConnection) u.openConnection();

authString = "CognosAD/John Meyer:Password:CognosAD" ; //"username:pwd:CAMNamespace"
encoded = Base64.encodeBase64String(authString.getBytes());
c.setRequestProperty("Authorization", "CAMPassport <ClientCAMURI>, CAMNamespace " + encoded);
c.setRequestProperty("WWW-Authenticate", "CAMPassport <ClientCAMURI>, CAMNamespace ");
c.setRequestProperty("Accept","application/json; charset=utf-8");
c.setRequestProperty("Content-Type","application/json;charset=utf-8");
c.setRequestMethod("GET");
c.connect();

int status = c.getResponseCode();
System.out.println("Status :"+status);
System.out.println( "Response  "+ c.getResponseMessage());
==========================================================

OUTPUT:
=========
Status:401
Response Unauthorized

What am I missing here? They way of authorization, I guess?
CAM SSO is working perfectly fine on Architect & TM1web

Please help

Thanks
Krishna
Post Reply