-
Notifications
You must be signed in to change notification settings - Fork 487
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
119 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
adminapi/src/main/java/io/minio/admin/messages/AddServiceAccountRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package io.minio.admin.messages; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public class AddServiceAccountRequest { | ||
@JsonProperty("targetUser") | ||
private final String targetUser; | ||
|
||
public AddServiceAccountRequest(String targetUser) { | ||
this.targetUser = targetUser; | ||
} | ||
|
||
public String targetUser() { | ||
return targetUser; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
adminapi/src/main/java/io/minio/admin/messages/AddServiceAccountResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package io.minio.admin.messages; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public class AddServiceAccountResponse { | ||
@JsonProperty("credentials") | ||
private ServiceAccountCredentials credentials; | ||
|
||
public ServiceAccountCredentials credentials() { | ||
return credentials; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
adminapi/src/main/java/io/minio/admin/messages/ServiceAccountCredentials.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package io.minio.admin.messages; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import io.minio.messages.ResponseDate; | ||
|
||
public class ServiceAccountCredentials { | ||
@JsonProperty("accessKey") | ||
private String accessKey; | ||
|
||
@JsonProperty("secretKey") | ||
private String secretKey; | ||
|
||
@JsonProperty("sessionToken") | ||
private String sessionToken; | ||
|
||
@JsonProperty("expiration") | ||
private ResponseDate expiration; | ||
|
||
public String accessKey() { | ||
return accessKey; | ||
} | ||
|
||
public String secretKey() { | ||
return secretKey; | ||
} | ||
|
||
public String sessionToken() { | ||
return sessionToken; | ||
} | ||
|
||
public ResponseDate expiration() { | ||
return expiration; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
adminapi/src/test/java/io/minio/admin/AddServiceAccountTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package io.minio.admin; | ||
|
||
import io.minio.admin.messages.ServiceAccountCredentials; | ||
import java.io.IOException; | ||
import java.security.InvalidKeyException; | ||
import java.security.NoSuchAlgorithmException; | ||
import org.bouncycastle.crypto.InvalidCipherTextException; | ||
import org.junit.Test; | ||
|
||
public class AddServiceAccountTest { | ||
@Test | ||
public void canObtainServiceAccount() | ||
throws InvalidCipherTextException, NoSuchAlgorithmException, IOException, | ||
InvalidKeyException { | ||
MinioAdminClient adminClient = | ||
MinioAdminClient.builder() | ||
.endpoint("https://play.min.io") | ||
.credentials("Q3AM3UQ867SPQQA43P2F", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG") | ||
.build(); | ||
ServiceAccountCredentials credentials = adminClient.addServiceAccount("Q3AM3UQ867SPQQA43P2F"); | ||
System.out.println(credentials.accessKey()); | ||
System.out.println(credentials.secretKey()); | ||
} | ||
} |