ServiceSecurityAuditBehavior(ServiceSecurityAuditBehavior behavior)
 {
     this.auditLogLocation                = behavior.auditLogLocation;
     this.suppressAuditFailure            = behavior.suppressAuditFailure;
     this.serviceAuthorizationAuditLevel  = behavior.serviceAuthorizationAuditLevel;
     this.messageAuthenticationAuditLevel = behavior.messageAuthenticationAuditLevel;
 }
 ServiceSecurityAuditBehavior(ServiceSecurityAuditBehavior behavior)
 {
     this.auditLogLocation = behavior.auditLogLocation;
     this.suppressAuditFailure = behavior.suppressAuditFailure;
     this.serviceAuthorizationAuditLevel = behavior.serviceAuthorizationAuditLevel;
     this.messageAuthenticationAuditLevel = behavior.messageAuthenticationAuditLevel;
 }
Ejemplo n.º 3
0
        public static void Main(string[] args)
        {
            Uri address = new Uri("http://localhost:8001/TradeService");
            WSHttpBinding binding = new WSHttpBinding();
            Type contract = typeof(ExchangeService.ITradeService);
            ServiceHost host = new ServiceHost(typeof(TradeService));
            host.AddServiceEndpoint(contract, binding, address);

            // Add Auditing to the service
            ServiceSecurityAuditBehavior auditProvider =
                host.Description.Behaviors.Find<ServiceSecurityAuditBehavior>();
            if (auditProvider == null)
            {
                auditProvider = new ServiceSecurityAuditBehavior();
            }
            auditProvider.AuditLogLocation = AuditLogLocation.Application;
            auditProvider.MessageAuthenticationAuditLevel =
                AuditLevel.SuccessOrFailure;
            auditProvider.ServiceAuthorizationAuditLevel =
                AuditLevel.SuccessOrFailure;
            host.Description.Behaviors.Add(auditProvider);
            host.Open();
            Console.WriteLine("The WCF Management trading service is available.");
            Console.ReadKey();
        }
 protected internal override object CreateBehavior()
 {
     ServiceSecurityAuditBehavior behavior = new ServiceSecurityAuditBehavior();
     behavior.AuditLogLocation = this.AuditLogLocation;
     behavior.SuppressAuditFailure = this.SuppressAuditFailure;
     behavior.ServiceAuthorizationAuditLevel = this.ServiceAuthorizationAuditLevel;
     behavior.MessageAuthenticationAuditLevel = this.MessageAuthenticationAuditLevel;
     return behavior;
 }
      void IServiceBehavior.Validate(ServiceDescription description,ServiceHostBase serviceHostBase)
      {
         m_SecurityBehavior.UseAspNetProviders = UseAspNetProviders;
         m_SecurityBehavior.ApplicationName = ApplicationName;
         m_SecurityBehavior.ImpersonateAll = ImpersonateAll;

         m_SecurityBehavior.Validate(description,serviceHostBase);

         if(SecurityAuditEnabled)
         {
            ServiceSecurityAuditBehavior securityAudit = serviceHostBase.Description.Behaviors.Find<ServiceSecurityAuditBehavior>();
            if(securityAudit == null)
            {
               securityAudit = new ServiceSecurityAuditBehavior();
               securityAudit.MessageAuthenticationAuditLevel = AuditLevel.SuccessOrFailure;
               securityAudit.ServiceAuthorizationAuditLevel = AuditLevel.SuccessOrFailure;
               serviceHostBase.Description.Behaviors.Add(securityAudit);
            }
         }
      }