Beispiel #1
0
        private ICredentials InitCredentials(ClientSecurityConfig securityConfig, GroupConfig groupConfig)
        {
            var credentials = securityConfig.GetCredentials();

            if (credentials == null)
            {
                var credentialsClassname = securityConfig.GetCredentialsClassName();
                if (credentialsClassname != null)
                {
                    try
                    {
                        var type = Type.GetType(credentialsClassname, true, false);
                        if (type != null)
                        {
                            credentials = Activator.CreateInstance(type) as ICredentials;
                        }
                    }
                    catch (Exception e)
                    {
                        throw ExceptionUtil.Rethrow(e);
                    }
                }
            }
            if (credentials == null)
            {
                credentials = new UsernamePasswordCredentials(groupConfig.GetName(), groupConfig.GetPassword());
            }
            return(credentials);
        }
Beispiel #2
0
 public void Configure(GroupConfig groupConfig, IDictionary <string, string> properties)
 {
     if (!properties.TryGetValue("username", out _username))
     {
         _username = groupConfig.GetName();
     }
     if (!properties.TryGetValue("password", out _password))
     {
         _password = groupConfig.GetPassword();
     }
 }
Beispiel #3
0
        public ICredentials NewCredentials()
        {
            string username, password;

            if (!properties.TryGetValue("username", out username))
            {
                username = groupConfig.GetName();
            }
            if (!properties.TryGetValue("password", out password))
            {
                password = groupConfig.GetPassword();
            }
            return(new UsernamePasswordCredentials(username, password));
        }