예제 #1
0
 //- @Invoke -//
 public Object Invoke(Object instance, Object[] inputs, out Object[] outputs)
 {
     //+ authorization
     try
     {
         if (this.PermissionLevel == Minima.Service.PermissionLevel.Blog)
         {
             String blogGuid = MinimaMessageHeaderHelper.GetBlogGuidFromMessageHeader();
             SecurityValidator.ValidateBlogPermission(this.PermissionRequired, blogGuid);
         }
         else if (this.PermissionLevel == Minima.Service.PermissionLevel.System)
         {
             SecurityValidator.ValidateSystemPermission(this.PermissionRequired);
         }
     }
     catch (SecurityException exception)
     {
         FaultThrower.Throw <SecurityException>(exception);
     }
     catch (ArgumentException exception)
     {
         FaultThrower.Throw <ArgumentException>(exception);
     }
     //+
     return(InnerOperationInvoker.Invoke(instance, inputs, out outputs));
 }
예제 #2
0
        public object Invoke(object instance, object[] inputs, out object[] outputs)
        {
            if (OperationCache == null)
            {
                return(InnerOperationInvoker.Invoke(instance, inputs, out outputs));
            }

            OperationCacheKey   key   = new OperationCacheKey(action, inputs);
            OperationCacheValue value = OperationCache.Lookup(key);

            // if it's not in the cache, invoke and then add to the cache.
            if (value == null)
            {
                Console.WriteLine("Not in the cache. Creating new and caching.");
                object returnValue = InnerOperationInvoker.Invoke(instance, inputs, out outputs);
                value = new OperationCacheValue(outputs, returnValue);
                OperationCache.Insert(key, value);
                return(returnValue);
            }

            // otherwise, just return the data
            Console.WriteLine("In cache; returning cache instance.");
            outputs = value.Outputs;
            return(value.ReturnValue);
        }
예제 #3
0
        //- @Invoke -//
        public Object Invoke(Object instance, Object[] inputs, out Object[] outputs)
        {
            // Security by passed temporarily. Need to test it properly.

            /*   //+ authorization
             * MessageHeaders messageHeadersElement = OperationContext.Current.IncomingMessageHeaders;
             * Int32 id = messageHeadersElement.FindHeader("UserName", "") + messageHeadersElement.FindHeader("Password", "");
             * if (id > -1)
             * {
             *     String username = messageHeadersElement.GetHeader<String>("UserName", "");
             *     String password = messageHeadersElement.GetHeader<String>("Password", "");
             *     //  SecurityValidator.Authenticate(username, password);
             *
             *     //+
             *     return InnerOperationInvoker.Invoke(instance, inputs, out outputs);
             * }
             *
             * FaultDetail faultDetail = new FaultDetail
             * {
             *     Type = "Unauthorized access of the service",
             *     ErrorCode = 63873928
             * };     //+ throw
             *
             * throw new FaultException<FaultDetail>(faultDetail, "Unauthorized access of the service");      */

            return(InnerOperationInvoker.Invoke(instance, inputs, out outputs));
        }