Spring-Seecurity-OAuth 2が遭遇した奇妙な問題


SpringFraamewarkで提供されたsparklr 2をもとに、ヒョウタンの絵瓢箪に従ってOAuth 2 Serverプログラムを描きます.運行は大丈夫です.正式にプロジェクトをする時、もう二、三の問題があります.
最初はユーザ登録後、直接に空のポインターエラーを報告します.エラーの原因はAccess ConfirmationControllerにあります.これは自分で書いたControllerです.Spring-Seecurity-OAuth 2と合わせて使います.sparklr 2にはこのControllerがあります.主な原因はgetAccess Confirmation方法のパラメータmodelであり、中には「authorization Request」という有名なオブジェクトがありません.sizeは0です.このパラメータはsessionから取り出したものです.この種類はsparklr(瓢箪画瓢箪を含むテストプログラムでは同じです)の代コードは以下の通りです.
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.oauth2.provider.AuthorizationRequest;
import org.springframework.security.oauth2.provider.ClientDetails;
import org.springframework.security.oauth2.provider.ClientDetailsService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.servlet.ModelAndView;

/**
 * Controller for retrieving the model for and displaying the confirmation page for access to a protected resource.
 * 
 * @author Ryan Heaton
 */
@Controller
@SessionAttributes("authorizationRequest")
public class AccessConfirmationController {

	private ClientDetailsService clientDetailsService;

	@RequestMapping("/oauth/confirm_access")
	public ModelAndView getAccessConfirmation(Map<String, Object> model) throws Exception {
		AuthorizationRequest clientAuth = (AuthorizationRequest) model.remove("authorizationRequest");
		ClientDetails client = clientDetailsService.loadClientByClientId(clientAuth.getClientId());
		model.put("auth_request", clientAuth);
		model.put("client", client);
		return new ModelAndView("access_confirmation", model);
	}

	@RequestMapping("/oauth/error")
	public String handleError(Map<String,Object> model) throws Exception {
		// We can add more stuff to the model here for JSP rendering.  If the client was a machine then
		// the JSON will already have been rendered.
		model.put("message", "There was a problem with the OAuth2 protocol");
		return "oauth_error";
	}

	@Autowired
	public void setClientDetailsService(ClientDetailsService clientDetailsService) {
		this.clientDetailsService = clientDetailsService;
	}
}
中にSession Attributesを宣言しましたが、方法のmodelにはありません.
私の最初の解決方法は、AuthortionRequestオブジェクトをメソッドパラメータリストに追加して、@ModelAttributeで修飾します.やはり、このパラメータを得ることができ、正常にaccessTokenを得ることができますが、このaccessTokenを通じて保護されたデータを取得するにはいつも警告権限が足りません.
追跡調査でVoteが採決を行っているのを発見した時は、scopeが通りませんでした.
お客様のアプリケーションはscopeを提供しています.READですが、抽出されたライセンスのうち、scopeは「read+write」です.本来は2つの文字列のSetの結果が1つの文字列しかないSetになりましたので、検査の時はいつも通りません.
長い間追跡した結果、Access ConfirmationControllerがAuthortionRequestオブジェクトを取得した時に問題が発生しました.sessionに保存する時はいいです.(AuthortionEntpoint.authorize方法、159行目はmodelの中にput値を設定してSessionに設定します.)、scopeはSeriwte+Seriteです..
この時のコードは以下の通りです.
import java.util.Enumeration;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.oauth2.provider.AuthorizationRequest;
import org.springframework.security.oauth2.provider.ClientDetails;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.servlet.ModelAndView;

/**
 * Controller for retrieving the model for and displaying the confirmation page for access to a protected resource.
 * 
 * @author Ryan Heaton
 */
@Controller
@SessionAttributes("authorizationRequest")
public class AccessConfirmationController {
	
	private ClientDetailsService clientDetailsService;

	@RequestMapping("/oauth/confirm_access")
	public ModelAndView getAccessConfirmation(Map<String, Object> model, @ModelAttribute("authorizationRequest")AuthorizationRequest clientAuth) throws Exception {
		model.remove("authorizationRequest");
		ClientDetails client = clientDetailsService.loadClientByClientId(clientAuth.getClientId());
		model.put("auth_request", clientAuth);
		model.put("client", client);
		return new ModelAndView("access_confirmation", model);
	}

	@RequestMapping("/oauth/error")
	public String handleError(Map<String,Object> model) throws Exception {
		// We can add more stuff to the model here for JSP rendering.  If the client was a machine then
		// the JSON will already have been rendered.
		model.put("message", "There was a problem with the OAuth2 protocol");
		return "oauth2/error";
	}
	@Autowired
	public void setClientDetailsService(ClientDetailsService clientDetailsService) {
		this.clientDetailsService = clientDetailsService;
	}
}
やむを得ず、AuthortionRequestオブジェクトをgetAccess Confirmationのパラメータリストからクリアし、HttpSessionオブジェクトをパラメータとして追加し、sessionから直接データを取得すればいいです.
最後のコードは:
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.oauth2.provider.AuthorizationRequest;
import org.springframework.security.oauth2.provider.ClientDetails;
import org.springframework.security.oauth2.provider.ClientDetailsService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;
import org.springframework.web.servlet.ModelAndView;

/**
 * Controller for retrieving the model for and displaying the confirmation page for access to a protected resource.
 * 
 * @author Ryan Heaton
 */
@Controller
@SessionAttributes("authorizationRequest")
public class AccessConfirmationController {

	private ClientDetailsService clientDetailsService;

	@RequestMapping("/oauth/confirm_access")
	public ModelAndView getAccessConfirmation(Map<String, Object> model, HttpSession session) throws Exception {
		AuthorizationRequest clientAuth = (AuthorizationRequest) session.getAttribute("authorizationRequest");
//		 session.removeAttribute("authorizationRequest");//    ,       。model        Session     
		ClientDetails client = clientDetailsService.loadClientByClientId(clientAuth.getClientId());
		model.put("auth_request", clientAuth);
		model.put("client", client);
		return new ModelAndView("access_confirmation", model);
	}

	@RequestMapping("/oauth/error")
	public String handleError(Map<String,Object> model) throws Exception {
		// We can add more stuff to the model here for JSP rendering.  If the client was a machine then
		// the JSON will already have been rendered.
		model.put("message", "There was a problem with the OAuth2 protocol");
		return "oauth_error";
	}

	@Autowired
	public void setClientDetailsService(ClientDetailsService clientDetailsService) {
		this.clientDetailsService = clientDetailsService;
	}
}
現在の問題は:
1.Access Confirmation Controllerのget Access ConfirmationはどうしてmodelからAuthortionRequestオブジェクトを取得できないですか?Sessionを注ぎ込むと、中にこの相手がいるのが見えます.
2.AuthortionRequest声明をget Access Confirmationの方法の中で、@ModelAttributeで修飾して、どうして取り出しられますか?しかし、なぜscope属性がSet[read,write]からSet[read+write]に変わったのですか?誰がやった幽霊ですか
3.上記追跡中にどこかに漏れがありましたか?この問題を引き起こした元凶ですか?