Skip to content

Commit

Permalink
Fix compilation errors after cherry-picking
Browse files Browse the repository at this point in the history
These deal with User->Focus generalization w.r.t. passwords.
(These are in UserType only in 4.0.x.)
  • Loading branch information
mederly committed Mar 14, 2020
1 parent e136c2e commit ce81807
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 24 deletions.
Expand Up @@ -991,15 +991,15 @@ Collection<String> getManagersOidsExceptUser(@NotNull Collection<ObjectReference

boolean isMemberOf(UserType user, String orgOid);

String getPlaintextUserPassword(FocusType user) throws EncryptionException;
String getPlaintextUserPassword(UserType user) throws EncryptionException;

String getPlaintext(ProtectedStringType user) throws EncryptionException;

String getPlaintextAccountPassword(ShadowType account) throws EncryptionException;

String getPlaintextAccountPasswordFromDelta(ObjectDelta<? extends ShadowType> delta) throws EncryptionException;

String getPlaintextUserPasswordFromDeltas(List<ObjectDelta<? extends FocusType>> deltas) throws EncryptionException;
String getPlaintextUserPasswordFromDeltas(List<ObjectDelta<UserType>> deltas) throws EncryptionException;

Task getCurrentTask();

Expand Down
Expand Up @@ -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?
}
Expand Down Expand Up @@ -256,15 +256,15 @@ private void takePasswordsFromItemDelta(List<ProtectedStringType> passwords, Ite
}

@Override
public String getPlaintextUserPasswordFromDeltas(List<ObjectDelta<? extends FocusType>> objectDeltas) throws EncryptionException {
public String getPlaintextUserPasswordFromDeltas(List<ObjectDelta<UserType>> objectDeltas) throws EncryptionException {

List<ProtectedStringType> passwords = new ArrayList<>();

for (ObjectDelta<? extends FocusType> delta : objectDeltas) {
for (ObjectDelta<UserType> 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()) {
Expand Down
Expand Up @@ -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
Expand All @@ -287,10 +287,10 @@ public String getFocusPassword() {
return passwordFromDeltas;
}

//noinspection unchecked
ObjectDelta<FocusType> focusPrimaryDelta = (ObjectDelta) getFocusPrimaryDelta();
//noinspection unchecked
ObjectDelta<FocusType> focusSecondaryDelta = (ObjectDelta) getFocusSecondaryDelta();
//noinspection unchecked,rawtypes
ObjectDelta<UserType> focusPrimaryDelta = (ObjectDelta) getFocusPrimaryDelta();
//noinspection unchecked,rawtypes
ObjectDelta<UserType> focusSecondaryDelta = (ObjectDelta) getFocusSecondaryDelta();
if (focusPrimaryDelta == null && focusSecondaryDelta == null) {
LOGGER.trace("getFocusPasswordFromEvent: No password in executed delta(s) and no primary/secondary deltas");
return null;
Expand All @@ -313,7 +313,7 @@ public String getFocusPassword() {
return null;
}

private String getPasswordFromDeltas(List<ObjectDelta<? extends FocusType>> deltas) {
private String getPasswordFromDeltas(List<ObjectDelta<UserType>> deltas) {
try {
return getMidpointFunctions().getPlaintextUserPasswordFromDeltas(deltas);
} catch (EncryptionException e) {
Expand Down
@@ -1,11 +1,12 @@
/**
/*
* Copyright (c) 2010-2017 Evolveum and contributors
*
* This work is dual-licensed under the Apache License 2.0
* and European Union Public License. See LICENSE file for details.
*/
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;

Expand Down Expand Up @@ -177,14 +178,14 @@ public void test010FormatUser() throws Exception {
@Test
public void test020FormatUserDelta() throws Exception {

given();
// GIVEN

ObjectDelta<UserType> delta = parseDelta(USER_JACK_MODIFICATION_FILE);
PrismObject<UserType> 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);
Expand All @@ -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);
Expand Down Expand Up @@ -246,20 +247,20 @@ private void checkNotes(String notification) {
@Test
public void test030FormatAccount() throws Exception {

given();
// GIVEN

PrismObject<ShadowType> 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);

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)";
Expand Down Expand Up @@ -301,7 +302,7 @@ public void test030FormatAccount() throws Exception {
@Test
public void test050FormatDeltaWithOperAndAuxItems() throws Exception {

given();
// GIVEN

PrismObject<UserType> jack = PrismTestUtil.parseObject(new File(USER_JACK_FILE));
display("jack", jack.debugDump());
Expand All @@ -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);
Expand All @@ -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

Expand Down

0 comments on commit ce81807

Please sign in to comment.