From ce8180700f8b7390e6b3204bbb96e557ce9a21b9 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Sat, 14 Mar 2020 08:56:14 +0100 Subject: [PATCH] Fix compilation errors after cherry-picking These deal with User->Focus generalization w.r.t. passwords. (These are in UserType only in 4.0.x.) --- .../model/api/expr/MidpointFunctions.java | 4 ++-- .../impl/expr/MidpointFunctionsImpl.java | 10 ++++----- .../impl/events/ModelEventImpl.java | 14 ++++++------- .../notifications/impl/TestTextFormatter.java | 21 ++++++++++--------- 4 files changed, 25 insertions(+), 24 deletions(-) diff --git a/model/model-api/src/main/java/com/evolveum/midpoint/model/api/expr/MidpointFunctions.java b/model/model-api/src/main/java/com/evolveum/midpoint/model/api/expr/MidpointFunctions.java index b21ef7a191a..a8e151a79c1 100644 --- a/model/model-api/src/main/java/com/evolveum/midpoint/model/api/expr/MidpointFunctions.java +++ b/model/model-api/src/main/java/com/evolveum/midpoint/model/api/expr/MidpointFunctions.java @@ -991,7 +991,7 @@ Collection getManagersOidsExceptUser(@NotNull Collection getManagersOidsExceptUser(@NotNull Collection delta) throws EncryptionException; - String getPlaintextUserPasswordFromDeltas(List> deltas) throws EncryptionException; + String getPlaintextUserPasswordFromDeltas(List> deltas) throws EncryptionException; Task getCurrentTask(); diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/expr/MidpointFunctionsImpl.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/expr/MidpointFunctionsImpl.java index 525e0e9008d..11ba68bc0c7 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/expr/MidpointFunctionsImpl.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/expr/MidpointFunctionsImpl.java @@ -171,7 +171,7 @@ public boolean isMemberOf(UserType user, String orgOid) { } @Override - public String getPlaintextUserPassword(FocusType user) throws EncryptionException { + public String getPlaintextUserPassword(UserType user) throws EncryptionException { if (user == null || user.getCredentials() == null || user.getCredentials().getPassword() == null) { return null; // todo log a warning here? } @@ -256,15 +256,15 @@ private void takePasswordsFromItemDelta(List passwords, Ite } @Override - public String getPlaintextUserPasswordFromDeltas(List> objectDeltas) throws EncryptionException { + public String getPlaintextUserPasswordFromDeltas(List> objectDeltas) throws EncryptionException { List passwords = new ArrayList<>(); - for (ObjectDelta delta : objectDeltas) { + for (ObjectDelta delta : objectDeltas) { if (delta.isAdd()) { - FocusType newObject = delta.getObjectToAdd().asObjectable(); - return getPlaintextUserPassword(newObject); // for simplicity we do not look for other values + UserType newUser = delta.getObjectToAdd().asObjectable(); + return getPlaintextUserPassword(newUser); // for simplicity we do not look for other values } if (!delta.isModify()) { diff --git a/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/events/ModelEventImpl.java b/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/events/ModelEventImpl.java index bb838da4bc1..25f18f37650 100644 --- a/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/events/ModelEventImpl.java +++ b/model/notifications-impl/src/main/java/com/evolveum/midpoint/notifications/impl/events/ModelEventImpl.java @@ -276,8 +276,8 @@ public String getFocusPassword() { LOGGER.trace("getFocusPasswordFromEvent: No user deltas in event"); return null; } - if (!hasFocusOfType(FocusType.class)) { - LOGGER.trace("getFocusPasswordFromEvent: Not a FocusType context"); + if (!hasFocusOfType(UserType.class)) { + LOGGER.trace("getFocusPasswordFromEvent: Not a UserType context"); return null; } //noinspection unchecked,rawtypes @@ -287,10 +287,10 @@ public String getFocusPassword() { return passwordFromDeltas; } - //noinspection unchecked - ObjectDelta focusPrimaryDelta = (ObjectDelta) getFocusPrimaryDelta(); - //noinspection unchecked - ObjectDelta focusSecondaryDelta = (ObjectDelta) getFocusSecondaryDelta(); + //noinspection unchecked,rawtypes + ObjectDelta focusPrimaryDelta = (ObjectDelta) getFocusPrimaryDelta(); + //noinspection unchecked,rawtypes + ObjectDelta focusSecondaryDelta = (ObjectDelta) getFocusSecondaryDelta(); if (focusPrimaryDelta == null && focusSecondaryDelta == null) { LOGGER.trace("getFocusPasswordFromEvent: No password in executed delta(s) and no primary/secondary deltas"); return null; @@ -313,7 +313,7 @@ public String getFocusPassword() { return null; } - private String getPasswordFromDeltas(List> deltas) { + private String getPasswordFromDeltas(List> deltas) { try { return getMidpointFunctions().getPlaintextUserPasswordFromDeltas(deltas); } catch (EncryptionException e) { diff --git a/model/notifications-impl/src/test/java/com/evolveum/midpoint/notifications/impl/TestTextFormatter.java b/model/notifications-impl/src/test/java/com/evolveum/midpoint/notifications/impl/TestTextFormatter.java index 77d0f29ee9d..9d3a615c1bc 100644 --- a/model/notifications-impl/src/test/java/com/evolveum/midpoint/notifications/impl/TestTextFormatter.java +++ b/model/notifications-impl/src/test/java/com/evolveum/midpoint/notifications/impl/TestTextFormatter.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2010-2017 Evolveum and contributors * * This work is dual-licensed under the Apache License 2.0 @@ -6,6 +6,7 @@ */ package com.evolveum.midpoint.notifications.impl; +import static com.evolveum.midpoint.test.IntegrationTestTools.display; import static org.testng.AssertJUnit.assertFalse; import static org.testng.AssertJUnit.assertTrue; @@ -177,14 +178,14 @@ public void test010FormatUser() throws Exception { @Test public void test020FormatUserDelta() throws Exception { - given(); + // GIVEN ObjectDelta delta = parseDelta(USER_JACK_MODIFICATION_FILE); PrismObject jack = PrismTestUtil.parseObject(new File(USER_JACK_FILE)); System.out.println(delta.debugDump()); - when(); + // WHEN String deltaFormattedHideNone = textFormatter.formatObjectModificationDelta(delta, null, true, jack, null); System.out.println("no hidden paths + show operational attributes: " + deltaFormattedHideNone); @@ -198,7 +199,7 @@ public void test020FormatUserDelta() throws Exception { String deltaFormattedHideAuxAndOper = textFormatter.formatObjectModificationDelta(delta, auxiliaryPaths, false, jack, null); System.out.println("hide auxiliary paths + hide operational attributes: " + deltaFormattedHideAuxAndOper); - then(); + // THEN checkNotes(deltaFormattedHideAux); checkNotes(deltaFormattedHideAuxAndOper); @@ -246,12 +247,12 @@ private void checkNotes(String notification) { @Test public void test030FormatAccount() throws Exception { - given(); + // GIVEN PrismObject jack = PrismTestUtil.parseObject(new File(ACCOUNT_JACK_FILE)); System.out.println(jack.debugDump()); - when(); + // WHEN String jackFormattedHideNone = valueFormatter.formatAccountAttributes(jack.asObjectable(), null, true); System.out.println("no hidden paths + show operational attributes: " + jackFormattedHideNone); @@ -259,7 +260,7 @@ public void test030FormatAccount() throws Exception { String jackFormattedHideAux = valueFormatter.formatAccountAttributes(jack.asObjectable(), auxiliaryPaths, true); System.out.println("hide auxiliary paths + show operational attributes: " + jackFormattedHideAux); - then(); + // THEN final String NAME = "Name: jack"; final String PASSWORD = "(protected string)"; @@ -301,7 +302,7 @@ public void test030FormatAccount() throws Exception { @Test public void test050FormatDeltaWithOperAndAuxItems() throws Exception { - given(); + // GIVEN PrismObject jack = PrismTestUtil.parseObject(new File(USER_JACK_FILE)); display("jack", jack.debugDump()); @@ -317,7 +318,7 @@ public void test050FormatDeltaWithOperAndAuxItems() throws Exception { display("delta", delta.debugDump()); - when(); + // WHEN String deltaFormattedHideNone = textFormatter.formatObjectModificationDelta(delta, null, true, jack, null); System.out.println("no hidden paths + show operational attributes:\n" + deltaFormattedHideNone); @@ -331,7 +332,7 @@ public void test050FormatDeltaWithOperAndAuxItems() throws Exception { String deltaFormattedHideAuxAndOper = textFormatter.formatObjectModificationDelta(delta, auxiliaryPaths, false, jack, null); System.out.println("hide auxiliary paths + hide operational attributes:\n" + deltaFormattedHideAuxAndOper); - then(); + // THEN // TODO create some asserts here