Beispiel #1
0
 /// <summary>
 /// Submits an approval response message for the pending approval using
 /// the specified endpoint address and the default approval endpoint
 /// configuration name (ServiceMultipleTokenBinding_ResourceFactory).
 /// Use this overload e.g. if you need to specify explicitly a service
 /// principal name.
 /// </summary>
 /// <param name="approval">The approval object for which to submit an approval response.</param>
 /// <param name="isApproved">True when to approve the approval. False to reject it.</param>
 /// <param name="approvalConfiguration">The approval endpoint.</param>
 public void Approve(
     RmApproval approval,
     bool isApproved,
     EndpointAddress address)
 {
     Approve(approval, isApproved, address, DefaultApprovalConfiguration);
 }
Beispiel #2
0
        public void Approve(RmApproval approval, bool isApproved, EndpointAddress address)
        {
            Constants.Bindings bindings = new Constants.Bindings();

            WSResourceFactoryClient approvalClient = new WSResourceFactoryClient(bindings.ServiceMultipleTokenBinding_ResourceFactory, address);

            approvalClient.ClientCredentials.Windows.ClientCredential = this.ClientCredential;
            approvalClient.Approve(approval, isApproved);
        }
Beispiel #3
0
        public void Approve(RmApproval approval, bool isApproved, EndpointAddress address)
        {
            //try
            //{
            //    _defaultClient.Approve(approval, isApproved, address);
            //}
            //catch (Exception e)
            //{
            //    HandleError(e);
            //}

            _defaultClient.Approve(approval, isApproved, address);
        }
Beispiel #4
0
        public void Approve(RmApproval approval, bool isApproved)
        {
            //try
            //{
            //    _defaultClient.Approve(approval, isApproved);
            //}
            //catch (Exception e)
            //{
            //    HandleError(e);
            //}

            _defaultClient.Approve(approval, isApproved);
        }
Beispiel #5
0
        /// <summary>
        /// Submits an approval response message for the pending approval using
        /// the specified approval endpoint configuration name.
        /// </summary>
        /// <param name="approval">The approval object for which to submit an approval response.</param>
        /// <param name="isApproved">True when to approve the approval. False to reject it.</param>
        /// <param name="approvalConfiguration">The approval endpoint configuration name.</param>
        public void Approve(
            RmApproval approval,
            bool isApproved,
            string approvalConfiguration)
        {
            // Create a transfer client specifying the configuration name and
            // the approval endpoint address
            WsTransferFactoryClient approvalClient = new WsTransferFactoryClient(
                approvalConfiguration,
                approval.ApprovalEndpointAddress);

            // set the credentials in the new client
            approvalClient.ClientCredentials.Windows.ClientCredential = this.ClientCredential;
            // approve the request
            approvalClient.Approve(approval, isApproved);
        }
Beispiel #6
0
        public string Approve(RmApproval approval, EndpointIdentity identity, bool isApproved)
        {
            if (approval == null)
            {
                return("Approval cannot be null");
            }

            EndpointAddress address = new EndpointAddress(
                new Uri(approval.ApprovalEndpointAddress),
                identity);

            try
            {
                this.Client.Approve(approval, isApproved, address);
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }

            return(string.Empty);
        }
Beispiel #7
0
        public bool Approve(RmApproval approval, EndpointIdentity identity)
        {
            if (approval == null)
            {
                return(false);
            }

            EndpointAddress address = new EndpointAddress(
                new Uri(approval.ApprovalEndpointAddress),
                identity);

            try
            {
                this.Client.Approve(approval, true, address);
            }
            catch (Exception exc)
            {
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// Submits an approval response message for the pending approval.
        /// </summary>
        /// <param name="approval">The approval object for which to submit an approval response.</param>
        /// <param name="isApproved">True when to approve the approval. False to reject it.</param>
        /// <returns>Returns true if the approval response was accepted.</returns>
        public void Approve(RmApproval approval, bool isApproved)
        {
            // the AuthZ endpoint does not use the MS-WSTIM extensions.
            // Rather than create a whole new object model or adapt the serializer, I construct the XML manually:
            System.Xml.XmlDocument         doc       = new System.Xml.XmlDocument();
            System.Xml.XmlNamespaceManager nsManager = new System.Xml.XmlNamespaceManager(doc.NameTable);
            nsManager.AddNamespace(Constants.Rm.Prefix, Constants.Rm.Namespace);

            System.Xml.XmlElement approvalResponseElement = doc.CreateElement("rm:ApprovalResponse", Constants.Rm.Namespace);
            System.Xml.XmlElement approvalElement         = doc.CreateElement("rm:Approval", Constants.Rm.Namespace);
            approvalElement.InnerText = approval.ObjectID.Value;
            approvalResponseElement.AppendChild(approvalElement);

            System.Xml.XmlElement approvalDecisionElement = doc.CreateElement("rm:Decision", Constants.Rm.Namespace);
            approvalDecisionElement.InnerText = isApproved ? @"Approved" : @"Rejected";
            approvalResponseElement.AppendChild(approvalDecisionElement);

            System.Xml.XmlElement objectTypenElement = doc.CreateElement("rm:ObjectType", Constants.Rm.Namespace);
            objectTypenElement.InnerText = "ApprovalResponse";
            approvalResponseElement.AppendChild(objectTypenElement);

            doc.AppendChild(approvalResponseElement);

            Message requestMessage = Message.CreateMessage(MessageVersion.Default, Constants.WsTransfer.CreateAction, approvalResponseElement);

            if (String.IsNullOrEmpty(approval.WorkflowInstance.Value))
            {
                throw new InvalidOperationException("The approval does not have an active workflow activity.");
            }

            ContextMessageHeader ctx = new ContextMessageHeader(approval.WorkflowInstance.Value);

            requestMessage.Headers.Add(ctx);

            // send the create request. If an error occurs, an exception is thrown.
            Message responseMessage = Create(requestMessage);
        }
Beispiel #9
0
        public List <RmApproval> GetApprovalByQuery(string query, string[] attributes)
        {
            List <RmResource> resourceList = Base_GetResourceByQuery(RmApproval.StaticResourceType(), query, attributes);

            return(resourceList.ConvertAll <RmApproval>(delegate(RmResource r) { return r as RmApproval; }));
        }
Beispiel #10
0
        public List <RmApproval> GetApprovalByAttribute(string attributeName, string value, OperationType operation, string[] attributes)
        {
            List <RmResource> resourceList = Base_GetResourceByAttribute(RmApproval.StaticResourceType(), attributeName, value, operation, attributes);

            return(resourceList.ConvertAll <RmApproval>(delegate(RmResource r) { return r as RmApproval; }));
        }
Beispiel #11
0
 public RmApproval GetApprovalById(string objectId, string[] attributes)
 {
     return(Base_GetResourceById(RmApproval.StaticResourceType(), objectId, attributes) as RmApproval);
 }
Beispiel #12
0
 public RmApproval GetApprovalByDisplayName(string displayName, string[] attributes)
 {
     return(Base_GetResourceByDisplayName(RmApproval.StaticResourceType(), displayName, attributes) as RmApproval);
 }
Beispiel #13
0
 /// <summary>
 /// Submits an approval response message for the pending approval using
 /// the default approval endpoint configuration name
 /// (ServiceMultipleTokenBinding_ResourceFactory).
 /// </summary>
 /// <param name="approval">The approval object for which to submit an approval response.</param>
 /// <param name="isApproved">True when to approve the approval. False to reject it.</param>
 /// <returns>Returns true if the approval response was accepted.</returns>
 public void Approve(
     RmApproval approval,
     bool isApproved)
 {
     Approve(approval, isApproved, DefaultApprovalConfiguration);
 }