Ejemplo n.º 1
0
        /**
         * 构造url
         *
         * @param encode 转码
         * @return url
         */
        public string build(bool encode)
        {
            if (this.paramDic.Count == 0 || this.paramDic == null)
            {
                return(this.baseUrl);
            }
            string baseUrl     = this.appendIfNotContain(this.baseUrl, "?", "&");
            string paramString = GlobalAuthUtil.parseMapToString(this.paramDic);

            return(baseUrl + paramString);
        }
Ejemplo n.º 2
0
        /**
         * 检查配置合法性。针对部分平台, 对redirect uri有特定要求。一般来说redirect uri都是http://,而对于facebook平台, redirect uri 必须是https的链接
         *
         * @param config config
         * @param source source
         * @since 1.6.1-beta
         */
        public static void checkConfig(ClientConfig config, IAuthSource source)
        {
            string redirectUri = config.redirectUri;

            if (!GlobalAuthUtil.isHttpProtocol(redirectUri) && !GlobalAuthUtil.isHttpsProtocol(redirectUri))
            {
                throw new Exception(AuthResponseStatus.ILLEGAL_REDIRECT_URI.GetDesc());
            }
            // facebook的回调地址必须为https的链接
            if ("FACEBOOK".Equals(source.getName().ToUpper()) && !GlobalAuthUtil.isHttpsProtocol(redirectUri))
            {
                // Facebook's redirect uri must use the HTTPS protocol
                throw new Exception(AuthResponseStatus.ILLEGAL_REDIRECT_URI.GetDesc());
            }
            // 支付宝在创建回调地址时,不允许使用localhost或者127.0.0.1
            if ("ALIPAY".Equals(source.getName().ToUpper()) && GlobalAuthUtil.isLocalHost(redirectUri))
            {
                // The redirect uri of alipay is forbidden to use localhost or 127.0.0.1
                throw new Exception(AuthResponseStatus.ILLEGAL_REDIRECT_URI.GetDesc());
            }
        }