Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Github issue 1544 #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Work in progress on CookieStore cache
  • Loading branch information
benjamij committed Jun 19, 2014
commit fbf1ab281317ac539615be511611b9fd04ed0325
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,7 @@ protected Response execRequest(HttpRequestBase httpRequestBase, Args args, Objec
return _xhr(httpRequestBase, args, content);
}
}

/**
* Allows clients to override the process content section of {@link #_xhr(HttpRequestBase, Args)}. <br/>
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* � Copyright IBM Corp. 2012
* � Copyright IBM Corp. 2012
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,14 +15,20 @@
*/
package com.ibm.sbt.services.endpoints;

import java.lang.ref.SoftReference;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.LogRecord;

import org.apache.http.client.CookieStore;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.impl.client.DefaultHttpClient;

import com.ibm.commons.runtime.Context;
import com.ibm.sbt.security.authentication.AuthenticationException;
import com.ibm.sbt.services.client.ClientService;
import com.ibm.sbt.services.client.CookieStoreCache;
import com.ibm.sbt.services.client.Response;
import com.ibm.sbt.services.client.ClientService.Args;
import com.ibm.sbt.services.client.ClientService.Handler;
Expand Down Expand Up @@ -103,6 +109,20 @@ public interface Endpoint {
*/
public boolean isUseProxy();

/**
* TODO
* @param key
* @param value
*/
public void setCookieStore(String key, CookieStore value);

/**
* TODO
* @param key
* @return
*/
public CookieStore getCookieStore(String key);

/**
* Gets the error code for authentication failure.
* @return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public void initialize(DefaultHttpClient httpClient) throws ClientServicesExcept
if (accesstoken != null) {
HttpRequestInterceptor oauthInterceptor = new OAuth2Interceptor(accesstoken);
httpClient.addRequestInterceptor(oauthInterceptor, 0);
httpClient.setCookieStore(getCookieStore(getConsumerSecret()));
}
} catch (OAuthException e) {}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* � Copyright IBM Corp. 2012
* � Copyright IBM Corp. 2012
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -245,11 +245,14 @@ public void logout() throws OAuthException {
@Override
public void initialize(DefaultHttpClient httpClient) throws ClientServicesException {
try {
String key = getConsumerSecret();
AccessToken token = oAuthHandler.acquireToken(false);
if ((token != null) && (oAuthHandler != null)) {
HttpRequestInterceptor oauthInterceptor = new OAuthInterceptor(token, super.getUrl(),oAuthHandler);
httpClient.addRequestInterceptor(oauthInterceptor, 0);
httpClient.setCookieStore(getCookieStore(key));
}

} catch (OAuthException ex) {
throw new ClientServicesException(ex);
}
Expand Down