类org.apache.http.client.protocol.ClientContext源码实例Demo

下面列出了怎么用org.apache.http.client.protocol.ClientContext的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: jenkins-client-java   文件: PreemptiveAuth.java
@Override
public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
    AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE);

    if (authState.getAuthScheme() == null) {
        AuthScheme authScheme = (AuthScheme) context.getAttribute("preemptive-auth");
        CredentialsProvider credsProvider = (CredentialsProvider) context
                .getAttribute(ClientContext.CREDS_PROVIDER);
        HttpHost targetHost = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);
        if (authScheme != null) {
            Credentials creds = credsProvider
                    .getCredentials(new AuthScope(targetHost.getHostName(), targetHost.getPort()));
            if (creds == null) {
                throw new HttpException("No credentials for preemptive authentication");
            }
            authState.update(authScheme, creds);
        }
    }
}
 
源代码2 项目: pushfish-android   文件: HttpClientConfigurer.java
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {

            AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE);

            if (authState.getAuthScheme() != null || authState.hasAuthOptions()) {
                return;
            }

            // If no authState has been established and this is a PUT or POST request, add preemptive authorisation
            String requestMethod = request.getRequestLine().getMethod();
            if (requestMethod.equals(HttpPut.METHOD_NAME) || requestMethod.equals(HttpPost.METHOD_NAME)) {
                CredentialsProvider credentialsProvider = (CredentialsProvider) context.getAttribute(ClientContext.CREDS_PROVIDER);
                HttpHost targetHost = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);
                Credentials credentials = credentialsProvider.getCredentials(new AuthScope(targetHost.getHostName(), targetHost.getPort()));
                if (credentials == null) {
                    throw new HttpException("No credentials for preemptive authentication");
                }
                authState.update(authScheme, credentials);
            }
        }
 
源代码3 项目: verigreen   文件: PreemptiveAuth.java
@Override
public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
    AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE);
    Credentials creds;
    
    if (authState.getAuthScheme() == null) {
        AuthScheme authScheme = (AuthScheme) context.getAttribute("preemptive-auth");
        CredentialsProvider credsProvider =
                (CredentialsProvider) context.getAttribute(ClientContext.CREDS_PROVIDER);
        HttpHost targetHost =
                (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);
        if (authScheme != null) {
            creds =
                    credsProvider.getCredentials(new AuthScope(
                            targetHost.getHostName(),
                            targetHost.getPort()));
            if (creds == null) {
                throw new HttpException("No credentials for preemptive authentication");
            }
            authState.update(authScheme, creds);
        }
    }
}
 
源代码4 项目: neembuu-uploader   文件: XvidStageAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    //NULogger.getLogger().info("Getting startup cookies & link from XvidStage.com");
    //responseString = NUHttpClientUtils.getData("http://xvidstage.com", httpContext);
}
 
源代码5 项目: neembuu-uploader   文件: VidToAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    //NULogger.getLogger().info("Getting startup cookies & link from VidTo.me");
    //responseString = NUHttpClientUtils.getData("http://vidto.me", httpContext);
}
 
源代码6 项目: neembuu-uploader   文件: VipFileAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    //NULogger.getLogger().info("Getting startup cookies & link from Vip-File.com");
    //responseString = NUHttpClientUtils.getData("http://vip-file.com", httpContext);
}
 
源代码7 项目: neembuu-uploader   文件: VodLockerAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    //NULogger.getLogger().info("Getting startup cookies & link from VodLocker.com");
    //responseString = NUHttpClientUtils.getData("http://vodlocker.com", httpContext);
}
 
源代码8 项目: neembuu-uploader   文件: FileOmAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    //NULogger.getLogger().info("Getting startup cookies & link from FileOM.com");
    //responseString = NUHttpClientUtils.getData("http://fileom.com", httpContext);
}
 
源代码9 项目: neembuu-uploader   文件: PutStreamAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    //NULogger.getLogger().info("Getting startup cookies & link from PutStream.com");
    //responseString = NUHttpClientUtils.getData("", httpContext);
}
 
源代码10 项目: neembuu-uploader   文件: FileCloudCcAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    //NULogger.getLogger().info("Getting startup cookies & link from FileCloud.cc");
    //responseString = NUHttpClientUtils.getData("http://filecloud.cc", httpContext);
}
 
源代码11 项目: neembuu-uploader   文件: RockFileAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    //NULogger.getLogger().info("Getting startup cookies & link from RockFile.eu");
    //responseString = NUHttpClientUtils.getData("http://rockfile.eu", httpContext);
}
 
源代码12 项目: neembuu-uploader   文件: FireDrive.java
@Override
public void run() {
    uploadInitialising();
    try{
        if (fireDriveAccount.loginsuccessful) {
            httpContext = fireDriveAccount.getHttpContext();
            
            if(fireDriveAccount.isPremium()){
                maxFileSizeLimit = 53687091200l; //50 GB
            }
            else{
                maxFileSizeLimit = 1073741824l; //1 GB
            }
            
        }
        else{
            httpContext.setAttribute(ClientContext.COOKIE_STORE, new BasicCookieStore());
        }
        
        if (file.length() > maxFileSizeLimit) {
            throw new NUMaxFileSizeException(maxFileSizeLimit, file.getName(), getHost());
        }
        
        normalUpload();
        uploadFinished();
    } catch(NUException ex){
        ex.printError();
        uploadInvalid();
    } catch(Exception e){
        NULogger.getLogger().log(Level.INFO, "Exception: {0}", e);
        uploadFailed();
    }
}
 
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
    AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE);
    CredentialsProvider credsProvider = (CredentialsProvider) context.getAttribute(
            ClientContext.CREDS_PROVIDER);
    HttpHost targetHost = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);

    if (authState.getAuthScheme() == null) {
        AuthScope authScope = new AuthScope(targetHost.getHostName(), targetHost.getPort());
        Credentials creds = credsProvider.getCredentials(authScope);
        if (creds != null) {
            authState.setAuthScheme(new BasicScheme());
            authState.setCredentials(creds);
        }
    }
}
 
源代码14 项目: neembuu-uploader   文件: HugeFilesAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    //NULogger.getLogger().info("Getting startup cookies & link from HugeFiles.net");
    //responseString = NUHttpClientUtils.getData("http://hugefiles.net", httpContext);
}
 
源代码15 项目: neembuu-uploader   文件: FileViceAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    //NULogger.getLogger().info("Getting startup cookies & link from FileVice.com");
    //responseString = NUHttpClientUtils.getData("http://filevice.com", httpContext);
}
 
源代码16 项目: neembuu-uploader   文件: VozUploadAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    //NULogger.getLogger().info("Getting startup cookies & link from VozUpload.com");
    //responseString = NUHttpClientUtils.getData("http://vozupload.com/", httpContext);
}
 
源代码17 项目: neembuu-uploader   文件: UploadRocketAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    //NULogger.getLogger().info("Getting startup cookies & link from UploadRocket.net");
    //responseString = NUHttpClientUtils.getData("http://uploadrocket.net", httpContext);
}
 
源代码18 项目: neembuu-uploader   文件: MegaCacheAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    //NULogger.getLogger().info("Getting startup cookies & link from MegaCache.net");
    //responseString = NUHttpClientUtils.getData("http://megacache.net", httpContext);
}
 
源代码19 项目: neembuu-uploader   文件: CookieUtils.java
/**
 * There is a cookie that starts with this name?
 * @param httpContext the context.
 * @param name the first part of the name of the cookie.
 * @return boolean value.
 */
public static boolean existCookieStartWithValue(HttpContext httpContext, String name){
    CookieStore cookieStore = (CookieStore) httpContext.getAttribute(ClientContext.COOKIE_STORE);
    List<Cookie> cookies = cookieStore.getCookies();
    String cookieName;
    for(int i = 0; i < cookies.size(); i++){
        cookieName = cookies.get(i).getName();
        if(cookieName.startsWith(name)){
            return true;
        }
    }
    return false;
}
 
源代码20 项目: neembuu-uploader   文件: UploadBoyAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    //NULogger.getLogger().info("Getting startup cookies & link from UploadBoy.com");
    //responseString = NUHttpClientUtils.getData("http://uploadboy.com", httpContext);
}
 
源代码21 项目: neembuu-uploader   文件: TwoDriveAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    //NULogger.getLogger().info("Getting startup cookies & link from 2Drive.net");
    //responseString = NUHttpClientUtils.getData("2Drive.net", httpContext);
}
 
源代码22 项目: neembuu-uploader   文件: SafeSharingAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    //NULogger.getLogger().info("Getting startup cookies & link from SafeSharing.eu");
    //responseString = NUHttpClientUtils.getData("http://safesharing.eu", httpContext);
}
 
源代码23 项目: neembuu-uploader   文件: CloudCornerAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    NULogger.getLogger().info("** CloudCorner.com ** => Gathering initial cookie values.");
    responseString = NUHttpClientUtils.getData("https://www.cloudcorner.com/", httpContext);
    responseString = NUHttpClientUtils.getData("https://www.cloudcorner.com/api/recaptcha", httpContext);
    // {"success":true,"data":{"enable":true,"key":"6Ld7c9ISAAAAADeAGevtJ0zpz4nfVmjUNt5-Caqh"}}
    
    if (StringUtils.stringBetweenTwoStrings(responseString, "\"enable\":", ",\"").equals("true")){
        isCaptReq = true;
        NULogger.getLogger().info("** CloudCorner.com ** => Captcha is being enforced ...");
        kChallengeCode = StringUtils.stringBetweenTwoStrings(responseString, "\"key\":\"", "\"");
        
        Captcha captcha = captchaServiceProvider().newCaptcha();
        captcha.setFormTitle(Translation.T().captchacontrol()+" ("+ getHOSTNAME()  +")");
        if(captcha.findCCaptchaUrlFromK(kChallengeURL+kChallengeCode) != null){
            captcha.findCaptchaImageURL();
            recaptchaChallengeField = captcha.getCCaptchaUrl();
            captchaString = captcha.getCaptchaString();
            NULogger.getLogger().info("** CloudCorner.com ** => Captcha string input by the user: "+captchaString);
        } else {
            throw new Exception("Captcha generic error");
        }
    }
}
 
源代码24 项目: neembuu-uploader   文件: EdiskCzAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    //NULogger.getLogger().info("Getting startup cookies & link from EDisk.cz");
    //responseString = NUHttpClientUtils.getData("http://www.edisk.cz", httpContext);
}
 
源代码25 项目: neembuu-uploader   文件: BitShareAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
    
    //Force to use en language
    BasicClientCookie cookie = new BasicClientCookie("language_selection", "EN");
    cookie.setDomain(".bitshare.com");
    cookie.setPath("/");
    cookieStore.addCookie(cookie);

    //NULogger.getLogger().info("Getting startup cookies & link from BitShare.com");
    //responseString = NUHttpClientUtils.getData("http://bitshare.com", httpContext);
}
 
源代码26 项目: neembuu-uploader   文件: FileNukeAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    //NULogger.getLogger().info("Getting startup cookies & link from FileNuke.com");
    //responseString = NUHttpClientUtils.getData("http://filenuke.com/", httpContext);
}
 
源代码27 项目: neembuu-uploader   文件: FilesTwoShareAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    //NULogger.getLogger().info("Getting startup cookies & link from Files2Share.ch");
    //responseString = NUHttpClientUtils.getData("http://files2share.ch", httpContext);
}
 
源代码28 项目: neembuu-uploader   文件: MinhaTecaAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    NULogger.getLogger().info("** MinhaTeca.com.br ** => Initiating plugin ...");
    responseString = NUHttpClientUtils.getData("http://minhateca.com.br/", httpContext);
    doc = Jsoup.parse(responseString);
    vToken = doc.select("input[name=__RequestVerificationToken]").attr("value");
    if (!vToken.isEmpty()){
        NULogger.getLogger().info("** MinhaTeca.com.br ** => Verification token found! Proceeding further.");
    } else {
        NULogger.getLogger().info("** MinhaTeca.com.br ** => Error! Unable to find the verification token!");
    }
}
 
源代码29 项目: neembuu-uploader   文件: VideoWoodAccount.java
private void initialize() throws Exception {
       httpContext = new BasicHttpContext();
       cookieStore = new BasicCookieStore();
       httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

       NULogger.getLogger().info("Getting startup cookies & link from VideoWood.tv");
       responseString = NUHttpClientUtils.getData("http://videowood.tv/login", httpContext);
       doc = Jsoup.parse(responseString);
vdwood_token = doc.select("form").select("input[name=_token]").attr("value");
   }
 
源代码30 项目: neembuu-uploader   文件: XfileLoadAccount.java
private void initialize() throws Exception {
    httpContext = new BasicHttpContext();
    cookieStore = new BasicCookieStore();
    httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    //NULogger.getLogger().info("Getting startup cookies & link from XfileLoad.com");
    //responseString = NUHttpClientUtils.getData("http://xfileload.com", httpContext);
}
 
 类所在包
 类方法
 同包方法