I have two domains: sharepoint.server.com AND app.server.com
In the application from domain app.server.com I do invisible ntlm authentication on the server sharepoint.server.com.
sharepoint.server.com returns me its cookies. How is it possible to write these cookies to the browser's memory?
It's possible to write these cookies, but just with domain app.server.com, but I need to write it with domain sharepoint.server.com.
So, if it's written to the browser's memory, sharepoint.server.com will never show authentication user window again based on the existing cookies. However, it cannot read these cookies, because it's different domain.
DefaultHttpClient httpClient = new DefaultHttpClient(cm,params);
httpClient.getAuthSchemes().register("ntlm", new NTLMSchemeFactory());
httpClient.getCredentialsProvider().setCredentials(new AuthScope(AuthScope.ANY),
new NTCredentials("login", "pass", null, "server.net"));
HttpGet httpget = new HttpGet("htts://sharepoint.server.com/");
HttpResponse response;
try {
response = httpClient.execute(httpget);
StatusLine entity = response.getStatusLine();
System.out.println("executing request " + httpget.getRequestLine());
System.out.println(entity.toString());
System.out.println("");
Header[] headers = response.getAllHeaders();
for (Header header : headers) {
System.out.println(header.getName() + " : " + header.getValue());
}
List<Cookie> cookies = httpClient.getCookieStore.getCookies();
for(Cookie cookie:cookies)
{
JavaApp.getInstance().getMainWindow().executeJavaScript(
"document.cookie='" + cookie.getName()+"="+cookie.getValue() +"; domain="+cookie.getDomain()+"; path="+cookie.getPath()+"'");
}
Now it doesnt write cookies at all, because cookie.getDomain()=sharepoint.server.com, and it cannot be written.
If I remove domain=cookie.getDomain() from the line, it writes cookies to the momory, but uses domain domain "app.server.com"
But I need to write these cookies with domain sharepoint.server.com
How is it possible to make it?