當前位置: 首頁>>代碼示例>>Java>>正文


Java CookieHandler.setDefault方法代碼示例

本文整理匯總了Java中java.net.CookieHandler.setDefault方法的典型用法代碼示例。如果您正苦於以下問題:Java CookieHandler.setDefault方法的具體用法?Java CookieHandler.setDefault怎麽用?Java CookieHandler.setDefault使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.net.CookieHandler的用法示例。


在下文中一共展示了CookieHandler.setDefault方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreate

import java.net.CookieHandler; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    shouldAutoPlay = true;
    clearResumePosition();
    mediaDataSourceFactory = buildDataSourceFactory(true);
    mainHandler = new Handler();
    if (CookieHandler.getDefault() != DEFAULT_COOKIE_MANAGER) {
        CookieHandler.setDefault(DEFAULT_COOKIE_MANAGER);
    }

    setContentView(R.layout.player_activity);
    View rootView = findViewById(R.id.root);
    rootView.setOnClickListener(this);
    debugRootView = (LinearLayout) findViewById(R.id.controls_root);
    debugTextView = (TextView) findViewById(R.id.debug_text_view);
    retryButton = (Button) findViewById(R.id.retry_button);
    retryButton.setOnClickListener(this);

    simpleExoPlayerView = (SimpleExoPlayerView) findViewById(R.id.player_view);
    simpleExoPlayerView.setControllerVisibilityListener(this);
    simpleExoPlayerView.requestFocus();
}
 
開發者ID:ashwanijanghu,項目名稱:ExoPlayer-Offline,代碼行數:24,代碼來源:PlayerActivity.java

示例2: createViews

import java.net.CookieHandler; //導入方法依賴的package包/類
private void createViews() {
    mediaDataSourceFactory = buildDataSourceFactory(true);
    mainHandler = new Handler();
    window = new Timeline.Window();
    if (CookieHandler.getDefault() != DEFAULT_COOKIE_MANAGER) {
        CookieHandler.setDefault(DEFAULT_COOKIE_MANAGER);
    }

    LayoutParams layoutParams = new LayoutParams(
            LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT);
    exoPlayerView = new ExoPlayerView(getContext());
    exoPlayerView.setLayoutParams(layoutParams);

    addView(exoPlayerView, 0, layoutParams);
}
 
開發者ID:12d,項目名稱:react-native-videoplayer,代碼行數:17,代碼來源:ReactExoplayerView.java

示例3: SoapSession

import java.net.CookieHandler; //導入方法依賴的package包/類
public SoapSession(URL institutionUrl, String username, String password) throws Exception
{
	this.institutionUrl = institutionUrl;
	encoder = new Base64(-1);

	CookieHandler.setDefault(new BasicCookieHandler());
	final URL endpointUrl = new URL(institutionUrl, "services/SoapService51");

	System.setProperty("axis.socketFactory", "com.dytech.edge.importexport.TleDefaultSocketFactory");
	System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SLF4JLog");
	System.setProperty("org.apache.commons.logging.LogFactory", "org.apache.commons.logging.impl.SLF4JLogFactory");

	final CustomSoapService51Locator locator = new CustomSoapService51Locator();

	client = locator.getSoapService51Endpoint(endpointUrl);

	final PropBagEx userXml = new PropBagEx(client.login(username, password));
	userId = userXml.getNode("uuid");
	loggedIn = true;

	final Map<String, List<String>> fakeHeaders = new HashMap<String, List<String>>();
	fakeHeaders.put("Set-Cookie", locator.getCookiesForUrl(endpointUrl));
	CookieHandler.getDefault().put(endpointUrl.toURI(), fakeHeaders);

	new KeepAlive().start();
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:27,代碼來源:SoapSession.java

示例4: doClientSide

import java.net.CookieHandler; //導入方法依賴的package包/類
void doClientSide() throws Exception {
    // Wait for server to get started.
    while (!serverReady) {
        Thread.sleep(50);
    }

    HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
        public boolean verify(String hostname, SSLSession session) {
            return true;
        }});

    URL url = new URL("https://localhost:" + serverPort +"/");

    // Run without a CookieHandler first
    InputStream in = url.openConnection().getInputStream();
    while (in.read() != -1);  // read response body so connection can be reused

    // Set a CookeHandler and retest using the HttpClient from the KAC
    CookieManager manager = new CookieManager(null, CookiePolicy.ACCEPT_ALL);
    CookieHandler.setDefault(manager);

    in = url.openConnection().getInputStream();
    while (in.read() != -1);

    if (manager.getCookieStore().getCookies().isEmpty()) {
        throw new RuntimeException("Failed: No cookies in the cookie Handler.");
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:29,代碼來源:CookieHttpsClientTest.java

示例5: initCookies

import java.net.CookieHandler; //導入方法依賴的package包/類
private void initCookies() {
    CookieManager cookieManager = new CookieManager();
    CookieHandler.setDefault(cookieManager);
    if (cookieManager.getCookieStore().getCookies().size() == 0) {
        try {
            String url = SharedPreferencesEditor.getInstance().getString(
                    Constants.PREFS_URL_SHORTCUT);
            URI uri = new URI(url);
            HttpCookie cookie = new HttpCookie(Constants.COOKIE_AUTH_NAME,
                    SharedPreferencesEditor.getInstance().getString(
                            Constants.PREFS_AUTH));
            cookie.setDomain(uri.getHost());
            cookie.setPath(Constants.COOKIE_BASE_PATH);
            cookie.setVersion(0);
            cookie.setMaxAge((new Date()).getTime()
                    + Constants.COOKIE_LIFETIME_YEAR);
            cookieManager.getCookieStore().add(uri, cookie);
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }

    }
}
 
開發者ID:CactusSoft,項目名稱:zabbkit-android,代碼行數:24,代碼來源:GraphFragment.java

示例6: CookieHttpClientTest

import java.net.CookieHandler; //導入方法依賴的package包/類
CookieHttpClientTest() throws Exception {
    /* start the server */
    ss = new ServerSocket(0);
    (new Thread(this)).start();

    URL url = new URL("http://localhost:" + ss.getLocalPort() +"/");

    // Run without a CookieHandler first
    InputStream in = url.openConnection().getInputStream();
    while (in.read() != -1);  // read response body so connection can be reused

    // Set a CookeHandler and retest using the HttpClient from the KAC
    CookieManager manager = new CookieManager(null, CookiePolicy.ACCEPT_ALL);
    CookieHandler.setDefault(manager);

    in = url.openConnection().getInputStream();
    while (in.read() != -1);

    if (manager.getCookieStore().getCookies().isEmpty()) {
        throw new RuntimeException("Failed: No cookies in the cookie Handler.");
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:23,代碼來源:CookieHttpClientTest.java

示例7: tstGetPost

import java.net.CookieHandler; //導入方法依賴的package包/類
public void tstGetPost() throws Exception {
  String urlSource = "http://localhost:8080/beige-accounting-web/secure/main.jsp";
  String urlBase = urlSource.substring(0, urlSource.indexOf("secure") - 1);
  assertEquals("http://localhost:8080/beige-accounting-web", urlBase);
  CookieManager cookieManager = new CookieManager();
  cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
  CookieHandler.setDefault(cookieManager);
  URL url = new URL(urlSource);
  Map<String, Object> params = new HashMap<String, Object>();
  params.put("userName", "admin");
  params.put("userPass", "admin");
  params.put("authMethod", "form");
  params.put("urlBase", urlBase);
  params.put("authUrl", urlBase + "/secure/j_security_check");
  params.put("authUserName", "j_username");
  params.put("authUserPass", "j_password");
  params.put("urlSource", urlSource);
  tstAuthGet(url, params, cookieManager); //either Get or Post for test allowed
  urlSource = "http://localhost:8080/beige-accounting-web/secure/sendEntities";
  params.put("urlSource", urlSource);
  //url = new URL(urlSource);
  //tstAuthPost(url, params, cookieManager);
}
 
開發者ID:demidenko05,項目名稱:beige-software,代碼行數:24,代碼來源:HttpURLConnectionTest.java

示例8: main

import java.net.CookieHandler; //導入方法依賴的package包/類
public static void main(String[] args) {
    AppVars.setAppVars();
    Preferences.load();
    if (Preferences.useSystemLookAndFeel()) {
        useSystemLookAndFeel(true);
    }
    CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL));
    if (Preferences.useUserProxy()) {
        ComicUtil.setProxy(Preferences.getProxyAddress(), Preferences.getProxyPort(), Preferences.getProxyUsername(), Preferences.getProxyEncryptedPassword());
    }
    ComicUtil.getNewestComic();

    EventQueue.invokeLater(() -> {
        MainFrame frame = new MainFrame("XKCDownload");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
        frame.setLocationRelativeTo(null);
    });
}
 
開發者ID:sbth,項目名稱:XKCDownload-deprecated,代碼行數:20,代碼來源:Main.java

示例9: onCreate

import java.net.CookieHandler; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  shouldAutoPlay = true;
  clearResumePosition();
  mediaDataSourceFactory = buildDataSourceFactory(true);
  mainHandler = new Handler();
  if (CookieHandler.getDefault() != DEFAULT_COOKIE_MANAGER) {
    CookieHandler.setDefault(DEFAULT_COOKIE_MANAGER);
  }

  setContentView(R.layout.player_activity);
  View rootView = findViewById(R.id.root);
  rootView.setOnClickListener(this);
  debugRootView = findViewById(R.id.controls_root);
  debugTextView = findViewById(R.id.debug_text_view);
  retryButton = findViewById(R.id.retry_button);
  retryButton.setOnClickListener(this);

  simpleExoPlayerView = findViewById(R.id.player_view);
  simpleExoPlayerView.setControllerVisibilityListener(this);
  simpleExoPlayerView.requestFocus();
}
 
開發者ID:y20k,項目名稱:transistor,代碼行數:24,代碼來源:PlayerActivity.java

示例10: init

import java.net.CookieHandler; //導入方法依賴的package包/類
@Before
public void init() {
	trash = new ArrayList<T>();
	CookieManager cookieManager = new CookieManager();
	cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
	CookieHandler.setDefault(cookieManager);

	GsonBuilder gsonBuilder = new GsonBuilder();
	gsonBuilder//
			.setDateFormat("yyyy-MM-dd HH:mm:ss");//
	Gson gson = gsonBuilder.create();

	RestAdapter restAdapter = new RestAdapter.Builder()
			// تعیین مبدل داده
			.setConverter(new GsonConverter(gson))
			// تعیین کنترل کننده خطا
			.setErrorHandler(new PErrorHandler())
			// تعیین آدرس سایت مورد نظر
			.setEndpoint(TestSettings.getApiURL())
			// ایجاد یک نمونه
			.build();
	// ایجاد سرویس‌ها
	this.userService = restAdapter.create(IRUserService.class);
	createTService(restAdapter);
}
 
開發者ID:phoenix-scholars,項目名稱:JPluf,代碼行數:26,代碼來源:AbstractGeneralServiceTest.java

示例11: createService

import java.net.CookieHandler; //導入方法依賴的package包/類
@Before
public void createService() {
	CookieManager cookieManager = new CookieManager();
	cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
	CookieHandler.setDefault(cookieManager);

	GsonBuilder gsonBuilder = new GsonBuilder();
	gsonBuilder//
			.setDateFormat("yyyy-MM-dd HH:mm:ss");//
	Gson gson = gsonBuilder.create();

	RestAdapter restAdapter = new RestAdapter.Builder()//
			.setConverter(new GsonConverter(gson))//
			// تعیین کنترل کننده خطا
			.setErrorHandler(new PErrorHandler())
			// تعیین آدرس سایت مورد نظر
			.setEndpoint(API_URL)
			// ایجاد یک نمونه
			.build();
	this.profileAdmin = restAdapter.create(IRProfileAdministrator.class);
	this.usr = restAdapter.create(IRUserService.class);
}
 
開發者ID:phoenix-scholars,項目名稱:JPluf,代碼行數:23,代碼來源:PProfileAdminTest.java

示例12: newRequestQueue

import java.net.CookieHandler; //導入方法依賴的package包/類
private static RequestQueue newRequestQueue() {
        VolleyLog.DEBUG = true;
        RequestQueue requestQueue = new RequestQueue(openCache(), new BasicNetwork(new HurlStack()));
        requestQueue.start();
        CookieManager manager = new CookieManager(new SimpleCookieStore(), CookiePolicy.ACCEPT_ORIGINAL_SERVER);
        CookieHandler.setDefault(manager);

//        String userAgent = "volley/0";
//        try {
//            String packageName = BaseApplication.getBaseApplication().getPackageName();
//            PackageInfo info = BaseApplication.getBaseApplication().getPackageManager().getPackageInfo(packageName, 0);
//            userAgent = packageName + "/" + info.versionCode;
//        } catch (PackageManager.NameNotFoundException e) {}
//        android.net.http.AndroidHttpClient  httpClient = AndroidHttpClient.newInstance(userAgent);
//        HttpStack httpStack = new OwnHttpClientStack(httpClient);
//        RequestQueue requestQueue = Volley.newRequestQueue(BaseApplication.getBaseApplication(),
//                httpStack);


        return requestQueue;
    }
 
開發者ID:lofei117,項目名稱:TuChongAndroid,代碼行數:22,代碼來源:RequestManager.java

示例13: NetworkStore

import java.net.CookieHandler; //導入方法依賴的package包/類
NetworkStore() {

        kwalaCookieStore = new KwalaCookieStore(KwalaApplication.getInstance());
        CookieManager cookieManager = new CookieManager(kwalaCookieStore, CookiePolicy.ACCEPT_ORIGINAL_SERVER);
        CookieHandler.setDefault(cookieManager);

        okHttpClient = new OkHttpClient.Builder()
                .cookieJar(new JavaNetCookieJar(cookieManager))
                .authenticator(authenticator)
                .readTimeout(30, TimeUnit.SECONDS)
                .writeTimeout(30, TimeUnit.SECONDS)
                .build();

        KwalaApplication application = KwalaApplication.getInstance();

        // Initialize the Amazon Cognito credentials provider
        CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(application,
                KwalaConstants.Network.AWS_IDENTITY_POOL_ID,
                Regions.US_EAST_1
        );

        // Initialize Amazon S3 and transfer utility
        s3Client = new AmazonS3Client(credentialsProvider);
        transferUtility = new TransferUtility(s3Client, application);
    }
 
開發者ID:KwalaGroup,項目名稱:Android-Client,代碼行數:26,代碼來源:NetworkStore.java

示例14: reset

import java.net.CookieHandler; //導入方法依賴的package包/類
public void reset() {
    // Reset system properties.
    System.setProperties(null);

    // From "L" release onwards, calling System.setProperties(null) clears the java.io.tmpdir,
    // so we set it again. No-op on earlier releases.
    System.setProperty("java.io.tmpdir", tmpDir);

    if (JAVA_RUNTIME_VERSION != null) {
        System.setProperty("java.runtime.version", JAVA_RUNTIME_VERSION);
    }
    if (JAVA_VM_INFO != null) {
        System.setProperty("java.vm.info", JAVA_VM_INFO);
    }
    if (JAVA_VM_VERSION != null) {
        System.setProperty("java.vm.version", JAVA_VM_VERSION);
    }
    if (JAVA_VM_VENDOR != null) {
        System.setProperty("java.vm.vendor", JAVA_VM_VENDOR);
    }
    if (JAVA_VM_NAME != null) {
        System.setProperty("java.vm.name", JAVA_VM_NAME);
    }

    // Require writable java.home and user.dir directories for preferences
    if ("Dalvik".equals(System.getProperty("java.vm.name"))) {
        String javaHome = tmpDir + "/java.home";
        IoUtils.safeMkdirs(new File(javaHome));
        System.setProperty("java.home", javaHome);
    }
    String userHome = System.getProperty("user.home");
    if (userHome.length() == 0) {
        userHome = tmpDir + "/user.home";
        IoUtils.safeMkdirs(new File(userHome));
        System.setProperty("user.home", userHome);
    }

    // Localization
    Locale.setDefault(Locale.US);
    TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"));

    // Preferences
    // Temporarily silence the java.util.prefs logger, which otherwise emits
    // an unactionable warning. See RI bug 4751540.
    Logger loggerToMute = Logger.getLogger("java.util.prefs");
    boolean usedParentHandlers = loggerToMute.getUseParentHandlers();
    loggerToMute.setUseParentHandlers(false);
    try {
        // resetPreferences(Preferences.systemRoot());
        resetPreferences(Preferences.userRoot());
    } finally {
        loggerToMute.setUseParentHandlers(usedParentHandlers);
    }

    // HttpURLConnection
    Authenticator.setDefault(null);
    CookieHandler.setDefault(null);
    ResponseCache.setDefault(null);
    HttpsURLConnection.setDefaultHostnameVerifier(defaultHostnameVerifier);
    HttpsURLConnection.setDefaultSSLSocketFactory(defaultSSLSocketFactory);

    // Logging
    LogManager.getLogManager().reset();
    Logger.getLogger("").addHandler(new ConsoleHandler());

    // Cleanup to force CloseGuard warnings etc
    System.gc();
    System.runFinalization();
}
 
開發者ID:dryganets,項目名稱:vogar,代碼行數:70,代碼來源:TestEnvironment.java

示例15: getCookieManager

import java.net.CookieHandler; //導入方法依賴的package包/類
private static java.net.CookieManager getCookieManager() {
    if (mCookieManager == null) {
        mCookieManager = new java.net.CookieManager(null, CookiePolicy.ACCEPT_ALL);
        CookieHandler.setDefault(mCookieManager);
    }
    return mCookieManager;
}
 
開發者ID:alibaba,項目名稱:LuaViewPlayground,代碼行數:8,代碼來源:CookieManager.java


注:本文中的java.net.CookieHandler.setDefault方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。