List of usage examples for java.net CookiePolicy ACCEPT_NONE
CookiePolicy ACCEPT_NONE
To view the source code for java.net CookiePolicy ACCEPT_NONE.
Click Source Link
From source file:Main.java
public static void main(String[] args) throws Exception { CookieManager cm = new CookieManager(); cm.setCookiePolicy(CookiePolicy.ACCEPT_NONE); CookieHandler.setDefault(cm); new URL("http://google.com").openConnection().getContent(); List<HttpCookie> cookies = cm.getCookieStore().getCookies(); for (HttpCookie cookie : cookies) { System.out.println("Name = " + cookie.getName()); System.out.println("Value = " + cookie.getValue()); System.out.println("Lifetime (seconds) = " + cookie.getMaxAge()); System.out.println("Path = " + cookie.getPath()); System.out.println();/*from w w w . j av a 2 s . c om*/ } }
From source file:org.jboss.aerogear.android.cookbook.agreddit.authentication.RedditAuthenticationModule.java
public void login(final String username, final String password, final Callback<HeaderAndBody> callback) { COOKIE_MANAGER = new CookieManager(null, CookiePolicy.ACCEPT_NONE); CookieHandler.setDefault(COOKIE_MANAGER); AsyncTask<Void, Void, HeaderAndBody> task = new AsyncTask<Void, Void, HeaderAndBody>() { private Exception exception; @Override/*from w w w.j av a2 s . c o m*/ protected HeaderAndBody doInBackground(Void... params) { HeaderAndBody result; try { HttpProvider provider = new HttpRestProvider(getLoginURL(username)); provider.setDefaultHeader("User-Agent", "AeroGear StoryList Demo /u/secondsun"); provider.setDefaultHeader("Content-Type", "application/x-www-form-urlencoded"); String loginData = buildLoginData(username, password); result = provider.post(loginData); Log.d("Auth", new String(result.getBody())); String json = new String(result.getBody()); JsonObject obj = new JsonParser().parse(json).getAsJsonObject().get("json").getAsJsonObject(); modHash = obj.get("data").getAsJsonObject().get("modhash").getAsString(); authToken = obj.get("data").getAsJsonObject().get("cookie").getAsString(); isLoggedIn = true; } catch (Exception e) { Log.e(RedditAuthenticationModule.class.getSimpleName(), "Error with Login", e); exception = e; return null; } return result; } @Override protected void onPostExecute(HeaderAndBody headerAndBody) { if (exception == null) { callback.onSuccess(headerAndBody); } else { callback.onFailure(exception); } } }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }
From source file:at.gv.egiz.bku.binding.AbstractBindingProcessor.java
@Override public void init(String id, STAL stal, SLCommandInvoker commandInvoker) { if (id == null) { throw new NullPointerException("Id must not be null."); }//from w w w. ja va 2 s .c o m if (stal == null) { throw new NullPointerException("STAL must not null."); } if (commandInvoker == null) { throw new NullPointerException("CommandInvoker must null."); } this.id = IdFactory.getInstance().createId(id); this.stal = stal; this.commandInvoker = commandInvoker; // disable cookies CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_NONE)); }