Generate and Validate Operations

Last modified 13 Mar 2024 13:32 +01:00

Description

Request to validate or generate a value.

Request

For the request use the HTTP POST for the request.

Generate operation
POST http://localhost:8080/midpoint/ws/rest/generate
Validate operation
POST http://localhost:8080/midpoint/ws/rest/validate

Headers

Regarding authorization type, the "Basic" Authorization header should be used.

Authorization header example replace {Base64EncodedCredentials} with the encoded credentials
Authorization: Basic {Base64EncodedCredentials}

Another header would be the Content-Type Header.

Content-Type header example, other media types are supported as well
"Content-Type: application/json"

You might need to specify the accepted type of content in case you are interested in a format different from xml (default)

Accept type header example, other media types are supported as well
"Accept: application/json"
For supported media types please refer to the following section of the documentation

Supported Media Types

Body

The body should contain a payload consisting of a policyItemDefinition type of object. Based on the use case you might need to specify which value policy should be used for the operation or which item should be the target of the operation. Please see the examples below.

Options

There are no supported operation options for this type of operation.

Response

Error code Meaning

1xx

Information. Stay tuned, operation is in progress.

2xx

Success. Operation finished successfully. There are two custom codes:

  • 250 for partial error which means that during processing some error occurred but some changes was executed.

  • 240 for handled error which means that there was originally error, but midPoint was able to fix this using its consistency mechanism.

In this two cases, midPoint returns the OperationResult where there details of executed operations can be found.

3xx

Redirection or "in progress". This is returned mostly to indicate two cases:

  • Operation has finished, but the results are not in this resource. Redirection is issues to point the client to the results. Typical example is creation of an object with POST to a collection web resource. In this case a new object is created, new URI is assigned and the client is redirected to this URI. Retrieving that URI provides created object and 200 status code, indicating that the operation is finished.

  • Operation is in progress (asynchronous operation). In this case midPoint API redirects the client to a task object that can be used to track progress of the operation.

4xx

Client errors. The client has sent request that cannot be processed. This indicates usual situation that are well handled by the midPoint code. Maybe the client request to create conflicting object, delete non-existent object, modification that violates the schema and so on. The OperationResult structure is usually provided in the response to provide more details about the situation.

5xx

Server errors. Situations that the server cannot handle and where the cause is unknown. This usually means bugs in the code, insufficient resources such as RAM or disk space, unforeseen failures in the infrastructure and so on. The OperationResult structure might or might not be provided in this case. Some errors are so severe that the structured error information might not be available.

Status codes and the indication of errors and asynchronous processing applies uniformly to all midPoint web resources (both RESTful and RPC).

Access Authorization

The interface authorization needed for executing this type of request. The authorization is needed to access the specific part of the interface. For more information please see this page.

  • http://midpoint.evolveum.com/xml/ns/public/security/authorization-rest-3#rpcGenerateValue

  • http://midpoint.evolveum.com/xml/ns/public/security/authorization-rest-3#rpcValidateValue

Model Authorization

The model authorization for the specific action. This authorization is needed to request/execute the concrete action. The examples are usually quite broad, and the actions can be additionally specified for a more fine-grained authorization. For more information please see this page.

No model authorizations needed in this case.

Examples

In our examples we are authenticating with the credentials, name "administrator" and password "y0uR_P455woR*d" on a localhost instance running on port 8080.

For some help regarding the REST examples please see this link:

Validate Value on Input Procedure Call
curl --user administrator:y0uR_P455woR*d \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-X POST http://localhost:8080/midpoint/ws/rest/rpc/validate \
-v \
--data-binary @./samples/rest/policy-items-password-validate.json
Show data source example for "Validate value on input procedure call" | GitHub
{
  "policyItemsDefinition": {
    "policyItemDefinition": {
      "value": "5ecr3t5AbC",
      "valuePolicyRef" :{
        "oid": "00000000-0000-0000-0000-000000000003"
      }
    }
  }
}

The response is an HTTP 200 code in case of success with a response body.

Example Output of "Validate value on input procedure call" example

The example is simplified, some properties were removed to keep the example output "short". This example does not contain all possible properties of this object type.

{
  "@ns" : "http://prism.evolveum.com/xml/ns/public/types-3",
  "object" : {
    "@type" : "http://midpoint.evolveum.com/xml/ns/public/common/api-types-3#PolicyItemsDefinitionType",
    "policyItemDefinition" : [ {
      "valuePolicyRef" : {
        "@type" : "c:ObjectReferenceType",
        "oid" : "00000000-0000-0000-0000-000000000003"
      },
      "value" : "5ecr3t5AbC",
      "result" : {
        "operation" : "validateValue",
        "status" : "success",
        "importance" : "normal",
        "start" : "",
        "end" : "",
        "microseconds" : ,
        "invocationId" : ,
        "token" : ,
        "partialResults" : [ {}, {
          "operation" : "com.evolveum.midpoint.model.api.ModelInteractionService.validateValue.value",
          "status" : "success",
          "importance" : "normal",
          "start" : "",
          "end" : "",
          "microseconds" : ,
          "invocationId" : ,
          "params" : {
            "entry" : [ {
              "@ns" : "http://midpoint.evolveum.com/xml/ns/public/common/common-3",
              "paramValue" : {
                "@type" : "xsd:string",
                "@value" : "5ecr3t5AbC"
              },
              "key" : "valueToValidate"
            } ]
          },
          "token" : ,
          "partialResults" : [ {
            "operation" : "com.evolveum.midpoint.model.common.stringpolicy.ObjectValuePolicyEvaluator.validateValue",
            "status" : "success",
            "importance" : "",
            "start" : "",
            "end" : "",
            "microseconds" : ,
            "invocationId" : ,
            "token" : ,
            "partialResults" : [ {
              "operation" : "com.evolveum.midpoint.model.common.stringpolicy.ValuePolicyProcessor.stringPolicyValidation",
              "status" : "success",
              "importance" : "normal",
              "start" : "",
              "end" : "",
              "microseconds" : ,
              "invocationId" : ,
              "params" : {
                "entry" : [ {
                  "@ns" : "http://midpoint.evolveum.com/xml/ns/public/common/common-3",
                  "paramValue" : {
                    "@type" : "xsd:string",
                    "@value" : "Default Password Policy"
                  },
                  "key" : "policyName"
                } ]
              },
              "token" : 1000000000000005240,
              "partialResults" : [ {}, {
                "operation" : "Tested limitation: Lowercase characters",
                "status" : "success",
                "importance" : "normal",
                "end" : "",
                "token" :
              }, {
                "operation" : "Tested limitation: Uppercase characters",
                "status" : "success",
                "importance" : "normal",
                "end" : "",
                "token" :
              }, {
                "operation" : "Tested limitation: Numeric characters",
                "status" : "success",
                "importance" : "normal",
                "end" : "",
                "token" :
              }, {
                "operation" : "Tested limitation: Special characters",
                "status" : "success",
                "importance" : "normal",
                "end" : "",
                "token" :
              } ]
            } ]
          } ]
        } ]
      }
    } ]
  }
}
Generate Value on Input Procedure Call
curl --user administrator:y0uR_P455woR*d \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-X POST http://localhost:8080/midpoint/ws/rest/rpc/generate \
-v \
--data-binary @./samples/rest/policy-items-password-rpc-generate.json
Show data source example for "Generate value on input procedure call" | GitHub

By using an empty policyItemDefinition, the default value policy is used.

{
  "policyItemsDefinition": {
    "policyItemDefinition": {
    }
  }
}

The response is an HTTP 200 code in case of success with a response body.

Example Output of "Generate value on input procedure call" example
{
  "@ns" : "http://prism.evolveum.com/xml/ns/public/types-3",
  "object" : {
    "@type" : "http://midpoint.evolveum.com/xml/ns/public/common/api-types-3#PolicyItemsDefinitionType",
    "policyItemDefinition" : [ {
      "value" : {
        "@type" : "xsd:string",
        "@value" : "3ju6We:q,DL"
      }
    } ]
  }
}
Was this page helpful?
YES NO
Thanks for your feedback