Exemplo n.º 1
0
        /// <summary>
        /// Pings specified broker
        /// </summary>
        /// <param name="sessionID">sessionID of broker to ping</param>
        public bool PingBroker(string sessionId)
        {
            try
            {
                this.CheckAccess(sessionId);

                if (!SoaHelper.CheckWindowsIdentity(OperationContext.Current))
                {
                    ThrowHelper.ThrowSessionFault(SOAFaultCode.AccessDenied_BrokerLauncher, SR.AccessDenied_BrokerLauncher);
                }

                string uniqueId;
                return(this.brokerManager.DoesBrokerExist(sessionId, out uniqueId));
            }
            catch (Exception e)
            {
                TraceHelper.TraceEvent(sessionId, System.Diagnostics.TraceEventType.Error, "[BrokerLauncher] Ping Broker {0} failed: {1}", sessionId, e);
                throw ExceptionHelper.ConvertExceptionToFaultException(e);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Called to auth each request
        /// </summary>
        /// <param name="operationContext">Operation's context</param>
        /// <returns>pass validation or not</returns>
        protected override bool CheckAccessCore(OperationContext operationContext)
        {
            if (this.enable == false)
            {
                RuntimeTraceHelper.TraceEvent(
                    this.jobId,
                    TraceEventType.Verbose,
                    "[HpcServiceHost]: BrokerNodeAuthManager is disabled.");
                return(true);
            }

            WindowsIdentity callerIdentity = null;
            bool            result         = SoaHelper.CheckWindowsIdentity(operationContext, out callerIdentity);

            if (result && callerIdentity == null)
            {
                // this code path is for Azure.
                return(true);
            }

            if (callerIdentity == null || !result || operationContext.ServiceSecurityContext.IsAnonymous)
            {
                RuntimeTraceHelper.TraceEvent(this.jobId, TraceEventType.Warning, "[HpcServiceHost]: Access denied by BrokerNodeAuthManager. WindowsIdeneity is not recognized.");
                return(false);
            }

            RuntimeTraceHelper.TraceEvent(this.jobId, TraceEventType.Verbose, "[HpcServiceHost]: received request from {0}", callerIdentity.Name);

            // if this is calling from local
            if (callerIdentity.IsSystem)
            {
                return(true);
            }

            // Bug 11378: Authenticate job owner also for inprocess broker
            if (callerIdentity.Name.Equals(this.jobOwnerUserName, StringComparison.InvariantCultureIgnoreCase))
            {
                RuntimeTraceHelper.TraceEvent(
                    this.jobId,
                    TraceEventType.Verbose,
                    "[HpcServiceHost]: Authenticate job owner {0} for inprocess broker.",
                    this.jobOwnerUserName);

                return(true);
            }

            // is this call from a BN
            if (SessionBrokerNodes.IsSessionBrokerNode(callerIdentity, this.jobId))
            {
                return(true);
            }

            RuntimeTraceHelper.TraceEvent(
                this.jobId,
                TraceEventType.Warning,
                "[HpcServiceHost]: {0}/SID={1} is not a broker node",
                callerIdentity.Name,
                callerIdentity.User.Value);

            // Last see if the caller is the 'run as' user for the process. This is mainly needed for diag tests
            if (callerIdentity.User == this.allowedUser.User)
            {
                return(true);
            }
            else
            {
                RuntimeTraceHelper.TraceEvent(
                    this.jobId,
                    TraceEventType.Warning,
                    "[HpcServiceHost]: Access denied by BrokerNodeAuthManager. {0} is not allowed.",
                    callerIdentity.User);
                return(false);
            }
        }