Skip to content

Commit

Permalink
renaming 'verification code' to 'authorization code' on the client-si…
Browse files Browse the repository at this point in the history
…de to align with oauth spec terminology
  • Loading branch information
stoicflame committed Jul 29, 2011
1 parent b6738e8 commit 3ec6515
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.springframework.security.web.PortResolver;
import org.springframework.security.web.PortResolverImpl;
import org.springframework.security.web.RedirectStrategy;
import org.springframework.security.web.savedrequest.DefaultSavedRequest;
import org.springframework.security.web.util.ThrowableAnalyzer;
import org.springframework.security.web.util.UrlUtils;
import org.springframework.util.Assert;
Expand Down Expand Up @@ -68,7 +67,7 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo
}
oauth2Context.setErrorParameters(errorParams);
}
oauth2Context.setVerificationCode(request.getParameter("code"));
oauth2Context.setAuthorizationCode(request.getParameter("code"));
oauth2Context.setUserAuthorizationRedirectUri(calculateCurrentUri(request));
oauth2Context.setPreservedState(getRememberMeServices().loadPreservedState(request.getParameter("state"), request, response));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ public interface OAuth2SecurityContext {
String getUserAuthorizationRedirectUri();

/**
* The verification code for this context.
* The authorization code for this context.
*
* @return The verification code, or null if none.
* @return The authorization code, or null if none.
*/
String getVerificationCode();
String getAuthorizationCode();

/**
* Any details for this security this context.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class OAuth2SecurityContextImpl implements OAuth2SecurityContext {
private Object preservedState;
private String userAuthorizationRedirectUri;
private Map<String, String> errorParameters;
private String verificationCode;
private String authorizationCode;
private Object details;

public Map<String, OAuth2AccessToken> getAccessTokens() {
Expand Down Expand Up @@ -48,12 +48,12 @@ public void setErrorParameters(Map<String, String> errorParameters) {
this.errorParameters = errorParameters;
}

public String getVerificationCode() {
return verificationCode;
public String getAuthorizationCode() {
return authorizationCode;
}

public void setVerificationCode(String verificationCode) {
this.verificationCode = verificationCode;
public void setAuthorizationCode(String authorizationCode) {
this.authorizationCode = authorizationCode;
}

public Object getDetails() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ public class WebServerProfile extends OAuth2AccessTokenSupport implements OAuth2
public OAuth2AccessToken obtainNewAccessToken(OAuth2ProtectedResourceDetails details) throws UserRedirectRequiredException, AccessDeniedException {
WebServerProfileResourceDetails resource = (WebServerProfileResourceDetails) details;
final OAuth2SecurityContext context = OAuth2SecurityContextHolder.getContext();
String verificationCode = null;
String authorizationCode = null;
if (context != null) {
verificationCode = context.getVerificationCode();
authorizationCode = context.getAuthorizationCode();
}

if (context != null && context.getErrorParameters() != null) {
//there was an oauth error...
throw getSerializationService().deserializeError(context.getErrorParameters());
}
else if (verificationCode == null) {
//we don't have a verification code yet. So first get that.
else if (authorizationCode == null) {
//we don't have an authorization code yet. So first get that.
TreeMap<String, String> requestParameters = new TreeMap<String, String>();
requestParameters.put("response_type", "code"); //oauth2 spec, section 3
requestParameters.put("client_id", resource.getClientId());
Expand Down Expand Up @@ -81,7 +81,7 @@ else if (verificationCode == null) {
MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>();
form.add("grant_type", "authorization_code");
form.add("client_id", resource.getClientId());
form.add("code", verificationCode);
form.add("code", authorizationCode);

Object state = context == null ? null : context.getPreservedState();
if (state == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void startElement(String uri, String localName, String qName, Attributes
if (context != null) {
// this one is kind of a hack for this application
// the problem is that the sparklr photos page doesn't remove the 'code=' request parameter.
((OAuth2SecurityContextImpl)context).setVerificationCode(null);
((OAuth2SecurityContextImpl)context).setAuthorizationCode(null);
}
//clear any stored access tokens...
getTokenServices().removeToken(SecurityContextHolder.getContext().getAuthentication(), resource);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public String photos(Model model) throws Exception {
if (context != null) {
// this one is kind of a hack for this application
// the problem is that the facebook friends page doesn't remove the 'code=' request parameter.
((OAuth2SecurityContextImpl) context).setVerificationCode(null);
((OAuth2SecurityContextImpl) context).setAuthorizationCode(null);
}
// clear any stored access tokens...
tokenServices.removeToken(SecurityContextHolder.getContext().getAuthentication(), resource);
Expand Down

0 comments on commit 3ec6515

Please sign in to comment.