class CompositeCredentialResolver implements CredentialResolver {

	public Credential resolveCredential(HttpServletRequest request){
		if(request==null){
			return null;
		}
		
		Credential credential = null;
		if(encryCredentialResolver!=null){
			//先解析加密后的凭据。
			credential = encryCredentialResolver.resolveCredential(request);
		}
		//若返回空，则用原始凭据解析器解析。
		if(credential==null){
			if(usernamePasswordCredentialResolver!=null){
				credential = usernamePasswordCredentialResolver.resolveCredential(request);
			}
		}
		
		//如果是抽象的参数凭据对象，则解析其它的参数。
		if(credential instanceof AbstractParameter){
			AbstractParameter abstractParameter = (AbstractParameter)credential;
			//将所有的参数设置到参数列表中，方便以后处理使用。
			abstractParameter.setParameters(WebUtils.getParametersStartingWith(request, null));
			//如果参数列表中无service,则从session中获取。
			if(abstractParameter.getParameterValue(WebConstants.SERVICE_PARAM_NAME)==null){
				if(request.getSession().getAttribute(WebConstants.KI4SO_SERVICE_KEY_IN_SESSION)!=null){
					abstractParameter.getParameters().put(WebConstants.SERVICE_PARAM_NAME, request.getSession().getAttribute(WebConstants.KI4SO_SERVICE_KEY_IN_SESSION));
				}
			}
		}
		return credential;
	}

	public  CompositeCredentialResolver();

}