Unable to make HTTP Post call using Kerberos (SONEGO) authentication on AEM
Hi,
I need to make a simple HTTP Post call by passing kerberos ticket (SPNEGO) authenticated to get the results from another system on AEM 6.5.21.
This is the snippet that I am using:
DefaultHttpClient httpclient = new DefaultHttpClient();
System.setProperty("java.security.krb5.conf", "C:/Windows/krb5.ini");
System.setProperty("sun.security.krb5.debug", "true");
System.setProperty("javax.security.auth.useSubjectCredsOnly","false");
NegotiateSchemeFactory nsf = new NegotiateSchemeFactory();
httpclient.getAuthSchemes().register(AuthPolicy.SPNEGO, nsf);
List<String> authpref = new ArrayList<>();
authpref.add(AuthPolicy.SPNEGO);
httpclient.getParams().setParameter(AuthPNames.PROXY_AUTH_PREF, authpref);
HttpPost request = new HttpPost("url");
HttpEntity entity = new StringEntity(jsonPayload, "UTF-8");
HttpResponse response = httpclient.execute(request);I know that DefaultHttpClient is deprecated. (Planning to changing that once I get the success response)
I am not able to get the kerberos ticket, even after passing the krb5.ini file location. I have manually created the krb5.ini file with kbc and other required details in the specified location, but I get 401 unauthorized on trying to make the call.
Has anyone faced similar error. Anyone input will be helpful. Thank you.