// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.geocities.com/kpdus/jad.html // Decompiler options: braces fieldsfirst space lnc package org.apache.oltu.oauth2.common.message; import java.util.HashMap; import java.util.Map; import org.apache.oltu.oauth2.common.exception.OAuthProblemException; import org.apache.oltu.oauth2.common.exception.OAuthSystemException; import org.apache.oltu.oauth2.common.parameters.BodyURLEncodedParametersApplier; import org.apache.oltu.oauth2.common.parameters.FragmentParametersApplier; import org.apache.oltu.oauth2.common.parameters.JSONBodyParametersApplier; import org.apache.oltu.oauth2.common.parameters.OAuthParametersApplier; import org.apache.oltu.oauth2.common.parameters.QueryParameterApplier; import org.apache.oltu.oauth2.common.parameters.WWWAuthHeaderParametersApplier; // Referenced classes of package org.apache.oltu.oauth2.common.message: // OAuthMessage public class OAuthResponse implements OAuthMessage { public static class OAuthErrorResponseBuilder extends OAuthResponseBuilder { public OAuthErrorResponseBuilder error(OAuthProblemException oauthproblemexception) { parameters.put("error", oauthproblemexception.getError()); parameters.put("error_description", oauthproblemexception.getDescription()); parameters.put("error_uri", oauthproblemexception.getUri()); parameters.put("state", oauthproblemexception.getState()); return this; } public OAuthErrorResponseBuilder location(String s) { location = s; return this; } public volatile OAuthResponseBuilder location(String s) { return location(s); } public OAuthErrorResponseBuilder setError(String s) { parameters.put("error", s); return this; } public OAuthErrorResponseBuilder setErrorDescription(String s) { parameters.put("error_description", s); return this; } public OAuthErrorResponseBuilder setErrorUri(String s) { parameters.put("error_uri", s); return this; } public OAuthErrorResponseBuilder setRealm(String s) { parameters.put("realm", s); return this; } public OAuthErrorResponseBuilder setState(String s) { parameters.put("state", s); return this; } public OAuthErrorResponseBuilder(int i) { super(i); } } public static class OAuthResponseBuilder { protected OAuthParametersApplier applier; protected String location; protected Map parameters; protected int responseCode; public OAuthResponse buildBodyMessage() throws OAuthSystemException { OAuthResponse oauthresponse = new OAuthResponse(location, responseCode); applier = new BodyURLEncodedParametersApplier(); return (OAuthResponse)applier.applyOAuthParameters(oauthresponse, parameters); } public OAuthResponse buildHeaderMessage() throws OAuthSystemException { OAuthResponse oauthresponse = new OAuthResponse(location, responseCode); applier = new WWWAuthHeaderParametersApplier(); return (OAuthResponse)applier.applyOAuthParameters(oauthresponse, parameters); } public OAuthResponse buildJSONMessage() throws OAuthSystemException { OAuthResponse oauthresponse = new OAuthResponse(location, responseCode); applier = new JSONBodyParametersApplier(); return (OAuthResponse)applier.applyOAuthParameters(oauthresponse, parameters); } public OAuthResponse buildQueryMessage() throws OAuthSystemException { OAuthResponse oauthresponse = new OAuthResponse(location, responseCode); applier = new QueryParameterApplier(); if (parameters.containsKey("access_token")) { applier = new FragmentParametersApplier(); } else { applier = new QueryParameterApplier(); } return (OAuthResponse)applier.applyOAuthParameters(oauthresponse, parameters); } public OAuthResponseBuilder location(String s) { location = s; return this; } public OAuthResponseBuilder setParam(String s, String s1) { parameters.put(s, s1); return this; } public OAuthResponseBuilder setScope(String s) { parameters.put("scope", s); return this; } public OAuthResponseBuilder(int i) { parameters = new HashMap(); responseCode = i; } } protected String body; protected Map headers; protected int responseStatus; protected String uri; protected OAuthResponse(String s, int i) { headers = new HashMap(); uri = s; responseStatus = i; } public static OAuthErrorResponseBuilder errorResponse(int i) { return new OAuthErrorResponseBuilder(i); } public static OAuthResponseBuilder status(int i) { return new OAuthResponseBuilder(i); } public void addHeader(String s, String s1) { headers.put(s, s1); } public String getBody() { return body; } public String getHeader(String s) { return (String)headers.get(s); } public Map getHeaders() { return headers; } public String getLocationUri() { return uri; } public int getResponseStatus() { return responseStatus; } public void setBody(String s) { body = s; } public void setHeaders(Map map) { headers = map; } public void setLocationUri(String s) { uri = s; } }