/// <summary>
            /// Activates the session and binds it to the current secure channel.
            /// </summary>
            /// <param name="context"></param>
            /// <param name="clientSignature"></param>
            /// <param name="clientSoftwareCertificates"></param>
            /// <param name="userIdentityToken"></param>
            /// <param name="userTokenSignature"></param>
            /// <param name="serverNonce"></param>
            /// <returns></returns>
            internal bool Activate(RequestContextModel context, SignatureData clientSignature,
                                   List <SoftwareCertificate> clientSoftwareCertificates, ExtensionObject userIdentityToken,
                                   SignatureData userTokenSignature, byte[] serverNonce)
            {
                lock (_lock) {
                    var changed = ValidateActivation(context, clientSignature, clientSoftwareCertificates,
                                                     userIdentityToken, userTokenSignature);
                    if (!_activated)
                    {
                        _activated = true;
                    }
                    else
                    {
                        // Reactivation = bind to the new secure channel.
                        _secureChannelId = context.ChannelContext.SecureChannelId;
                    }

                    // update server nonce.
                    _serverNonce = serverNonce;
                    // build list of signed certificates for audit event.
                    var signedSoftwareCertificates = new List <SignedSoftwareCertificate>();
                    if (clientSoftwareCertificates != null)
                    {
                        foreach (var softwareCertificate in clientSoftwareCertificates)
                        {
                            var item = new SignedSoftwareCertificate {
                                CertificateData = softwareCertificate.SignedCertificate.RawData
                            };
                            signedSoftwareCertificates.Add(item);
                        }
                    }
                    _timeoutTimer.Change(_timeout, Timeout.InfiniteTimeSpan);
                    return(changed);
                }
            }
Example #2
0
        /// <summary>
        /// Activates the session and binds it to the current secure channel.
        /// </summary>
        public bool Activate(
            OperationContext context,
            List <SoftwareCertificate> clientSoftwareCertificates,
            UserIdentityToken identityToken,
            IUserIdentity identity,
            IUserIdentity effectiveIdentity,
            StringCollection localeIds,
            byte[]                    serverNonce)
        {
            lock (m_lock)
            {
                // update user identity.
                bool changed = false;

                if (identityToken != null)
                {
                    if (UpdateUserIdentity(identityToken, identity, effectiveIdentity))
                    {
                        changed = true;
                    }
                }

                // update local ids.
                if (UpdateLocaleIds(localeIds))
                {
                    changed = true;
                }

                if (!m_activated)
                {
                    // toggle the activated flag.
                    m_activated = true;

                    // save the software certificates.
                    m_softwareCertificates = clientSoftwareCertificates;

                    TraceState("FIRST ACTIVATION");
                }
                else
                {
                    // bind to the new secure channel.
                    m_secureChannelId = context.ChannelContext.SecureChannelId;

                    TraceState("RE-ACTIVATION");
                }

                // update server nonce.
                m_serverNonce = serverNonce;

                // build list of signed certificates for audit event.
                List <SignedSoftwareCertificate> signedSoftwareCertificates = new List <SignedSoftwareCertificate>();

                if (clientSoftwareCertificates != null)
                {
                    foreach (SoftwareCertificate softwareCertificate in clientSoftwareCertificates)
                    {
                        SignedSoftwareCertificate item = new SignedSoftwareCertificate();
                        item.CertificateData = softwareCertificate.SignedCertificate.GetRawCertData();
                        signedSoftwareCertificates.Add(item);
                    }
                }

                // raise an audit event.
                ServerSystemContext systemContext = m_server.DefaultSystemContext.Copy(context);
                ReportAuditActivateSessionEvent(systemContext);

                // update the contact time.
                lock (m_diagnostics)
                {
                    m_diagnostics.ClientLastContactTime = DateTime.UtcNow;
                }

                // indicate whether the user context has changed.
                return(changed);
            }
        }
Example #3
0
 /// <summary>
 /// Handles an error when validating software certificates provided by the server.
 /// </summary>
 protected virtual void OnSoftwareCertificateError(SignedSoftwareCertificate signedCertificate, ServiceResult result)
 {
     throw new ServiceResultException(result);
 }
        /// <summary>
        /// Activates the session and binds it to the current secure channel.
        /// </summary>
        public bool Activate(
            OperationContext          context,
            List<SoftwareCertificate> clientSoftwareCertificates,
            UserIdentityToken         identityToken,
            IUserIdentity             identity,
            IUserIdentity             effectiveIdentity,
            StringCollection          localeIds,
            byte[]                    serverNonce)
        {
            lock (m_lock)
            {
                // update user identity.
                bool changed = false;

                if (identityToken != null)
                {
                    if (UpdateUserIdentity(identityToken, identity, effectiveIdentity))
                    {
                        changed = true;
                    }
                }
                
                // update local ids.
                if (UpdateLocaleIds( localeIds ))
                {
                    changed = true;
                }

                if (!m_activated)
                {
                    // toggle the activated flag.
                    m_activated = true;

                    // save the software certificates.
                    m_softwareCertificates = clientSoftwareCertificates;

                    TraceState("FIRST ACTIVATION");
                }
                else
                {
                    // bind to the new secure channel.
                    m_secureChannelId = context.ChannelContext.SecureChannelId;      

                    TraceState("RE-ACTIVATION");  
                }

                // update server nonce.
                m_serverNonce = serverNonce;
                    
                // build list of signed certificates for audit event.
                List<SignedSoftwareCertificate> signedSoftwareCertificates = new List<SignedSoftwareCertificate>();

                if (clientSoftwareCertificates != null)
                {
                    foreach (SoftwareCertificate softwareCertificate in clientSoftwareCertificates)
                    {
                        SignedSoftwareCertificate item = new SignedSoftwareCertificate();
                        item.CertificateData = softwareCertificate.SignedCertificate.RawData;
                        signedSoftwareCertificates.Add(item);
                    }
                }

                // raise an audit event.
                ServerSystemContext systemContext = m_server.DefaultSystemContext.Copy(context);
                ReportAuditActivateSessionEvent(systemContext);

                // update the contact time.
                lock (m_diagnostics)
                {
                    m_diagnostics.ClientLastContactTime = DateTime.UtcNow;
                }

                // indicate whether the user context has changed.
                return changed;
            }
        }