当前位置: 首页>>代码示例>>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;未经允许,请勿转载。