mirror of
https://github.com/floci-io/floci.git
synced 2026-11-29 16:35:29 -05:00
refactor: rebuild the SSO Admin instance ARN through AwsArnUtils and share the ACM id cut (#7370)
This commit is contained in:
1 parent
c0906b88d0
commit
e872bdc308
5 files changed
+30
-13
No files matched your search
@@ -719,7 +719,7 @@ public class AcmService implements ResourceProvider {
|
||||
// ============ Helper Methods ============
|
||||
|
||||
private synchronized Certificate getCertificateByArn(String arn, String region) {
|
||||
String certId = extractCertificateIdFromArn(arn);
|
||||
String certId = Certificate.idFromArn(arn);
|
||||
String storageKey = regionKey(region, certId);
|
||||
|
||||
Certificate cert = store.get(storageKey).orElseThrow(() ->
|
||||
@@ -800,7 +800,7 @@ public class AcmService implements ResourceProvider {
|
||||
"that used that token.", 400);
|
||||
}
|
||||
|
||||
String certId = extractCertificateIdFromArn(entry.arn());
|
||||
String certId = Certificate.idFromArn(entry.arn());
|
||||
return store.get(regionKey(region, certId));
|
||||
}
|
||||
|
||||
@@ -971,11 +971,6 @@ public class AcmService implements ResourceProvider {
|
||||
return AwsArnUtils.Arn.of("acm", region, accountId, "certificate/" + certId).toString();
|
||||
}
|
||||
|
||||
private String extractCertificateIdFromArn(String arn) {
|
||||
int lastSlash = arn.lastIndexOf('/');
|
||||
return lastSlash >= 0 ? arn.substring(lastSlash + 1) : arn;
|
||||
}
|
||||
|
||||
private String regionKey(String region, String certId) {
|
||||
return region + "::" + certId;
|
||||
}
|
||||
|
||||
@@ -266,7 +266,11 @@ public class Certificate {
|
||||
}
|
||||
|
||||
public String extractCertificateId() {
|
||||
if (arn == null) return null;
|
||||
return arn == null ? null : idFromArn(arn);
|
||||
}
|
||||
|
||||
/** The id at the end of a certificate ARN. A value with no {@code /} is taken as the id itself. */
|
||||
public static String idFromArn(String arn) {
|
||||
int lastSlash = arn.lastIndexOf('/');
|
||||
return lastSlash >= 0 ? arn.substring(lastSlash + 1) : arn;
|
||||
}
|
||||
|
||||
@@ -2481,11 +2481,9 @@ public class SsoAdminService implements Resettable {
|
||||
}
|
||||
|
||||
private static String instanceArnForPermissionSet(String permissionSetArn) {
|
||||
int serviceIndex = permissionSetArn.indexOf(":sso::");
|
||||
int instanceStart = permissionSetArn.indexOf("permissionSet/") + "permissionSet/".length();
|
||||
int instanceEnd = permissionSetArn.indexOf('/', instanceStart);
|
||||
return permissionSetArn.substring(0, serviceIndex) + ":sso:::instance/"
|
||||
+ permissionSetArn.substring(instanceStart, instanceEnd);
|
||||
AwsArnUtils.Arn arn = AwsArnUtils.parse(permissionSetArn);
|
||||
String instanceId = arn.resource().split("/", 3)[1];
|
||||
return AwsArnUtils.Arn.global(arn.partition(), "sso", "", "instance/" + instanceId).toString();
|
||||
}
|
||||
|
||||
static String applicationAccessScopeKey(String applicationArn, String scope) {
|
||||
|
||||
Reference in new issue
Block a user