Exemplo n.º 1
0
 public PeerSecurityCredentialsManager(PeerCredential credential, PeerAuthenticationMode mode, bool messageAuth)
     : base()
 {
     this.credential  = credential;
     this.mode        = mode;
     this.messageAuth = messageAuth;
 }
Exemplo n.º 2
0
 public PeerClientSecurityTokenManager(PeerSecurityManager parent, PeerCredential credential, PeerAuthenticationMode mode, bool messageAuth)
 {
     this.credential  = credential;
     this.mode        = mode;
     this.messageAuth = messageAuth;
     this.parent      = parent;
 }
 public ServiceCredentials()
 {
     this.userName           = new UserNamePasswordServiceCredential();
     this.clientCertificate  = new X509CertificateInitiatorServiceCredential();
     this.serviceCertificate = new X509CertificateRecipientServiceCredential();
     this.windows            = new WindowsServiceCredential();
     this.issuedToken        = new IssuedTokenServiceCredential();
     this.peer = new PeerCredential();
     this.secureConversation = new SecureConversationServiceCredential();
 }
Exemplo n.º 4
0
        internal void ApplyConfiguration(PeerCredential cert)
        {
            if (cert == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("cert");
            }
            PropertyInformationCollection properties = base.ElementInformation.Properties;

            if (((properties["storeLocation"].ValueOrigin != PropertyValueOrigin.Default) || (properties["storeName"].ValueOrigin != PropertyValueOrigin.Default)) || ((properties["x509FindType"].ValueOrigin != PropertyValueOrigin.Default) || (properties["findValue"].ValueOrigin != PropertyValueOrigin.Default)))
            {
                cert.SetCertificate(this.StoreLocation, this.StoreName, this.X509FindType, this.FindValue);
            }
        }
 protected ServiceCredentials(ServiceCredentials other)
 {
     if (other == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("other");
     }
     this.userName           = new UserNamePasswordServiceCredential(other.userName);
     this.clientCertificate  = new X509CertificateInitiatorServiceCredential(other.clientCertificate);
     this.serviceCertificate = new X509CertificateRecipientServiceCredential(other.serviceCertificate);
     this.windows            = new WindowsServiceCredential(other.windows);
     this.issuedToken        = new IssuedTokenServiceCredential(other.issuedToken);
     this.peer = new PeerCredential(other.peer);
     this.secureConversation = new SecureConversationServiceCredential(other.secureConversation);
 }
        internal void ApplyConfiguration(PeerCredential cert)
        {
            if (cert == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("cert");
            }
            PropertyInformationCollection propertyInfo = this.ElementInformation.Properties;

            if (propertyInfo[ConfigurationStrings.StoreLocation].ValueOrigin != PropertyValueOrigin.Default ||
                propertyInfo[ConfigurationStrings.StoreName].ValueOrigin != PropertyValueOrigin.Default ||
                propertyInfo[ConfigurationStrings.X509FindType].ValueOrigin != PropertyValueOrigin.Default ||
                propertyInfo[ConfigurationStrings.FindValue].ValueOrigin != PropertyValueOrigin.Default)
            {
                cert.SetCertificate(this.StoreLocation, this.StoreName, this.X509FindType, this.FindValue);
            }
        }
Exemplo n.º 7
0
        protected ClientCredentials(ClientCredentials other)
        {
            if (other == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("other");
            }
            if (other.userName != null)
            {
                this.userName = new UserNamePasswordClientCredential(other.userName);
            }
            if (other.clientCertificate != null)
            {
                this.clientCertificate = new X509CertificateInitiatorClientCredential(other.clientCertificate);
            }
            if (other.serviceCertificate != null)
            {
                this.serviceCertificate = new X509CertificateRecipientClientCredential(other.serviceCertificate);
            }
            if (other.windows != null)
            {
                this.windows = new WindowsClientCredential(other.windows);
            }
            if (other.httpDigest != null)
            {
                this.httpDigest = new HttpDigestClientCredential(other.httpDigest);
            }
            if (other.issuedToken != null)
            {
                this.issuedToken = new IssuedTokenClientCredential(other.issuedToken);
            }
            if (other.peer != null)
            {
                this.peer = new PeerCredential(other.peer);
            }

            this.getInfoCardTokenCallback = other.getInfoCardTokenCallback;
            this.supportInteractive       = other.supportInteractive;
            this.securityTokenHandlerCollectionManager = other.securityTokenHandlerCollectionManager;
            this.useIdentityConfiguration = other.useIdentityConfiguration;
            this.isReadOnly = other.isReadOnly;
        }
        internal void ApplyConfiguration(PeerCredential creds)
        {
            if (creds == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("creds");
            }
            PropertyInformationCollection properties = base.ElementInformation.Properties;

            if (properties["certificate"].ValueOrigin != PropertyValueOrigin.Default)
            {
                this.Certificate.ApplyConfiguration(creds);
            }
            if (properties["peerAuthentication"].ValueOrigin != PropertyValueOrigin.Default)
            {
                this.PeerAuthentication.ApplyConfiguration(creds.PeerAuthentication);
            }
            if (properties["messageSenderAuthentication"].ValueOrigin != PropertyValueOrigin.Default)
            {
                this.MessageSenderAuthentication.ApplyConfiguration(creds.MessageSenderAuthentication);
            }
        }
Exemplo n.º 9
0
        static public PeerSecurityManager Create(PeerAuthenticationMode authenticationMode, bool messageAuthentication, PeerSecurityCredentialsManager credman, ChannelProtectionRequirements reqs, XmlDictionaryReaderQuotas readerQuotas)
        {
            PeerSecurityManager      manager             = null;
            X509CertificateValidator connectionValidator = null;
            X509CertificateValidator messageValidator    = null;
            PeerCredential           credential          = credman.Credential;

            if (null == credential && credman == null)
            {
                if (authenticationMode != PeerAuthenticationMode.None || messageAuthentication)
                {
                    PeerExceptionHelper.ThrowArgument_InsufficientCredentials(PeerPropertyNames.Credentials);
                }
                //create one that doesnt have any credentials in it.
                return(CreateDummy());
            }

            manager              = new PeerSecurityManager(authenticationMode, messageAuthentication);
            manager.credManager  = credman;
            manager.password     = credman.Password;
            manager.readerQuotas = readerQuotas;
            if (reqs != null)
            {
                manager.protection = new ChannelProtectionRequirements(reqs);
            }
            manager.tokenManager = credman.CreateSecurityTokenManager();
            if (credential == null)
            {
                return(manager);
            }

            switch (authenticationMode)
            {
            case PeerAuthenticationMode.None:
                break;

            case PeerAuthenticationMode.Password:
            {
                manager.password = credential.MeshPassword;
                if (String.IsNullOrEmpty(manager.credManager.Password))
                {
                    PeerExceptionHelper.ThrowArgument_InsufficientCredentials(PeerPropertyNames.Password);
                }
                connectionValidator = X509CertificateValidator.None;
            }
            break;

            case PeerAuthenticationMode.MutualCertificate:
            {
                if (manager.credManager.Certificate == null)
                {
                    PeerExceptionHelper.ThrowArgument_InsufficientCredentials(PeerPropertyNames.Certificate);
                }
                if (!credential.PeerAuthentication.TryGetCertificateValidator(out connectionValidator))
                {
                    PeerExceptionHelper.ThrowArgument_InsufficientCredentials(PeerPropertyNames.PeerAuthentication);
                }
            }
            break;
            }
            if (messageAuthentication)
            {
                if (credential.MessageSenderAuthentication != null)
                {
                    if (!credential.MessageSenderAuthentication.TryGetCertificateValidator(out messageValidator))
                    {
                        PeerExceptionHelper.ThrowArgument_InsufficientCredentials(PeerPropertyNames.MessageSenderAuthentication);
                    }
                }
                else
                {
                    PeerExceptionHelper.ThrowArgument_InsufficientCredentials(PeerPropertyNames.MessageSenderAuthentication);
                }
            }
            return(manager);
        }
Exemplo n.º 10
0
        static void ValidateCredentialSettings(PeerAuthenticationMode authenticationMode, bool signMessages, PeerCredential credential)
        {
            X509CertificateValidator validator;

            if (authenticationMode == PeerAuthenticationMode.None && !signMessages)
            {
                return;
            }
            switch (authenticationMode)
            {
            case PeerAuthenticationMode.Password:
            {
                if (String.IsNullOrEmpty(credential.MeshPassword))
                {
                    PeerExceptionHelper.ThrowArgument_InsufficientCredentials(PeerPropertyNames.Password);
                }
            }
            break;

            case PeerAuthenticationMode.MutualCertificate:
            {
                if (credential.Certificate == null)
                {
                    PeerExceptionHelper.ThrowArgument_InsufficientCredentials(PeerPropertyNames.Certificate);
                }
                if (!credential.PeerAuthentication.TryGetCertificateValidator(out validator))
                {
                    PeerExceptionHelper.ThrowArgument_InsufficientCredentials(PeerPropertyNames.PeerAuthentication);
                }
            }
            break;
            }
            if (signMessages)
            {
                if (!credential.MessageSenderAuthentication.TryGetCertificateValidator(out validator))
                {
                    PeerExceptionHelper.ThrowArgument_InsufficientCredentials(PeerPropertyNames.MessageSenderAuthentication);
                }
            }
        }
Exemplo n.º 11
0
        //</snippet25>

        //<snippet26>
        public void snippet26(CalculatorClient client)
        {
            PeerCredential peercred = client.ClientCredentials.Peer;
        }
Exemplo n.º 12
0
 public void Peer()
 {
     ClientCredentials c = new ClientCredentials();
     // FIXME: implement
     PeerCredential peer = c.Peer;
 }
Exemplo n.º 13
0
        public static PeerSecurityManager Create(PeerAuthenticationMode authenticationMode, bool messageAuthentication, PeerSecurityCredentialsManager credman, ChannelProtectionRequirements reqs, XmlDictionaryReaderQuotas readerQuotas)
        {
            PeerSecurityManager      manager    = null;
            X509CertificateValidator none       = null;
            X509CertificateValidator validator2 = null;
            PeerCredential           credential = credman.Credential;

            if ((credential == null) && (credman == null))
            {
                if ((authenticationMode != PeerAuthenticationMode.None) || messageAuthentication)
                {
                    PeerExceptionHelper.ThrowArgument_InsufficientCredentials(PeerPropertyNames.Credentials);
                }
                return(CreateDummy());
            }
            manager = new PeerSecurityManager(authenticationMode, messageAuthentication)
            {
                credManager  = credman,
                password     = credman.Password,
                readerQuotas = readerQuotas
            };
            if (reqs != null)
            {
                manager.protection = new ChannelProtectionRequirements(reqs);
            }
            manager.tokenManager = credman.CreateSecurityTokenManager();
            if (credential != null)
            {
                switch (authenticationMode)
                {
                case PeerAuthenticationMode.Password:
                    manager.password = credential.MeshPassword;
                    if (string.IsNullOrEmpty(manager.credManager.Password))
                    {
                        PeerExceptionHelper.ThrowArgument_InsufficientCredentials(PeerPropertyNames.Password);
                    }
                    none = X509CertificateValidator.None;
                    break;

                case PeerAuthenticationMode.MutualCertificate:
                    if (manager.credManager.Certificate == null)
                    {
                        PeerExceptionHelper.ThrowArgument_InsufficientCredentials(PeerPropertyNames.Certificate);
                    }
                    if (!credential.PeerAuthentication.TryGetCertificateValidator(out none))
                    {
                        PeerExceptionHelper.ThrowArgument_InsufficientCredentials(PeerPropertyNames.PeerAuthentication);
                    }
                    break;
                }
                if (messageAuthentication)
                {
                    if (credential.MessageSenderAuthentication != null)
                    {
                        if (!credential.MessageSenderAuthentication.TryGetCertificateValidator(out validator2))
                        {
                            PeerExceptionHelper.ThrowArgument_InsufficientCredentials(PeerPropertyNames.MessageSenderAuthentication);
                        }
                        return(manager);
                    }
                    PeerExceptionHelper.ThrowArgument_InsufficientCredentials(PeerPropertyNames.MessageSenderAuthentication);
                }
            }
            return(manager);
        }