}
protected HttpServletRequest setSecurityContext(HttpServletRequest request,
OAuthInfo info) {
final SecurityContext sc = createSecurityContext(request, info);
HttpServletRequest newRequest = new HttpServletRequestWrapper(request) {
@Override
public Principal getUserPrincipal() {
return sc.getUserPrincipal();
}
@Override
public boolean isUserInRole(String role) {
return sc.isUserInRole(role);
}
@Override
public String getAuthType() {
return "OAuth";
}
};
newRequest.setAttribute(OAuthContext.class.getName(), createOAuthContext(info));
return newRequest;
}