Java Code Examples for org.apache.oltu.oauth2.common.utils.OAuthUtils#format()

The following examples show how to use org.apache.oltu.oauth2.common.utils.OAuthUtils#format() . 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: QueryParameterApplier.java    From orion.server with Eclipse Public License 1.0 6 votes vote down vote up
public OAuthMessage applyOAuthParameters(OAuthMessage message, Map<String, Object> params) {

        String messageUrl = message.getLocationUri();
        if (messageUrl != null) {
            boolean containsQuestionMark = messageUrl.contains("?");
            StringBuffer url = new StringBuffer(messageUrl);
 
            StringBuffer query = new StringBuffer(OAuthUtils.format(params.entrySet(), "UTF-8"));
  
            if (!OAuthUtils.isEmpty(query.toString())) {
                if (containsQuestionMark) {
                    url.append("&").append(query);
                } else {
                    url.append("?").append(query);
                }
            }   
            message.setLocationUri(url.toString());
        }
        return message;
    }
 
Example 2
Source File: FragmentParametersApplier.java    From orion.server with Eclipse Public License 1.0 6 votes vote down vote up
public OAuthMessage applyOAuthParameters(OAuthMessage message, Map<String, Object> params) throws OAuthSystemException {

        String messageUrl = message.getLocationUri();
        if (messageUrl != null) {
            StringBuilder url = new StringBuilder(messageUrl);

            if (params.containsKey(OAuth.OAUTH_REFRESH_TOKEN)) {
                params.remove(OAuth.OAUTH_REFRESH_TOKEN);
            }

            String fragmentQuery = OAuthUtils.format(params.entrySet(), "UTF-8");

            if (!OAuthUtils.isEmpty(fragmentQuery)) {
                if (params.size() > 0) {
                        url.append("#").append(fragmentQuery);
                }
            }
            message.setLocationUri(url.toString());
        }
        return message;
    }
 
Example 3
Source File: BodyURLEncodedParametersApplier.java    From orion.server with Eclipse Public License 1.0 5 votes vote down vote up
public OAuthMessage applyOAuthParameters(OAuthMessage message, Map<String, Object> params)
    throws OAuthSystemException {

    String body = OAuthUtils.format(params.entrySet(), "UTF-8");
    message.setBody(body);
    return message;

}