Skip to content

Commit 93a4d5d

Browse files
committed
Created client layer for IAM
1 parent 55735d6 commit 93a4d5d

File tree

13 files changed

+2088
-0
lines changed

13 files changed

+2088
-0
lines changed

iam/iam-client/pom.xml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<artifactId>iam-client</artifactId>
6+
<packaging>jar</packaging>
7+
<name>MultiCloudJ - IAM Client</name>
8+
9+
<parent>
10+
<groupId>com.salesforce.multicloudj</groupId>
11+
<artifactId>iam</artifactId>
12+
<version>${revision}</version>
13+
<relativePath>../pom.xml</relativePath>
14+
</parent>
15+
16+
<dependencies>
17+
<!-- Core dependencies -->
18+
<dependency>
19+
<groupId>com.salesforce.multicloudj</groupId>
20+
<artifactId>multicloudj-common</artifactId>
21+
</dependency>
22+
<dependency>
23+
<groupId>com.salesforce.multicloudj</groupId>
24+
<artifactId>sts-client</artifactId>
25+
</dependency>
26+
27+
<!-- Test dependencies -->
28+
<dependency>
29+
<groupId>org.junit.jupiter</groupId>
30+
<artifactId>junit-jupiter-api</artifactId>
31+
<version>5.12.1</version>
32+
<scope>test</scope>
33+
</dependency>
34+
<dependency>
35+
<groupId>org.mockito</groupId>
36+
<artifactId>mockito-core</artifactId>
37+
<version>5.16.1</version>
38+
<scope>test</scope>
39+
</dependency>
40+
<dependency>
41+
<groupId>org.mockito</groupId>
42+
<artifactId>mockito-junit-jupiter</artifactId>
43+
<version>5.16.1</version>
44+
<scope>test</scope>
45+
</dependency>
46+
<dependency>
47+
<groupId>com.salesforce.multicloudj</groupId>
48+
<artifactId>multicloudj-common</artifactId>
49+
<type>test-jar</type>
50+
<scope>test</scope>
51+
</dependency>
52+
</dependencies>
53+
54+
<build>
55+
<plugins>
56+
<plugin>
57+
<groupId>org.apache.maven.plugins</groupId>
58+
<artifactId>maven-jar-plugin</artifactId>
59+
<version>3.4.2</version>
60+
<executions>
61+
<execution>
62+
<goals>
63+
<goal>test-jar</goal>
64+
</goals>
65+
</execution>
66+
</executions>
67+
</plugin>
68+
69+
<plugin>
70+
<groupId>org.apache.maven.plugins</groupId>
71+
<artifactId>maven-surefire-plugin</artifactId>
72+
<version>3.4.0</version>
73+
</plugin>
74+
<plugin>
75+
<groupId>org.apache.maven.plugins</groupId>
76+
<artifactId>maven-failsafe-plugin</artifactId>
77+
<version>3.4.0</version>
78+
<executions>
79+
<execution>
80+
<id>run-integration-tests</id>
81+
<phase>integration-test</phase>
82+
<goals>
83+
<goal>integration-test</goal>
84+
</goals>
85+
</execution>
86+
<execution>
87+
<id>verify-integration-results</id>
88+
<phase>verify</phase>
89+
<goals>
90+
<goal>verify</goal>
91+
</goals>
92+
</execution>
93+
</executions>
94+
</plugin>
95+
</plugins>
96+
</build>
97+
</project>
Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
package com.salesforce.multicloudj.iam.client;
2+
3+
import com.salesforce.multicloudj.iam.model.CreateOptions;
4+
import com.salesforce.multicloudj.iam.model.PolicyDocument;
5+
import com.salesforce.multicloudj.iam.model.TrustConfiguration;
6+
import com.salesforce.multicloudj.sts.model.CredentialsOverrider;
7+
8+
import java.net.URI;
9+
import java.util.List;
10+
import java.util.Optional;
11+
12+
/**
13+
* Entry point for client code to interact with Identity and Access Management (IAM) services
14+
* in a substrate-agnostic way.
15+
*
16+
* <p>This client provides unified IAM operations across multiple cloud providers including
17+
* AWS IAM, GCP IAM, and AliCloud RAM. It handles the complexity of different cloud IAM models
18+
* and provides a consistent API for identity lifecycle management and policy operations.
19+
*
20+
* <p>Usage example:
21+
* <pre>
22+
* IamClient client = IamClient.builder("aws")
23+
* .withRegion("us-west-2")
24+
* .build();
25+
*
26+
* // Create identity
27+
* String identityId = client.createIdentity("MyRole", "Example role", "123456789012", "us-west-2",
28+
* Optional.empty(), Optional.empty());
29+
*
30+
* // Create policy
31+
* PolicyDocument policy = PolicyDocument.builder()
32+
* .version("2024-01-01")
33+
* .statement("StorageAccess")
34+
* .effect("Allow")
35+
* .addAction("storage:GetObject")
36+
* .addResource("storage://my-bucket/*")
37+
* .endStatement()
38+
* .build();
39+
*
40+
* // Attach policy
41+
* client.attachInlinePolicy(policy, "123456789012", "us-west-2", "my-bucket");
42+
* </pre>
43+
*
44+
* @since 0.3.0
45+
*/
46+
public class IamClient {
47+
48+
/**
49+
* Protected constructor for IamClient.
50+
* Use the builder pattern to create instances.
51+
*/
52+
protected IamClient() {
53+
// Implementation will be added later when AbstractIamService is available
54+
}
55+
56+
/**
57+
* Creates a new IamClientBuilder for the specified provider.
58+
*
59+
* @param providerId the ID of the provider such as "aws", "gcp", or "ali"
60+
* @return a new IamClientBuilder instance
61+
*/
62+
public static IamClientBuilder builder(String providerId) {
63+
return new IamClientBuilder(providerId);
64+
}
65+
66+
/**
67+
* Creates a new identity (role/service account) in the cloud provider.
68+
*
69+
* @param identityName the name of the identity to create
70+
* @param description optional description for the identity (can be null)
71+
* @param tenantId the tenant ID (AWS Account ID, GCP Project ID, or AliCloud Account ID)
72+
* @param region the region for IAM operations
73+
* @param trustConfig optional trust configuration
74+
* @param options optional creation options
75+
* @return the unique identifier of the created identity
76+
*/
77+
public String createIdentity(String identityName, String description, String tenantId, String region,
78+
Optional<TrustConfiguration> trustConfig, Optional<CreateOptions> options) {
79+
// Implementation will be added when driver layer is available
80+
throw new UnsupportedOperationException("Implementation will be added when driver layer is available");
81+
}
82+
83+
/**
84+
* Attaches an inline policy to a resource.
85+
*
86+
* @param policyDocument the policy document in substrate-neutral format
87+
* @param tenantId the tenant ID
88+
* @param region the region
89+
* @param resource the resource to attach the policy to
90+
*/
91+
public void attachInlinePolicy(PolicyDocument policyDocument, String tenantId, String region, String resource) {
92+
// Implementation will be added when driver layer is available
93+
throw new UnsupportedOperationException("Implementation will be added when driver layer is available");
94+
}
95+
96+
/**
97+
* Retrieves the details of a specific inline policy attached to an identity.
98+
*
99+
* @param identityName the name of the identity
100+
* @param policyName the name of the policy
101+
* @param tenantId the tenant ID
102+
* @param region the region
103+
* @return the policy document details as a string
104+
*/
105+
public String getInlinePolicyDetails(String identityName, String policyName, String tenantId, String region) {
106+
// Implementation will be added when driver layer is available
107+
throw new UnsupportedOperationException("Implementation will be added when driver layer is available");
108+
}
109+
110+
/**
111+
* Lists all inline policies attached to an identity.
112+
*
113+
* @param identityName the name of the identity
114+
* @param tenantId the tenant ID
115+
* @param region the region
116+
* @return a list of policy names
117+
*/
118+
public List<String> getAttachedPolicies(String identityName, String tenantId, String region) {
119+
// Implementation will be added when driver layer is available
120+
throw new UnsupportedOperationException("Implementation will be added when driver layer is available");
121+
}
122+
123+
/**
124+
* Removes an inline policy from an identity.
125+
*
126+
* @param identityName the name of the identity
127+
* @param policyName the name of the policy to remove
128+
* @param tenantId the tenant ID
129+
* @param region the region
130+
*/
131+
public void removePolicy(String identityName, String policyName, String tenantId, String region) {
132+
// Implementation will be added when driver layer is available
133+
throw new UnsupportedOperationException("Implementation will be added when driver layer is available");
134+
}
135+
136+
/**
137+
* Deletes an identity from the cloud provider.
138+
*
139+
* @param identityName the name of the identity to delete
140+
* @param tenantId the tenant ID
141+
* @param region the region
142+
*/
143+
public void deleteIdentity(String identityName, String tenantId, String region) {
144+
// Implementation will be added when driver layer is available
145+
throw new UnsupportedOperationException("Implementation will be added when driver layer is available");
146+
}
147+
148+
/**
149+
* Retrieves metadata about an identity.
150+
*
151+
* @param identityName the name of the identity
152+
* @param tenantId the tenant ID
153+
* @param region the region
154+
* @return the unique identity identifier (ARN, email, or roleId)
155+
*/
156+
public String getIdentity(String identityName, String tenantId, String region) {
157+
// Implementation will be added when driver layer is available
158+
throw new UnsupportedOperationException("Implementation will be added when driver layer is available");
159+
}
160+
161+
/**
162+
* Builder class for IamClient.
163+
*/
164+
public static class IamClientBuilder {
165+
protected String region;
166+
protected URI endpoint;
167+
168+
/**
169+
* Constructor for IamClientBuilder.
170+
*
171+
* @param providerId the ID of the provider such as "aws", "gcp", or "ali"
172+
*/
173+
public IamClientBuilder(String providerId) {
174+
// Implementation will be added when ServiceLoader and AbstractIamService are available
175+
// Will find and initialize the provider builder here
176+
}
177+
178+
/**
179+
* Sets the region for the IAM client.
180+
*
181+
* @param region the region to set
182+
* @return this IamClientBuilder instance
183+
*/
184+
public IamClientBuilder withRegion(String region) {
185+
this.region = region;
186+
// Implementation will be added later to delegate to underlying provider builder
187+
return this;
188+
}
189+
190+
/**
191+
* Sets the endpoint to override for the IAM client.
192+
*
193+
* @param endpoint the endpoint to set
194+
* @return this IamClientBuilder instance
195+
*/
196+
public IamClientBuilder withEndpoint(URI endpoint) {
197+
this.endpoint = endpoint;
198+
// Implementation will be added later to delegate to underlying provider builder
199+
return this;
200+
}
201+
202+
/**
203+
* Builds and returns an IamClient instance.
204+
*
205+
* @return a new IamClient instance
206+
*/
207+
public IamClient build() {
208+
// Implementation will be added when ServiceLoader and AbstractIamService are available
209+
return new IamClient();
210+
}
211+
}
212+
}

0 commit comments

Comments
 (0)