Camel Components

Huawei Identity and Access Management (IAM)

Since Camel 3.11

Only producer is supported

Huawei Cloud Identity and Access Management (IAM) component allows you to integrate with IAM provided by Huawei Cloud.

Maven users will need to add the following dependency to their pom.xml for this component:

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-huaweicloud-iam</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>

URI Format

hwcloud-iam:operation[?options]

Configuring Options

Camel components are configured on two separate levels:

  • component level

  • endpoint level

Configuring Component Options

At the component level, you set general and shared configurations that are, then, inherited by the endpoints. It is the highest configuration level.

For example, a component may have security settings, credentials for authentication, urls for network connection and so forth.

Some components only have a few options, and others may have many. Because components typically have pre-configured defaults that are commonly used, then you may often only need to configure a few options on a component; or none at all.

You can configure components using:

  • the Component DSL.

  • in a configuration file (application.properties, *.yaml files, etc).

  • directly in the Java code.

Configuring Endpoint Options

You usually spend more time setting up endpoints because they have many options. These options help you customize what you want the endpoint to do. The options are also categorized into whether the endpoint is used as a consumer (from), as a producer (to), or both.

Configuring endpoints is most often done directly in the endpoint URI as path and query parameters. You can also use the Endpoint DSL and DataFormat DSL as a type safe way of configuring endpoints and data formats in Java.

A good practice when configuring options is to use Property Placeholders.

Property placeholders provide a few benefits:

  • They help prevent using hardcoded urls, port numbers, sensitive information, and other settings.

  • They allow externalizing the configuration from the code.

  • They help the code to become more flexible and reusable.

The following two sections list all the options, firstly for the component followed by the endpoint.

Component Options

The Huawei Identity and Access Management (IAM) component supports the following options which are listed below.

Name Description Default Type

lazyStartProducer (producer)

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

boolean

autowiredEnabled (advanced)

Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc.

true

boolean

Endpoint Options

The Huawei Identity and Access Management (IAM) endpoint is configured using URI syntax:

hwcloud-iam:operation

With the following path and query parameters:

Path Parameters

Name Description Default Type

operation (producer)

Required The operation that the producer performs: listUsers, getUser, updateUser, listGroups, getGroupUsers or updateGroup. The CamelHwCloudIamOperation exchange property replaces this option.

String

Query Parameters

Name Description Default Type

accessKey (producer)

Required The access key ID (AK) of the Huawei Cloud credentials. Not used when the serviceKeys option is set.

String

groupId (producer)

The ID of the user group for getGroupUsers and updateGroup, which fail without it. The CamelHwCloudIamGroupId exchange property replaces this option.

String

proxyHost (producer)

The host name or IP address of the proxy server. The producer uses a proxy only when this option and the proxyPort option are set.

String

proxyPassword (producer)

The password to authenticate with the proxy server. It is used only when the proxyHost, proxyPort and proxyUser options are set.

String

proxyPort (producer)

The port of the proxy server. The producer uses a proxy only when this option is above 0 and the proxyHost option is set.

int

proxyUser (producer)

The user name to authenticate with the proxy server. It is used only when the proxyHost and proxyPort options are set.

String

region (producer)

Required The region ID of IAM, for example cn-north-4. The producer uses it to find the endpoint of IAM, and fails to start the client when the Huawei Cloud SDK does not know the region for IAM.

String

secretKey (producer)

Required The secret access key (SK) of the Huawei Cloud credentials. Not used when the serviceKeys option is set.

String

serviceKeys (producer)

The AK/SK pair as an org.apache.camel.component.huaweicloud.common.models.ServiceKeys. When set, its accessKey and its secretKey replace the accessKey and secretKey options.

ServiceKeys

userId (producer)

The ID of the IAM user for getUser and updateUser, which fail without it. The CamelHwCloudIamUserId exchange property replaces this option.

String

lazyStartProducer (producer (advanced))

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

boolean

ignoreSslVerification (security)

Whether to skip the verification of the TLS certificate of the server. This makes the connection insecure: use it only for testing.

false

boolean

Message Body

The message body at each side of the Huawei Identity and Access Management (IAM) component: Consumer is the body of the messages the consumer creates, Consumer reply the bodies a consumer that answers its caller can reply with, Producer input the bodies the producer can send or write, and Producer output the body after the producer.

Side Body Description

Producer input

any

Not used by the list and get operations, which take the ids from the options or the CamelHwCloudIamUserId and CamelHwCloudIamGroupId exchange properties. updateUser needs an UpdateUserOption of the Huawei Cloud SDK or its JSON, and updateGroup a KeystoneUpdateGroupOption or its JSON, as text, bytes, a stream or a file: another body fails.

  • With operation=updateUser: text, bytes, stream, file or pojo

  • With operation=updateGroup: text, bytes, stream, file or pojo

Producer output

text (java.lang.String), as json

The JSON of the result as text: the array of the users or the groups for listUsers, listGroups and getGroupUsers, the user or the group for getUser, updateUser and updateGroup. The keys are the field names of the IAM API, such as domain_id, as in the JSON of the request.

The bodies are the ones with the default options. A side that is not listed is not known, and tooling does not guess it. The carriers, the sides and the tools that use them are described in Message Body Types.

Usage

Message properties evaluated by the IAM producer

Header Type Description

CamelHwCloudIamOperation

String

Name of operation to invoke

CamelHwCloudIamUserId

String

User ID to invoke operation on

CamelHwCloudIamGroupId

String

Group ID to invoke operation on

If any of the above properties are set, they will override their corresponding query parameter.

List of Supported IAM Operations

  • listUsers

  • getUser - userId parameter is required

  • updateUser - userId parameter is required

  • listGroups

  • getGroupUsers - groupId is required

  • updateGroup - groupId is required

Passing Options Through Exchange Body

There are many options that can be submitted to update a user (Table 4) or to update a group (Table 4). Since there are multiple user/group options, they must be passed through the exchange body.

For the updateUser operation, you can pass the user options as an UpdateUserOption object or its JSON, as text, bytes, a stream or a file:

Java-only: requires SDK UpdateUserOption builder
from("direct:triggerRoute")
 .setBody(constant(new UpdateUserOption().withName("user").withDescription("employee").withEmail("user@email.com")))
 .to("hwcloud-iam:updateUser?userId=********&region=cn-north-4&accessKey=********&secretKey=********")
  • Java

  • XML

  • YAML

from("direct:triggerRoute")
 .setBody(constant("{\"name\":\"user\",\"description\":\"employee\",\"email\":\"user@email.com\"}"))
 .to("hwcloud-iam:updateUser?userId=********&region=cn-north-4&accessKey=********&secretKey=********")
<route>
  <from uri="direct:triggerRoute"/>
  <setBody>
    <constant>{"name":"user","description":"employee","email":"user@email.com"}</constant>
  </setBody>
  <to uri="hwcloud-iam:updateUser?userId=********&amp;region=cn-north-4&amp;accessKey=********&amp;secretKey=********"/>
</route>
- route:
    from:
      uri: direct:triggerRoute
      steps:
        - setBody:
            constant: '{"name":"user","description":"employee","email":"user@email.com"}'
        - to:
            uri: hwcloud-iam:updateUser
            parameters:
              userId: "********"
              region: cn-north-4
              accessKey: "********"
              secretKey: "********"

For the updateGroup operation, you can pass the group options as a KeystoneUpdateGroupOption object or its JSON, as text, bytes, a stream or a file:

Java-only: requires SDK KeystoneUpdateGroupOption builder
from("direct:triggerRoute")
 .setBody(constant(new KeystoneUpdateGroupOption().withName("group").withDescription("employees").withDomainId("1234")))
 .to("hwcloud-iam:updateGroup?groupId=********&region=cn-north-4&accessKey=********&secretKey=********")
  • Java

  • XML

  • YAML

from("direct:triggerRoute")
 .setBody(constant("{\"name\":\"group\",\"description\":\"employees\",\"domain_id\":\"1234\"}"))
 .to("hwcloud-iam:updateGroup?groupId=********&region=cn-north-4&accessKey=********&secretKey=********")
<route>
  <from uri="direct:triggerRoute"/>
  <setBody>
    <constant>{"name":"group","description":"employees","domain_id":"1234"}</constant>
  </setBody>
  <to uri="hwcloud-iam:updateGroup?groupId=********&amp;region=cn-north-4&amp;accessKey=********&amp;secretKey=********"/>
</route>
- route:
    from:
      uri: direct:triggerRoute
      steps:
        - setBody:
            constant: '{"name":"group","description":"employees","domain_id":"1234"}'
        - to:
            uri: hwcloud-iam:updateGroup
            parameters:
              groupId: "********"
              region: cn-north-4
              accessKey: "********"
              secretKey: "********"

Another body fails the exchange with an IllegalArgumentException.

JSON of the Results

The operations set the exchange body to the JSON of their result, as text: the array of the users for listUsers and getGroupUsers, the array of the groups for listGroups, the user for getUser and updateUser, and the group for updateGroup. The keys are the field names of the IAM API, as in the JSON of the requests above, for example the result of getUser:

{"domain_id":"1234","name":"user","email":"user@email.com","pwd_status":true}

Using ServiceKey Configuration Bean

Access key and secret keys are required to authenticate against cloud IAM service. You can avoid having them being exposed and scattered over in your endpoint uri by wrapping them inside a bean of class org.apache.camel.component.huaweicloud.common.models.ServiceKeys. Add it to the registry and let Camel look it up by referring the object via endpoint query parameter serviceKeys.

Check the following code snippets:

<bean id="myServiceKeyConfig" class="org.apache.camel.component.huaweicloud.common.models.ServiceKeys">
   <property name="accessKey" value="your_access_key" />
   <property name="secretKey" value="your_secret_key" />
</bean>
  • Java

  • XML

  • YAML

from("direct:triggerRoute")
 .setProperty("CamelHwCloudIamOperation", constant("listUsers"))
 .setProperty("CamelHwCloudIamUserId", constant("your_user_id"))
 .setProperty("CamelHwCloudIamGroupId", constant("your_group_id"))
 .to("hwcloud-iam:listUsers?region=cn-north-4&serviceKeys=#myServiceKeyConfig")
<route>
  <from uri="direct:triggerRoute"/>
  <setProperty name="CamelHwCloudIamOperation">
    <constant>listUsers</constant>
  </setProperty>
  <setProperty name="CamelHwCloudIamUserId">
    <constant>your_user_id</constant>
  </setProperty>
  <setProperty name="CamelHwCloudIamGroupId">
    <constant>your_group_id</constant>
  </setProperty>
  <to uri="hwcloud-iam:listUsers?region=cn-north-4&amp;serviceKeys=#myServiceKeyConfig"/>
</route>
- route:
    from:
      uri: direct:triggerRoute
      steps:
        - setProperty:
            name: CamelHwCloudIamOperation
            constant: listUsers
        - setProperty:
            name: CamelHwCloudIamUserId
            constant: your_user_id
        - setProperty:
            name: CamelHwCloudIamGroupId
            constant: your_group_id
        - to:
            uri: hwcloud-iam:listUsers
            parameters:
              region: cn-north-4
              serviceKeys: "#myServiceKeyConfig"