use of org.apache.http.impl.cookie.BasicClientCookie in project warn-report by saaavsaaa.
the class WebRequestClient method setCookie.
private static void setCookie(String loginToken, String loginUserID) {
Cookie[] cookies = new Cookie[2];
cookies[0] = new BasicClientCookie(LOGIN_USERTOKEN_KEY, loginToken);
cookies[1] = new BasicClientCookie(LOGIN_USERID_KEY, loginUserID);
setCookies(cookies);
/* // 创建一个本地上下文信息
HttpContext localContext = new BasicHttpContext();
// 在本地上下问中绑定一个本地存储
localContext.setAttribute(HttpClientContext.COOKIE_STORE, cs);
cs.addCookie(new BasicClientCookie(LOGIN_USERTOKEN_KEY, loginToken));
cs.addCookie(new BasicClientCookie(LOGIN_USERID_KEY, loginUserID));*/
}
use of org.apache.http.impl.cookie.BasicClientCookie in project warn-report by saaavsaaa.
the class WebRequestClient method setCookies.
private static void setCookies(Map<String, String> cookieKVs) {
Cookie[] cookies = new Cookie[cookieKVs.size()];
int i = 0;
for (Map.Entry<String, String> entry : cookieKVs.entrySet()) {
cookies[i] = new BasicClientCookie(entry.getKey(), entry.getValue());
i++;
}
setCookies(cookies);
}
use of org.apache.http.impl.cookie.BasicClientCookie in project sling-org-apache-sling-testing-clients by apache.
the class SlingClient method impersonate.
/**
* Impersonate user with the given <code>userId</code>
* <p>
* By impersonating a user SlingClient can access content from the perspective of that user.
* </p>
*Passing a <code>null</code> will clear impersonation.
*
* @param userId the user to impersonate. A <code>null</code> value clears impersonation
*/
public SlingClient impersonate(String userId) {
if (userId == null) {
endImpersonation();
return this;
}
BasicClientCookie c = new BasicClientCookie(getSudoCookieName(), userId);
c.setPath("/");
c.setDomain(getUrl().getHost());
getCookieStore().addCookie(c);
return this;
}
use of org.apache.http.impl.cookie.BasicClientCookie in project sling-org-apache-sling-testing-clients by apache.
the class SlingClient method endImpersonation.
/**
* End the impersonation of the current user.
*/
public SlingClient endImpersonation() {
BasicClientCookie c = new BasicClientCookie(getSudoCookieName(), "");
c.setPath("/");
c.setDomain(getUrl().getHost());
// setting expiry date in the past will remove the cookie
c.setExpiryDate(new Date(0));
getCookieStore().addCookie(c);
return this;
}
use of org.apache.http.impl.cookie.BasicClientCookie in project xUtils by wyouflf.
the class HttpFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.http_fragment, container, false);
ViewUtils.inject(this, view);
mAppContext = inflater.getContext().getApplicationContext();
downloadManager = DownloadService.getDownloadManager(mAppContext);
preferencesCookieStore = new PreferencesCookieStore(mAppContext);
BasicClientCookie cookie = new BasicClientCookie("test", "hello");
cookie.setDomain("192.168.1.5");
cookie.setPath("/");
preferencesCookieStore.addCookie(cookie);
return view;
}
Aggregations