Skip to content

Commit

Permalink
ConnIdUtil.java: cleanup, removed unused parameter, dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
virgo47 committed Mar 6, 2020
1 parent a30ecaa commit f5ddd8a
Showing 1 changed file with 5 additions and 15 deletions.
Expand Up @@ -10,7 +10,6 @@
import java.io.FileNotFoundException;
import java.lang.reflect.InvocationTargetException;
import java.net.ConnectException;
import java.net.UnknownHostException;
import java.sql.SQLException;
import java.sql.SQLSyntaxErrorException;
import java.util.ArrayList;
Expand All @@ -33,7 +32,6 @@
import com.evolveum.midpoint.util.exception.SystemException;
import com.evolveum.midpoint.util.logging.LoggingUtils;

import org.identityconnectors.common.security.GuardedByteArray;
import org.identityconnectors.common.security.GuardedString;
import org.identityconnectors.framework.common.exceptions.*;
import org.identityconnectors.framework.common.objects.Attribute;
Expand All @@ -49,7 +47,6 @@
import com.evolveum.midpoint.prism.crypto.Protector;
import com.evolveum.midpoint.prism.polystring.PolyString;
import com.evolveum.midpoint.prism.xml.XmlTypeConverter;
import com.evolveum.midpoint.prism.xml.XsdTypeMapper;
import com.evolveum.midpoint.provisioning.ucf.api.GenericFrameworkException;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition;
Expand All @@ -59,7 +56,6 @@
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.util.PrettyPrinter;
import com.evolveum.midpoint.util.exception.CommonException;
import com.evolveum.midpoint.util.exception.CommunicationException;
import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException;
import com.evolveum.midpoint.util.exception.ObjectNotFoundException;
Expand All @@ -68,7 +64,6 @@
import com.evolveum.midpoint.util.exception.SecurityViolationException;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.prism.xml.ns._public.types_3.ProtectedByteArrayType;
import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType;

import org.identityconnectors.framework.impl.api.remote.RemoteWrappedException;
Expand Down Expand Up @@ -228,7 +223,7 @@ static Throwable processConnIdException(Throwable connIdException, String desc,
}

// Introspect the inner exceptions and look for known causes
knownCause = lookForKnownCause(connIdException, connIdException, connIdResult);
knownCause = lookForKnownCause(connIdException, connIdResult);
if (knownCause != null) {
// LOGGER.error("LOOK FOR KNOWN EXCEPTION: {} -> {}", connIdException.getClass().getName(), knownCause.getClass().getName());
connIdResult.recordFatalError(knownCause);
Expand Down Expand Up @@ -313,7 +308,7 @@ private static Exception processConnectorException(ConnectorException connIdExce

} else if (connIdException instanceof RetryableException) {
Exception newEx = new CommunicationException(createMessageFromAllExceptions(null, connIdException));
connIdResult.recordFatalError("Retryable errror: " + connIdException.getMessage(), newEx);
connIdResult.recordFatalError("Retryable error: " + connIdException.getMessage(), newEx);
return newEx;

} else if (connIdException instanceof ConnectorSecurityException) {
Expand All @@ -335,9 +330,7 @@ private static Exception processConnectorException(ConnectorException connIdExce
return null;
}

private static Exception lookForKnownCause(Throwable ex,
Throwable originalException, OperationResult parentResult) {

private static Exception lookForKnownCause(Throwable ex, OperationResult parentResult) {
if (ex.getClass().getPackage().equals(SchemaException.class.getPackage())) {
// Common midPoint exceptions, pass through
// Those may get here from the inner calls of handle() methods from the connector.
Expand Down Expand Up @@ -378,7 +371,7 @@ private static Exception lookForKnownCause(Throwable ex,
// This is thrown by LDAP connector and may be also throw by similar
// connectors
javax.naming.directory.InvalidAttributeValueException e = (javax.naming.directory.InvalidAttributeValueException) ex;
Exception newEx = null;
Exception newEx;
if (e.getExplanation().contains("unique attribute conflict")){
newEx = new ObjectAlreadyExistsException(createMessageFromAllExceptions("Invalid attribute", ex));
} else{
Expand Down Expand Up @@ -431,7 +424,7 @@ private static Exception lookForKnownCause(Throwable ex,
return null;
} else {
// Otherwise go one level deeper ...
return lookForKnownCause(ex.getCause(), originalException,
return lookForKnownCause(ex.getCause(),
parentResult);
}
}
Expand Down Expand Up @@ -666,14 +659,11 @@ public static GuardedString toGuardedString(ProtectedStringType ps, Protector pr
if (ps.getClearValue() == null) {
return null;
}
// LOGGER.warn("Using cleartext value for {}", propertyName);
return new GuardedString(ps.getClearValue().toCharArray());
}
try {
return new GuardedString(protector.decryptString(ps).toCharArray());
} catch (EncryptionException e) {
// LOGGER.error("Unable to decrypt value of element {}: {}",
// new Object[] { propertyName, e.getMessage(), e });
throw new SystemException("Unable to decrypt value of element " + propertyName + ": "
+ e.getMessage(), e);
}
Expand Down

0 comments on commit f5ddd8a

Please sign in to comment.