Page 1 of 1

Getting error:401 while logging via REST CAM SSO

Posted: Wed Apr 10, 2019 9:07 am
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