fivetran-arunsuri commented on code in PR #2197:
URL: https://github.com/apache/polaris/pull/2197#discussion_r2286289851


##########
runtime/service/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java:
##########
@@ -1135,18 +1136,83 @@ public void deletePrincipal(String name) {
             newSecrets.getPrincipalClientId(), newSecrets.getMainSecret()));
   }
 
+  private @Nonnull PrincipalWithCredentials resetCredentialsHelper(
+      String principalName, String customClientId, String customClientSecret) {
+    PrincipalEntity currentPrincipalEntity =
+        findPrincipalByName(principalName)
+            .orElseThrow(() -> new NotFoundException("Principal %s not found", 
principalName));
+
+    if (FederatedEntities.isFederated(currentPrincipalEntity)) {
+      throw new ValidationException(
+          "Cannot reset credentials for a federated principal: %s", 
principalName);
+    }
+    PolarisPrincipalSecrets currentSecrets =
+        metaStoreManager
+            .loadPrincipalSecrets(getCurrentPolarisContext(), 
currentPrincipalEntity.getClientId())
+            .getPrincipalSecrets();
+    if (currentSecrets == null) {
+      throw new IllegalArgumentException(
+          String.format("Failed to load current secrets for principal '%s'", 
principalName));
+    }
+    PolarisPrincipalSecrets newSecrets =
+        metaStoreManager
+            .resetPrincipalSecrets(
+                getCurrentPolarisContext(),
+                currentPrincipalEntity.getClientId(),

Review Comment:
   this flow should be covered as part of integration tests



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@polaris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to