示例#1
0
        private static AuthorizationPolicy GetPolicy(string policyIdUriString, string matchClaimType, string matchClaimValue)
        {
            Match match = new Match(LiteralMatchExpression.MatchUri, matchClaimType, true);
            EvaluationOperation equalOperation = new EvaluationOperation(EqualOperation.OperationUri, matchClaimValue);
            Rule rule = new Rule(match, equalOperation, true);

            return(new AuthorizationPolicy(rule, new Uri(policyIdUriString)));
        }
示例#2
0
        public static AuthorizationPolicy CreateVirtualRtuCaplPolicy(string hostname, string virtualRtuId, bool publish)
        {
            Uri   policyId = new Uri(UriGenerator.GetVirtualRtuPolicyId(hostname, virtualRtuId, publish));
            Match match    = new Match(LiteralMatchExpression.MatchUri, $"http://{hostname.ToLowerInvariant()}/name");
            EvaluationOperation operation = new EvaluationOperation()
            {
                Type = EqualOperation.OperationUri, ClaimValue = virtualRtuId.ToLowerInvariant()
            };
            Rule rule = new Rule(match, operation);

            return(new AuthorizationPolicy(rule, policyId));
        }
示例#3
0
        public static AuthorizationPolicy CreateDiagnosticsRequestPolicy(string hostname, string virtualRtuId)
        {
            Uri policyId = new Uri(UriGenerator.GetDiagnosticsRequestPolicyId(hostname, virtualRtuId));

            Match match = new Match(LiteralMatchExpression.MatchUri, $"http://{hostname.ToLowerInvariant()}/role");
            EvaluationOperation operation = new EvaluationOperation()
            {
                Type = EqualOperation.OperationUri, ClaimValue = "diagnostics"
            };
            Rule rule = new Rule(match, operation);

            return(new AuthorizationPolicy(rule, policyId));
        }
示例#4
0
        public static AuthorizationPolicy CreateDeviceCaplPolicy(string hostname, string virtualRtuId, string deviceId, bool publish)
        {
            Uri policyId = new Uri(UriGenerator.GetDevicePolicyId(hostname, virtualRtuId, deviceId, publish));

            Match nameMatch = new Match(LiteralMatchExpression.MatchUri, $"http://{hostname.ToLowerInvariant()}/name");
            EvaluationOperation nameOperation = new EvaluationOperation()
            {
                Type = EqualOperation.OperationUri, ClaimValue = deviceId.ToLowerInvariant()
            };
            Rule nameRule = new Rule(nameMatch, nameOperation, true);

            //Match roleMatch = new Match(LiteralMatchExpression.MatchUri, $"http://{hostname.ToLowerInvariant()}/role");
            //EvaluationOperation roleOperation = new EvaluationOperation() { Type = EqualOperation.OperationUri, ClaimValue = moduleId.ToLowerInvariant() };
            //Rule roleRule = new Rule(roleMatch, roleOperation, true);

            //LogicalAndCollection logicalAnd = new LogicalAndCollection();
            //logicalAnd.Add(nameRule);
            //logicalAnd.Add(roleRule);

            //return new AuthorizationPolicy(logicalAnd, policyId);
            return(new AuthorizationPolicy(nameRule, policyId));
        }
示例#5
0
        protected override void ProcessRecord()
        {
            Uri operationUri;

            if (Type == OperationType.BetweenDateTime)
            {
                operationUri = BetweenDateTimeOperation.OperationUri;
            }
            else if (Type == OperationType.Contains)
            {
                operationUri = ContainsOperation.OperationUri;
            }
            else if (Type == OperationType.Equal)
            {
                operationUri = EqualOperation.OperationUri;
            }
            else if (Type == OperationType.EqualDateTime)
            {
                operationUri = EqualDateTimeOperation.OperationUri;
            }
            else if (Type == OperationType.EqualNumeric)
            {
                operationUri = EqualNumericOperation.OperationUri;
            }
            else if (Type == OperationType.Exists)
            {
                operationUri = ExistsOperation.OperationUri;
            }
            else if (Type == OperationType.GreaterThan)
            {
                operationUri = GreaterThanOperation.OperationUri;
            }
            else if (Type == OperationType.GreaterThanDateTime)
            {
                operationUri = GreaterThanOrEqualDateTimeOperation.OperationUri;
            }
            else if (Type == OperationType.GreaterThanOrEqual)
            {
                operationUri = GreaterThanOrEqualOperation.OperationUri;
            }
            else if (Type == OperationType.GreaterThanOrEqualDateTime)
            {
                operationUri = GreaterThanOrEqualDateTimeOperation.OperationUri;
            }
            else if (Type == OperationType.LessThan)
            {
                operationUri = LessThanOperation.OperationUri;
            }
            else if (Type == OperationType.LessThanDateTime)
            {
                operationUri = LessThanOrEqualDateTimeOperation.OperationUri;
            }
            else if (Type == OperationType.LessThanOrEqual)
            {
                operationUri = LessThanOrEqualOperation.OperationUri;
            }
            else if (Type == OperationType.LessThanOrEqualDateTime)
            {
                operationUri = LessThanOrEqualDateTimeOperation.OperationUri;
            }
            else if (Type == OperationType.NotEqual)
            {
                operationUri = NotEqualOperation.OperationUri;
            }
            else
            {
                throw new ArgumentOutOfRangeException("Type");
            }

            EvaluationOperation operation = new EvaluationOperation(operationUri, Value);

            WriteObject(operation);
        }