Package com.sk89q.skmcl.util

Examples of com.sk89q.skmcl.util.HttpRequest


    }

    private void authenticate() throws IOException, InterruptedException, AuthenticationException {
        Object payload = new AuthenticatePayload(id, password);

        HttpRequest request = HttpRequest
                .post(AUTH_URL)
                .bodyJson(payload)
                .execute();

        if (request.getResponseCode() != 200) {
            ErrorResponse error = request.returnContent().asJson(ErrorResponse.class);
            throw new AuthenticationException(error.getErrorMessage(), error.getErrorMessage());
        } else {
            AuthenticateResponse response =
                    request.returnContent().asJson(AuthenticateResponse.class);
            accessToken = response.getAccessToken();
            clientToken = response.getClientToken();
            identities = response.getAvailableProfiles();
            for (Identity identity : identities) {
                identity.setAccessToken(accessToken);
View Full Code Here


    }

    private void refresh() throws IOException, InterruptedException, AuthenticationException {
        Object payload = new RefreshPayload(accessToken, clientToken);

        HttpRequest request = HttpRequest
                .post(REFRESH_URL)
                .bodyJson(payload)
                .execute();

        if (request.getResponseCode() != 200) {
            ErrorResponse error = request.returnContent().asJson(ErrorResponse.class);
            throw new AuthenticationException(error.getErrorMessage(), error.getErrorMessage());
        } else {
            AuthenticateResponse response =
                    request.returnContent().asJson(AuthenticateResponse.class);
            accessToken = response.getAccessToken();
            clientToken = response.getClientToken();
            identities = response.getAvailableProfiles();
            for (Identity identity : identities) {
                identity.setAccessToken(accessToken);
View Full Code Here

        return createFaceImage(username, size);
    }

    private static BufferedImage readSkin(String username) throws IOException {
        URL url = HttpRequest.url(String.format(SKINS_URL, username));
        HttpRequest request = HttpRequest.get(url);

        try {
            request.execute();
            return ImageIO.read(request.getInputStream());
        } finally {
            try {
                request.close();
            } catch (IOException e) {
            }
        }
    }
View Full Code Here

TOP

Related Classes of com.sk89q.skmcl.util.HttpRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.