use of javax.naming.NoPermissionException in project midpoint by Evolveum.
the class ConnIdUtil method lookForKnownCause.
private static Exception lookForKnownCause(Throwable ex, Throwable originalException, OperationResult parentResult) {
if (ex instanceof FileNotFoundException) {
//fix MID-2711 consider FileNotFoundException as CommunicationException
Exception newEx = new com.evolveum.midpoint.util.exception.CommunicationException(createMessageFromAllExceptions(null, ex));
parentResult.recordFatalError("File not found: " + ex.getMessage(), newEx);
return newEx;
} else if (ex instanceof NameAlreadyBoundException) {
// This is thrown by LDAP connector and may be also throw by similar
// connectors
Exception newEx = new ObjectAlreadyExistsException(createMessageFromAllExceptions(null, ex));
parentResult.recordFatalError("Object already exists: " + ex.getMessage(), newEx);
return newEx;
} else if (ex instanceof javax.naming.CommunicationException) {
// This is thrown by LDAP connector and may be also throw by similar
// connectors
Exception newEx = new CommunicationException(createMessageFromAllExceptions("Communication error", ex));
parentResult.recordFatalError("Communication error: " + ex.getMessage(), newEx);
return newEx;
} else if (ex instanceof ServiceUnavailableException) {
// In some cases (e.g. JDK 1.6.0_31) this is thrown by LDAP connector and may be also throw by similar
// connectors
Exception newEx = new CommunicationException(createMessageFromAllExceptions("Communication error", ex));
parentResult.recordFatalError("Communication error: " + ex.getMessage(), newEx);
return newEx;
} else if (ex instanceof ConnectionBrokenException) {
Exception newEx = new CommunicationException(createMessageFromAllExceptions("Communication error", ex));
parentResult.recordFatalError("Communication error: " + ex.getMessage(), newEx);
return newEx;
} else if (ex instanceof ConnectionFailedException) {
Exception newEx = new CommunicationException(createMessageFromAllExceptions("Communication error", ex));
parentResult.recordFatalError("Communication error: " + ex.getMessage(), newEx);
return newEx;
} else if (ex instanceof SchemaViolationException) {
// This is thrown by LDAP connector and may be also throw by similar
// connectors
Exception newEx = new SchemaException(createMessageFromAllExceptions("Schema violation", ex));
parentResult.recordFatalError("Schema violation: " + ex.getMessage(), newEx);
return newEx;
} else if (ex instanceof org.identityconnectors.framework.common.exceptions.InvalidAttributeValueException) {
Exception newEx = new SchemaException(createMessageFromAllExceptions("Invalid attribute", ex));
parentResult.recordFatalError("Invalid attribute: " + ex.getMessage(), newEx);
return newEx;
} else if (ex instanceof InvalidAttributeValueException) {
// This is thrown by LDAP connector and may be also throw by similar
// connectors
InvalidAttributeValueException e = (InvalidAttributeValueException) ex;
Exception newEx = null;
if (e.getExplanation().contains("unique attribute conflict")) {
newEx = new ObjectAlreadyExistsException(createMessageFromAllExceptions("Invalid attribute", ex));
} else {
newEx = new SchemaException(createMessageFromAllExceptions("Invalid attribute", ex));
}
parentResult.recordFatalError("Invalid attribute: " + ex.getMessage(), newEx);
return newEx;
} else if (ex instanceof ConnectException) {
// Buried deep in many exceptions, usually connection refused or
// similar errors
// Note: needs to be after javax.naming.CommunicationException as the
// javax.naming exception has more info (e.g. hostname)
Exception newEx = new CommunicationException(createMessageFromAllExceptions("Connect error", ex));
parentResult.recordFatalError("Connect error: " + ex.getMessage(), newEx);
return newEx;
} else if (ex instanceof SQLSyntaxErrorException) {
// Buried deep in many exceptions, usually DB schema problems of
// DB-based connectors
Exception newEx = new SchemaException(createMessageFromAllExceptions("DB syntax error", ex));
parentResult.recordFatalError("DB syntax error: " + ex.getMessage(), newEx);
return newEx;
} else if (ex instanceof SQLException) {
// Buried deep in many exceptions, usually DB connection problems
Exception newEx = new GenericFrameworkException(createMessageFromAllExceptions("DB error", ex));
parentResult.recordFatalError("DB error: " + ex.getMessage(), newEx);
return newEx;
} else if (ex instanceof UnknownUidException) {
// Object not found
Exception newEx = new ObjectNotFoundException(createMessageFromAllExceptions(null, ex));
parentResult.recordFatalError("Object not found: " + ex.getMessage(), newEx);
return newEx;
} else if (ex instanceof NoPermissionException) {
Exception newEx = new SecurityViolationException(createMessageFromAllExceptions(null, ex));
parentResult.recordFatalError("Object not found: " + ex.getMessage(), newEx);
return newEx;
} else if (ex instanceof AttributeInUseException) {
Exception newEx = new SchemaException(createMessageFromAllExceptions(null, ex));
parentResult.recordFatalError("Attribute in use: " + ex.getMessage(), newEx);
return newEx;
} else if (ex instanceof NoSuchAttributeException) {
Exception newEx = new SchemaException(createMessageFromAllExceptions(null, ex));
parentResult.recordFatalError("No such attribute: " + ex.getMessage(), newEx);
return newEx;
}
if (ex.getCause() == null) {
// found nothing
return null;
} else {
// Otherwise go one level deeper ...
return lookForKnownCause(ex.getCause(), originalException, parentResult);
}
}
use of javax.naming.NoPermissionException in project geode by apache.
the class ContextJUnitTest method testSubcontextInvokingMethodsOnDestroyedContext.
/**
* Tests inability to invoke methods on destroyed subcontexts.
*/
@Test
public void testSubcontextInvokingMethodsOnDestroyedContext() throws Exception {
// Create subcontext and destroy it.
Context sub = dataSourceContext.createSubcontext("sub4");
initialContext.destroySubcontext("java:gf/env/datasource/sub4");
try {
sub.bind("name", "object");
fail();
} catch (NoPermissionException expected) {
}
try {
sub.unbind("name");
fail();
} catch (NoPermissionException expected) {
}
try {
sub.createSubcontext("sub5");
fail();
} catch (NoPermissionException expected) {
}
try {
sub.destroySubcontext("sub6");
fail();
} catch (NoPermissionException expected) {
}
try {
sub.list("");
fail();
} catch (NoPermissionException expected) {
}
try {
sub.lookup("name");
fail();
} catch (NoPermissionException expected) {
}
try {
sub.composeName("name", "prefix");
fail();
} catch (NoPermissionException expected) {
}
try {
NameParserImpl parser = new NameParserImpl();
sub.composeName(parser.parse("a"), parser.parse("b"));
fail();
} catch (NoPermissionException expected) {
}
}
Aggregations