void InitializeCallStack() { if (OperationContext.Current == null || Header == null) { Header = new SecurityCallStack(); } else { Header = SecurityCallStackContext.Current; } }
void LogCallChain(SecurityCallStack callStack) { //Log call stack here. For example: foreach (SecurityCallFrame call in callStack.Calls) { Trace.Write("Activity ID = " + call.ActivityId + ","); Trace.Write(" Address = " + call.Address + ","); Trace.Write(" Authentication = " + call.Authentication + ","); Trace.Write(" Time = " + call.CallTime + ","); Trace.Write(" Identity = " + call.IdentityName + ","); Trace.Write(" Operation = " + call.Operation + ","); Trace.WriteLine(" Caller = " + call.CallerType); } }
void LogCallChain(SecurityCallStack callStack) { //Log call stack here. For example: foreach(SecurityCallFrame call in callStack.Calls) { Trace.Write("Activity ID = " + call.ActivityId + ","); Trace.Write(" Address = " + call.Address + ","); Trace.Write(" Authentication = " + call.Authentication + ","); Trace.Write(" Time = " + call.CallTime + ","); Trace.Write(" Identity = " + call.IdentityName + ","); Trace.Write(" Operation = " + call.Operation + ","); Trace.WriteLine(" Caller = " + call.CallerType); } }
protected override void PreInvoke(object instance, object[] inputs) { try { SecurityCallStack callStack = SecurityCallStackContext.Current; LogCallChain(callStack); ValidateCallChain(callStack); SignCallChain(callStack); } catch (NullReferenceException) { throw new InvalidOperationException("No security call stack was found. Are you using the right proxy?"); } }
void ValidateCallChain(SecurityCallStack callStack) { //Perform custom validation steps here }
void SignCallChain(SecurityCallStack callStack) { //Digitally sign call stack here }
void ValidateCallChain(SecurityCallStack callStack) { //Perform custom validation steps here. For now: throw new SecurityException("You must provide code to sign the call stack"); }