Package org.apache.cxf.jaxrs.client

Examples of org.apache.cxf.jaxrs.client.ClientWebApplicationException


            String method, String requestURI, Map<String, String> parameters) {
        try {
            OAuthMessage msg = accessor.newRequestMessage(method, requestURI, parameters.entrySet());
            return msg.getAuthorizationHeader(null);
        } catch (Exception ex) {
            throw new ClientWebApplicationException(ex);
        }
    }
View Full Code Here


                sb.append("Basic ");
                try {
                    String data = consumer.getKey() + ":" + consumer.getSecret();
                    sb.append(Base64Utility.encode(data.getBytes("UTF-8")));
                } catch (Exception ex) {
                    throw new ClientWebApplicationException(ex);
                }
                accessTokenService.header("Authorization", sb.toString());
            } else {
                form.set(OAuthConstants.CLIENT_ID, consumer.getKey());
                form.set(OAuthConstants.CLIENT_SECRET, consumer.getSecret());
            }
        } else {
            // in this case the AccessToken service is expected to find a mapping between
            // the authenticated credentials and the client registration id
        }
        Response response = accessTokenService.form(form);
        Map<String, String> map = null;
        try {
            map = new OAuthJSONProvider().readJSONResponse((InputStream)response.getEntity());
        } catch (IOException ex) {
            throw new ClientWebApplicationException(ex);
        }
        if (200 == response.getStatus()) {
            if (map.containsKey(OAuthConstants.ACCESS_TOKEN)
                && map.containsKey(OAuthConstants.ACCESS_TOKEN_TYPE)) {
                String tokenType = map.get(OAuthConstants.ACCESS_TOKEN_TYPE);
View Full Code Here

        String str = IOUtils.readStringFromStream(is).trim();
        if (str.length() == 0) {
            return Collections.emptyMap();
        }
        if (!str.startsWith("{") || !str.endsWith("}")) {
            throw new ClientWebApplicationException("JSON Sequence is broken");
        }
        Map<String, String> map = new HashMap<String, String>();
       
        str = str.substring(1, str.length() - 1).trim();
        String[] jsonPairs = str.split(",");
View Full Code Here

            String method, String requestURI, Map<String, String> parameters) {
        try {
            OAuthMessage msg = accessor.newRequestMessage(method, requestURI, parameters.entrySet());
            return msg.getAuthorizationHeader(null);
        } catch (Exception ex) {
            throw new ClientWebApplicationException(ex);
        }
    }
View Full Code Here

                sb.append("Basic ");
                try {
                    String data = consumer.getKey() + ":" + consumer.getSecret();
                    sb.append(Base64Utility.encode(data.getBytes("UTF-8")));
                } catch (Exception ex) {
                    throw new ClientWebApplicationException(ex);
                }
                accessTokenService.header("Authorization", sb.toString());
            } else {
                form.set(OAuthConstants.CLIENT_ID, consumer.getKey());
                if (consumer.getSecret() != null) {
                    form.set(OAuthConstants.CLIENT_SECRET, consumer.getSecret());
                }
            }
        } else {
            // in this case the AccessToken service is expected to find a mapping between
            // the authenticated credentials and the client registration id
        }
        Response response = accessTokenService.form(form);
        Map<String, String> map = null;
        try {
            map = new OAuthJSONProvider().readJSONResponse((InputStream)response.getEntity());
        } catch (IOException ex) {
            throw new ClientWebApplicationException(ex);
        }
        if (200 == response.getStatus()) {
            ClientAccessToken token = fromMapToClientToken(map, defaultTokenType);
            if (token == null) {
                throw new OAuthServiceException(OAuthConstants.SERVER_ERROR);
View Full Code Here

            MacAuthorizationScheme macAuthData = new MacAuthorizationScheme(httpProps, token);
            String macAlgo = token.getParameters().get(OAuthConstants.MAC_TOKEN_ALGORITHM);
            String macKey = token.getParameters().get(OAuthConstants.MAC_TOKEN_KEY);
            sb.append(macAuthData.toAuthorizationHeader(macAlgo, macKey));
        } else {
            throw new ClientWebApplicationException(new OAuthServiceException("Unsupported token type"));
        }
       
    }
View Full Code Here

        String str = IOUtils.readStringFromStream(is).trim();
        if (str.length() == 0) {
            return Collections.emptyMap();
        }
        if (!str.startsWith("{") || !str.endsWith("}")) {
            throw new ClientWebApplicationException("JSON Sequence is broken");
        }
        Map<String, String> map = new LinkedHashMap<String, String>();
       
        str = str.substring(1, str.length() - 1).trim();
        String[] jsonPairs = str.split(",");
View Full Code Here

                sb.append("Basic ");
                try {
                    String data = consumer.getKey() + ":" + consumer.getSecret();
                    sb.append(Base64Utility.encode(data.getBytes("UTF-8")));
                } catch (Exception ex) {
                    throw new ClientWebApplicationException(ex);
                }
                accessTokenService.header("Authorization", sb.toString());
            } else {
                form.set(OAuthConstants.CLIENT_ID, consumer.getKey());
                form.set(OAuthConstants.CLIENT_SECRET, consumer.getSecret());
            }
        } else {
            // in this case the AccessToken service is expected to find a mapping between
            // the authenticated credentials and the client registration id
        }
        Response response = accessTokenService.form(form);
        Map<String, String> map = null;
        try {
            map = new OAuthJSONProvider().readJSONResponse((InputStream)response.getEntity());
        } catch (IOException ex) {
            throw new ClientWebApplicationException(ex);
        }
        if (200 == response.getStatus()) {
            ClientAccessToken token = fromMapToClientToken(map);
            if (token == null) {
                throw new OAuthServiceException(OAuthConstants.SERVER_ERROR);
View Full Code Here

            MacAuthorizationScheme macAuthData = new MacAuthorizationScheme(httpProps, token);
            String macAlgo = token.getParameters().get(OAuthConstants.MAC_TOKEN_ALGORITHM);
            String macKey = token.getParameters().get(OAuthConstants.MAC_TOKEN_KEY);
            sb.append(macAuthData.toAuthorizationHeader(macAlgo, macKey));
        } else {
            throw new ClientWebApplicationException(new OAuthServiceException("Unsupported token type"));
        }
       
    }
View Full Code Here

        String str = IOUtils.readStringFromStream(is).trim();
        if (str.length() == 0) {
            return Collections.emptyMap();
        }
        if (!str.startsWith("{") || !str.endsWith("}")) {
            throw new ClientWebApplicationException("JSON Sequence is broken");
        }
        Map<String, String> map = new HashMap<String, String>();
       
        str = str.substring(1, str.length() - 1).trim();
        String[] jsonPairs = str.split(",");
View Full Code Here

TOP

Related Classes of org.apache.cxf.jaxrs.client.ClientWebApplicationException

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.