use of com.formkiq.aws.sts.StsConnectionBuilder in project formkiq-core by formkiq.
the class AbstractApiTest method beforeClass.
/**
* Before Class.
*
* @throws IOException IOException
*/
@BeforeClass
public static void beforeClass() throws IOException {
awsregion = Region.of(System.getProperty("testregion"));
String awsprofile = System.getProperty("testprofile");
appenvironment = System.getProperty("testappenvironment");
loadSsmParameterVariables(awsprofile);
try (ProfileCredentialsProvider credentials = ProfileCredentialsProvider.builder().profileName(awsprofile).build()) {
FormKiqClientConnection connection = new FormKiqClientConnection(rootRestUrl).region(awsregion).credentials(credentials.resolveCredentials()).header("Origin", Arrays.asList("http://localhost")).header("Access-Control-Request-Method", Arrays.asList("GET"));
restClient = new FormKiqClientV1(connection);
}
CognitoConnectionBuilder adminBuilder = new CognitoConnectionBuilder(cognitoClientId, cognitoUserPoolId, cognitoIdentitypool).setCredentials(awsprofile).setRegion(awsregion);
adminCognitoService = new CognitoService(adminBuilder);
stsBuilder = new StsConnectionBuilder().setCredentials(awsprofile).setRegion(awsregion);
stsService = new StsService(stsBuilder);
try (StsClient stsClient = stsBuilder.build()) {
GetCallerIdentityResponse identity = stsClient.getCallerIdentity();
String user = identity.arn().substring(identity.arn().lastIndexOf("/") + 1);
IamConnectionBuilder iamBuilder = new IamConnectionBuilder().setCredentials(awsprofile);
IamService iam = new IamService(iamBuilder);
try (IamClient iamClient = iamBuilder.build()) {
iam.addUserToGroup(iamClient, user, apiGatewayInvokeGroup);
}
executeApiSigner = new Aws4SignerParamsBuilder().setRegion(awsregion).setSigningName("execute-api").setCredentials(awsprofile).build();
}
setupCognito();
setupConfigService(awsprofile);
}
Aggregations