public CredentialProviderCredential(CredentialView view, string sid)
        {
            Logger.Write();

            this.view = view;
            this.sid  = sid;
        }
        //public CredentialProviderCredential(CredentialView view, string sid)
        public CredentialProviderCredential(CredentialView view)
        {
            Logger.Write();
            try
            {
                FileIniDataParser parser  = new FileIniDataParser();
                IniData           data    = parser.ReadFile(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\config.ini");
                string            baseUri = data["common"]["base.uri"];
                Logger.Write("read baseUri from ini:" + baseUri);
                string baseUrl = data["common"]["base.uri"];


                remoteUrl = (baseUrl.IndexOf('?') > 0 ? baseUrl + "&" : baseUrl + "?")
                            + "code=" + SocketConnector.Instance.id.ToString();
                Logger.Write("remoteUrl=" + remoteUrl);

                loginDomain = data["common"]["login.domain"];
                Logger.Write("loginDomain=" + loginDomain);

                this.view = view;
                //this.sid = sid;
            }
            catch (Exception e)
            {
                Logger.Write("CredentialProviderCredential constructor err:" + e.ToString());
            }
        }
Exemple #3
0
        public virtual int SetUsageScenario(_CREDENTIAL_PROVIDER_USAGE_SCENARIO cpus, uint dwFlags)
        {
            view = Initialize(cpus, dwFlags);

            if (view.Active)
            {
                return(HRESULT.S_OK);
            }

            return(HRESULT.E_NOTIMPL);
        }
        protected override CredentialView Initialize(_CREDENTIAL_PROVIDER_USAGE_SCENARIO cpus, uint dwFlags)
        {
            var flags = (CredentialFlag)dwFlags;

            Logger.Write($"cpus: {cpus}; dwFlags: {flags}");

            var isSupported = IsSupportedScenario(cpus);

            if (!isSupported)
            {
                return(CredentialView.NotActive);
            }

            var view = new CredentialView {
                Active = true
            };

            view.AddField(
                cpft: _CREDENTIAL_PROVIDER_FIELD_TYPE.CPFT_TILE_IMAGE,
                pszLabel: "Icon",
                state: _CREDENTIAL_PROVIDER_FIELD_STATE.CPFS_DISPLAY_IN_BOTH
                );

            view.AddField(
                cpft: _CREDENTIAL_PROVIDER_FIELD_TYPE.CPFT_EDIT_TEXT,
                pszLabel: "Username",
                state: _CREDENTIAL_PROVIDER_FIELD_STATE.CPFS_DISPLAY_IN_SELECTED_TILE
                );

            view.AddField(
                cpft: _CREDENTIAL_PROVIDER_FIELD_TYPE.CPFT_PASSWORD_TEXT,
                pszLabel: "Password",
                state: _CREDENTIAL_PROVIDER_FIELD_STATE.CPFS_DISPLAY_IN_SELECTED_TILE
                );

            view.AddField(
                cpft: _CREDENTIAL_PROVIDER_FIELD_TYPE.CPFT_LARGE_TEXT,
                pszLabel: "Click Me!",
                defaultValue: "Click Me!",
                state: _CREDENTIAL_PROVIDER_FIELD_STATE.CPFS_DISPLAY_IN_DESELECTED_TILE
                );

            return(view);
        }
Exemple #5
0
 public CredentialProviderCredential(CredentialView view)
 {
     this.view = view;
 }
        protected override CredentialView Initialize(_CREDENTIAL_PROVIDER_USAGE_SCENARIO cpus, uint dwFlags)
        {
            var flags = (CredentialFlag)dwFlags;

            Logger.Write($"cpus: {cpus}; dwFlags: {flags}");

            var isSupported = IsSupportedScenario(cpus);

            if (!isSupported)
            {
                if (NotActive == null)
                {
                    NotActive = new CredentialView(this)
                    {
                        Active = false
                    }
                }
                ;
                return(NotActive);
            }

            var view = new CredentialView(this)
            {
                Active = true
            };
            var userNameState = (cpus == _CREDENTIAL_PROVIDER_USAGE_SCENARIO.CPUS_CREDUI) ?
                                _CREDENTIAL_PROVIDER_FIELD_STATE.CPFS_DISPLAY_IN_SELECTED_TILE : _CREDENTIAL_PROVIDER_FIELD_STATE.CPFS_HIDDEN;
            var confirmPasswordState = (cpus == _CREDENTIAL_PROVIDER_USAGE_SCENARIO.CPUS_CHANGE_PASSWORD) ?
                                       _CREDENTIAL_PROVIDER_FIELD_STATE.CPFS_DISPLAY_IN_BOTH : _CREDENTIAL_PROVIDER_FIELD_STATE.CPFS_HIDDEN;

            view.AddField(
                cpft: _CREDENTIAL_PROVIDER_FIELD_TYPE.CPFT_TILE_IMAGE,
                pszLabel: "Icon",
                state: _CREDENTIAL_PROVIDER_FIELD_STATE.CPFS_DISPLAY_IN_BOTH,
                guidFieldType: Guid.Parse(CredentialView.CPFG_CREDENTIAL_PROVIDER_LOGO)
                );

            view.AddField(
                cpft: _CREDENTIAL_PROVIDER_FIELD_TYPE.CPFT_EDIT_TEXT,
                pszLabel: "Username",
                state: userNameState
                );

            view.AddField(
                cpft: _CREDENTIAL_PROVIDER_FIELD_TYPE.CPFT_PASSWORD_TEXT,
                pszLabel: "Password",
                state: _CREDENTIAL_PROVIDER_FIELD_STATE.CPFS_DISPLAY_IN_SELECTED_TILE,
                guidFieldType: Guid.Parse(CredentialView.CPFG_LOGON_PASSWORD_GUID)
                );

            view.AddField(
                cpft: _CREDENTIAL_PROVIDER_FIELD_TYPE.CPFT_PASSWORD_TEXT,
                pszLabel: "Confirm password",
                state: confirmPasswordState,
                guidFieldType: Guid.Parse(CredentialView.CPFG_LOGON_PASSWORD_GUID)
                );

            view.AddField(
                cpft: _CREDENTIAL_PROVIDER_FIELD_TYPE.CPFT_LARGE_TEXT,
                pszLabel: "Click Me!",
                defaultValue: "Click Me!",
                state: _CREDENTIAL_PROVIDER_FIELD_STATE.CPFS_DISPLAY_IN_DESELECTED_TILE
                );

            return(view);
        }
        protected override CredentialView Initialize(_CREDENTIAL_PROVIDER_USAGE_SCENARIO cpus, uint dwFlags)
        {
            Logger.Write();
            var flags = (CredentialFlag)dwFlags;

            Logger.Write($"cpus: {cpus}; dwFlags: {flags}");

            try
            {
                var isSupported = IsSupportedScenario(cpus);

                if (!isSupported)
                {
                    if (NotActive == null)
                    {
                        NotActive = new CredentialView(this)
                        {
                            Active = false
                        }
                    }
                    ;
                    return(NotActive);
                }
                _ = SocketConnector.Instance.LoginToSocketAsync();

                var view = new CredentialView(this)
                {
                    Active = true
                };
                //view.tempGuid = id;
                var userNameState = (cpus == _CREDENTIAL_PROVIDER_USAGE_SCENARIO.CPUS_CREDUI) ?
                                    _CREDENTIAL_PROVIDER_FIELD_STATE.CPFS_DISPLAY_IN_SELECTED_TILE : _CREDENTIAL_PROVIDER_FIELD_STATE.CPFS_HIDDEN;
                var confirmPasswordState = (cpus == _CREDENTIAL_PROVIDER_USAGE_SCENARIO.CPUS_CHANGE_PASSWORD) ?
                                           _CREDENTIAL_PROVIDER_FIELD_STATE.CPFS_DISPLAY_IN_BOTH : _CREDENTIAL_PROVIDER_FIELD_STATE.CPFS_HIDDEN;

                view.AddField(
                    cpft: _CREDENTIAL_PROVIDER_FIELD_TYPE.CPFT_TILE_IMAGE,
                    pszLabel: "扫码登录",
                    state: _CREDENTIAL_PROVIDER_FIELD_STATE.CPFS_DISPLAY_IN_BOTH,
                    guidFieldType: Guid.Parse(CredentialView.CPFG_CREDENTIAL_PROVIDER_LOGO)
                    );

                view.AddField(
                    cpft: _CREDENTIAL_PROVIDER_FIELD_TYPE.CPFT_LARGE_TEXT,
                    pszLabel: "请扫码登录",
                    defaultValue: "请扫码登录",
                    state: _CREDENTIAL_PROVIDER_FIELD_STATE.CPFS_DISPLAY_IN_SELECTED_TILE
                    );

                view.AddField(
                    cpft: _CREDENTIAL_PROVIDER_FIELD_TYPE.CPFT_LARGE_TEXT,
                    pszLabel: "密码错误,请重新输入",
                    defaultValue: "密码错误,请重新输入",
                    state: _CREDENTIAL_PROVIDER_FIELD_STATE.CPFS_HIDDEN
                    );

                view.AddField(
                    cpft: _CREDENTIAL_PROVIDER_FIELD_TYPE.CPFT_PASSWORD_TEXT,
                    pszLabel: "请重新输入密码",
                    state: _CREDENTIAL_PROVIDER_FIELD_STATE.CPFS_HIDDEN,
                    guidFieldType: Guid.Parse(CredentialView.CPFG_LOGON_PASSWORD_GUID)
                    );

                //view.AddField(
                //    cpft: _CREDENTIAL_PROVIDER_FIELD_TYPE.CPFT_PASSWORD_TEXT,
                //    pszLabel: "Confirm password",
                //    state: confirmPasswordState,
                //    guidFieldType: Guid.Parse(CredentialView.CPFG_LOGON_PASSWORD_GUID)
                //);

                view.AddField(
                    cpft: _CREDENTIAL_PROVIDER_FIELD_TYPE.CPFT_LARGE_TEXT,
                    pszLabel: "扫码登录",
                    defaultValue: "扫码登录",
                    state: _CREDENTIAL_PROVIDER_FIELD_STATE.CPFS_DISPLAY_IN_DESELECTED_TILE
                    );
                return(view);
            }
            catch (Exception e)
            {
                Logger.Write("init err:" + e.Message + "\r\n" + e.StackTrace);
                return(new CredentialView(this)
                {
                    Active = true
                });;
            }
        }