<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="ActivityContextLoggingEnabled" value="true" />
    <add key="WriteStackTraceOnResponse" value="true" />
    <add key="OAuthHttpModule.Profiles" value="S2SAppOnly"/>
    <add key="OAuthHttpModule.RunningAtBackend" value="true" />
  </appSettings>
  <system.serviceModel>
    <services>
      <service name="Microsoft.Exchange.PushNotifications.Server.Services.PushNotificationService" behaviorConfiguration="serviceBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="net.pipe://localhost" />
          </baseAddresses>
        </host>
        <endpoint name="PushNotifications"
                  address=""
                  binding="netNamedPipeBinding"
                  bindingConfiguration="ServiceBinding"
                  contract="Microsoft.Exchange.PushNotifications.IPublisherServiceContract" />
        <endpoint name="OutlookPushNotifications"
                  address=""
                  binding="netNamedPipeBinding"
                  bindingConfiguration="ServiceBinding"
                  contract="Microsoft.Exchange.PushNotifications.IOutlookPublisherServiceContract" />
        <endpoint name="PublishLocalUserNotifications"
                  address=""
                  binding="netNamedPipeBinding"
                  bindingConfiguration="ServiceBinding"
                  contract="Microsoft.Exchange.PushNotifications.ILocalUserNotificationPublisherServiceContract" />
        <endpoint name="CreateHub"
                  address=""
                  binding="netNamedPipeBinding"
                  bindingConfiguration="ServiceBinding"
                  contract="Microsoft.Exchange.PushNotifications.IAzureHubCreationServiceContract" />
        <endpoint name="IssueRegistrationChallenge"
                  address=""
                  binding="netNamedPipeBinding"
                  bindingConfiguration="ServiceBinding"
                  contract="Microsoft.Exchange.PushNotifications.IAzureChallengeRequestServiceContract" />
        <endpoint name="DeviceRegistration"
                  address=""
                  binding="netNamedPipeBinding"
                  bindingConfiguration="ServiceBinding"
                  contract="Microsoft.Exchange.PushNotifications.IAzureDeviceRegistrationServiceContract" />
        <endpoint name="OnPremPushNotifications"
                  address=""
                  behaviorConfiguration="HttpEndpointBehavior"
                  binding="webHttpBinding"
                  bindingConfiguration="SecureBinding"
                  contract="Microsoft.Exchange.PushNotifications.IOnPremPublisherServiceContract" />
        <endpoint name="PublishUserNotification"
                  address="Publish"
                  behaviorConfiguration="PublishUserNotificationBehavior"
                  binding="webHttpBinding"
                  bindingConfiguration="SecureBinding"
                  contract="Microsoft.Exchange.PushNotifications.IRemoteUserNotificationPublisherServiceContract" />
      </service>
    </services>
    <bindings>
      <netNamedPipeBinding>
        <binding name="ServiceBinding"
                 maxBufferSize="3276800"
                 maxReceivedMessageSize="3276800">
        </binding>
      </netNamedPipeBinding>
      <webHttpBinding>
        <binding name="SecureBinding"
                 maxBufferSize="3276800"
                 maxReceivedMessageSize="3276800">
          <security mode="Transport">
            <!-- Because the BackendRehydrationModule will not produce a Windows authenticated user we have to disable 
                       the clientCredentialType, note that the custom AuthorizationManager will enforce the request is
                       appropriately authenticated -->
            <transport clientCredentialType="None" />
          </security>
        </binding>
      </webHttpBinding>
      <netTcpBinding>
        <binding name="SecureBinding" maxConnections="100000">
          <security mode="Transport">
            <transport protectionLevel="EncryptAndSign" />
          </security>
        </binding>
      </netTcpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="serviceBehavior">
          <serviceDebug includeExceptionDetailInFaults="false" />
          <serviceAuthorization
            principalPermissionMode="Custom"
            serviceAuthorizationManagerType="Microsoft.Exchange.PushNotifications.Server.Wcf.PushNotificationAuthorizationManager, Microsoft.Exchange.PushNotifications.Server, Version=15.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
            <authorizationPolicies>
              <add policyType="Microsoft.Exchange.PushNotifications.Server.Wcf.PushNotificationAuthorizationPolicy, Microsoft.Exchange.PushNotifications.Server, Version=15.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
            </authorizationPolicies>
          </serviceAuthorization>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="HttpEndpointBehavior">
          <webHttp/>
        </behavior>
        <behavior name="PublishUserNotificationBehavior">
          <PublishUserNotificationBehaviorExt/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <extensions>
      <behaviorExtensions>
        <add name="PublishUserNotificationBehaviorExt"
             type="Microsoft.Exchange.PushNotifications.Server.Wcf.PublishUserNotificationBehaviorExtension, Microsoft.Exchange.PushNotifications.Server, Version=15.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      </behaviorExtensions>
    </extensions>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" minFreeMemoryPercentageToActivateService="0" />

    <client>
      <endpoint address="net.tcp://localhost:1009/Microsoft.Exchange.Security.Authentication.FederatedAuthService" binding="netTcpBinding" bindingConfiguration="SecureBinding" contract="Microsoft.Exchange.Security.Authentication.FederatedAuthService.IAuthService" name="Microsoft.Exchange.Security.Authentication.FederatedAuthService" />
    </client>
  </system.serviceModel>
  <system.webServer>
    <modules>
      <add type="Microsoft.Exchange.Security.OAuth.OAuthHttpModule" name="OAuthAuthModule" />
      <add type="Microsoft.Exchange.Security.Authentication.BackendRehydrationModule" name="BackendRehydrationModule" />
    </modules>
    <handlers>
      <add verb="GET" path="mowapendingget.ashx" type="Microsoft.Exchange.PushNotifications.Server.PendingGet.MowaPendingGetRequestHandler, Microsoft.Exchange.PushNotifications.Server" name="MowaPendingGetRequestHandler" preCondition="managedHandler" />
    </handlers>
  </system.webServer>
  <system.web>
    <compilation defaultLanguage="c#" debug="false">
      <assemblies>
        <add assembly="Microsoft.Exchange.Security, Version=15.0.0.0, Culture=neutral, publicKeyToken=31bf3856ad364e35" />
      </assemblies>
    </compilation>
  </system.web>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <linkedConfiguration href="file://%ExchangeInstallDir%ClientAccess\SharedWebConfig.config"/>
  </assemblyBinding>
</configuration>