Alon Bar-Lev has uploaded a new change for review.

Change subject: aaa: always set principal when fetching principal record
......................................................................

aaa: always set principal when fetching principal record

although information is available in AuthRecord, and extensions should
fall back into optional Principal anyway (as already do), it would be
nicer to provide both Principal and AuthRecord if available to simplify
extension implementation.

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1192791
Change-Id: I1330df35a054713d2e42c00bf70ea52ff0b49021
Signed-off-by: Alon Bar-Lev <[email protected]>
---
M 
backend/manager/modules/aaa/src/main/java/org/ovirt/engine/core/aaa/AuthzUtils.java
1 file changed, 26 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/99/37799/1

diff --git 
a/backend/manager/modules/aaa/src/main/java/org/ovirt/engine/core/aaa/AuthzUtils.java
 
b/backend/manager/modules/aaa/src/main/java/org/ovirt/engine/core/aaa/AuthzUtils.java
index df81bb7..bf3aae9 100644
--- 
a/backend/manager/modules/aaa/src/main/java/org/ovirt/engine/core/aaa/AuthzUtils.java
+++ 
b/backend/manager/modules/aaa/src/main/java/org/ovirt/engine/core/aaa/AuthzUtils.java
@@ -7,7 +7,6 @@
 import org.slf4j.LoggerFactory;
 
 import org.ovirt.engine.api.extensions.Base;
-import org.ovirt.engine.api.extensions.ExtKey;
 import org.ovirt.engine.api.extensions.ExtMap;
 import org.ovirt.engine.api.extensions.aaa.Authn;
 import org.ovirt.engine.api.extensions.aaa.Authz;
@@ -35,21 +34,38 @@
     }
 
     public static ExtMap fetchPrincipalRecord(final ExtensionProxy extension, 
ExtMap authRecord) {
-        return fetchPrincipalRecordImpl(extension, 
Authn.InvokeKeys.AUTH_RECORD, authRecord, true, true);
+        return fetchPrincipalRecordImpl(
+                extension,
+                new ExtMap().mput(
+                    Authn.InvokeKeys.AUTH_RECORD,
+                    authRecord
+                ).mput(
+                    Authz.InvokeKeys.PRINCIPAL,
+                    authRecord.get(Authn.AuthRecord.PRINCIPAL)
+                ),
+                true,
+                true
+        );
     }
 
     public static ExtMap fetchPrincipalRecord(final ExtensionProxy extension, 
String principal, boolean resolveGroups, boolean resolveGroupsRecursive) {
-        return fetchPrincipalRecordImpl(extension, Authz.InvokeKeys.PRINCIPAL, 
principal, resolveGroups, resolveGroupsRecursive);
+        return fetchPrincipalRecordImpl(
+                extension,
+                new ExtMap().mput(
+                    Authz.InvokeKeys.PRINCIPAL,
+                    principal
+                ),
+                resolveGroups,
+                resolveGroupsRecursive
+        );
     }
 
-    private static ExtMap fetchPrincipalRecordImpl(final ExtensionProxy 
extension, ExtKey key, Object value, boolean resolveGroups, boolean 
resolveGroupsRecursive) {
+    private static ExtMap fetchPrincipalRecordImpl(final ExtensionProxy 
extension, ExtMap m, boolean resolveGroups, boolean resolveGroupsRecursive) {
         ExtMap ret = null;
-        ExtMap output = extension.invoke(new ExtMap().mput(
-                Base.InvokeKeys.COMMAND,
-                Authz.InvokeCommands.FETCH_PRINCIPAL_RECORD
-                ).mput(
-                        key,
-                        value
+        ExtMap output = extension.invoke(
+                m.mput(
+                        Base.InvokeKeys.COMMAND,
+                        Authz.InvokeCommands.FETCH_PRINCIPAL_RECORD
                 ).mput(
                         Authz.InvokeKeys.QUERY_FLAGS,
                         (


-- 
To view, visit http://gerrit.ovirt.org/37799
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1330df35a054713d2e42c00bf70ea52ff0b49021
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Alon Bar-Lev <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to