org.apache.http.client.protocol.ClientContext Java Examples

The following examples show how to use org.apache.http.client.protocol.ClientContext. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HttpClientConfigurer.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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);
            }
        }
 
Example #2
Source File: PreemptiveAuth.java    From jenkins-client-java with MIT License 6 votes vote down vote up
@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);
        }
    }
}
 
Example #3
Source File: PreemptiveAuth.java    From verigreen with Apache License 2.0 6 votes vote down vote up
@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);
        }
    }
}
 
Example #4
Source File: IndiShareAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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 IndiShare.com");
    //responseString = NUHttpClientUtils.getData("http://www.indishare.com/", httpContext);
}
 
Example #5
Source File: VideoWoodAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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");
   }
 
Example #6
Source File: IguanaShareAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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 IguanaShare.com");
    //responseString = NUHttpClientUtils.getData("", httpContext);
}
 
Example #7
Source File: DropVideoAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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 DropVideo.com");
    //responseString = NUHttpClientUtils.getData("", httpContext);
}
 
Example #8
Source File: GBoxesAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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 GBoxes.com");
    //responseString = NUHttpClientUtils.getData("http://www.gboxes.com", httpContext);
}
 
Example #9
Source File: SharedSxAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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 Shared.sx");
    //responseString = NUHttpClientUtils.getData("Shared.sx", httpContext);
}
 
Example #10
Source File: UsersFilesAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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 UsersFiles.com");
    responseString = NUHttpClientUtils.getData("https://usersfiles.com/", httpContext);
    
    doc = Jsoup.parse(responseString);
    rand = doc.select("form[name=FL]").select("input[name=rand]").attr("value");
}
 
Example #11
Source File: GoFourUpAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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 Go4Up.com");
    //responseString = NUHttpClientUtils.getData("", httpContext);
}
 
Example #12
Source File: TwentyFourUploadingAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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 24Uploading.com");
    //responseString = NUHttpClientUtils.getData("", httpContext);
}
 
Example #13
Source File: FileJokerAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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 FileJoker.net");
    //responseString = NUHttpClientUtils.getData("https://filejoker.net", httpContext);
}
 
Example #14
Source File: LetWatchAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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 LetWatch.us");
    //responseString = NUHttpClientUtils.getData("", httpContext);
}
 
Example #15
Source File: SpeedyShare.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void run() {
    //Checking once again as user may disable account while this upload thread is waiting in queue
    try {
        if (speedyShareAccount.loginsuccessful) {
            userType = "reg";
            httpContext = speedyShareAccount.getHttpContext();
            maxFileSizeLimit = fileSizeLimit; // Unlimited
        } else {
            userType = "anon";
            cookieStore = new BasicCookieStore();
            httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
            maxFileSizeLimit = fileSizeLimit; // Unlimited
        }
        
        //-------------------------------------------------------------
        uploadInitialising();
        initialize();
        //-------------------------------------------------------------

        //-------------------------------------------------------------
        uploading();
        fileUpload();
        //-------------------------------------------------------------

        //-------------------------------------------------------------
        gettingLink();
        getDownloadLinks();
        //-------------------------------------------------------------

        NULogger.getLogger().log(Level.INFO, "Download Link: {0}", downURL);
        NULogger.getLogger().log(Level.INFO, "Delete link: {0}", delURL);

        uploadFinished();
    } catch (Exception ex) {
        NULogger.getLogger().log(Level.SEVERE, "SpeedyShare upload failed: {0} ", ex);

        uploadFailed();
    }
}
 
Example #16
Source File: UpSharedAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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 UpShared.com");
    //responseString = NUHttpClientUtils.getData("http://upshared.com", httpContext);
}
 
Example #17
Source File: XvidStageAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #18
Source File: XfileLoadAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #19
Source File: VShareAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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 VShare.eu");
    responseString = NUHttpClientUtils.getData("http://vshare.eu/login.html", httpContext);
    redirect = StringUtils.stringBetweenTwoStrings(responseString, "name=\"redirect\" value=\"", "\"");
}
 
Example #20
Source File: MinhaTecaAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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!");
    }
}
 
Example #21
Source File: FilesTwoShareAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #22
Source File: FileNukeAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #23
Source File: BitShareAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #24
Source File: EdiskCzAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #25
Source File: CloudCornerAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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");
        }
    }
}
 
Example #26
Source File: SafeSharingAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #27
Source File: TwoDriveAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #28
Source File: UploadBoyAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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);
}
 
Example #29
Source File: CookieUtils.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #30
Source File: MegaCacheAccount.java    From neembuu-uploader with GNU General Public License v3.0 5 votes vote down vote up
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);
}