use of eu.bcvsolutions.idm.core.api.exception.CoreException in project CzechIdMng by bcvsolutions.
the class DefaultIdmProcessedTaskItemDtoServiceTest method testItemTypeReference.
@Test
public void testItemTypeReference() {
IdmScheduledTaskDto d = helper.createSchedulableTask();
IdmLongRunningTaskDto lrt = this.createLongRunningTask(d);
IdmProcessedTaskItemDto item = helper.prepareProcessedItem(lrt);
//
try {
item.setScheduledTaskQueueOwner(d.getId());
service.get(service.saveInternal(item).getId());
fail("Both log and queue association is forbidden.");
} catch (CoreException e) {
assertNotNull(e.getMessage());
}
//
try {
item.setScheduledTaskQueueOwner(null);
item.setLongRunningTask(null);
service.get(service.saveInternal(item).getId());
fail("Empty log and queue association is forbidden.");
} catch (CoreException e) {
assertNotNull(e.getMessage());
}
}
use of eu.bcvsolutions.idm.core.api.exception.CoreException in project CzechIdMng by bcvsolutions.
the class ConnIdIcConfigurationService method toStandardJavaUrl.
/**
* Transformation the Url to standard Java Url (for the JBoss VFS problem)
*
* We have to create new instance of URL, because we don't want use the URL with
* 'vfs' protocol. This happens on the WildFly server (where are connectors
* copied to temp folder -> problem with non exists MANIFEST in the ConnId).
*
* @param url
* @return
*/
private URL toStandardJavaUrl(URL url) {
if (url == null) {
return null;
}
if (URL_PROTOCOL_VFS.equals(url.getProtocol())) {
try {
VirtualFile vf = VFS.getChild(url.toURI());
URL physicalUrl = VFSUtils.getPhysicalURL(vf);
// Workaround ... replace contents folder with name of file
URL resultUrl = new URL(URL_PROTOCOL_FILE, physicalUrl.getHost(), physicalUrl.getFile().replace("/contents/", "/" + vf.getName()));
return resultUrl;
} catch (Exception e) {
throw new CoreException("JBoss VFS URL transformation failed", e);
}
}
return url;
}
use of eu.bcvsolutions.idm.core.api.exception.CoreException in project CzechIdMng by bcvsolutions.
the class IcInitDataProcessor method process.
@Override
public EventResult<ModuleDescriptorDto> process(EntityEvent<ModuleDescriptorDto> event) {
LOG.info("Initialization [{}] module...", IcModuleDescriptor.MODULE_ID);
// ConnId using logger implementation, what cannot be configured (printing
// always). We need change the implementation to JDKLogger.
// Second way how configuring that property, is create property file
// 'connectors.properties' in the java home (jre/lib), witch will contains same
// property.
System.setProperty(PROPERTY_CONNID_LOGGER_IMPLEMENTATION, JDKLogger.class.getName());
// VŠ: I had to use this hard code. Because logger in Connid is cached and calls before this initialisation.
try {
Method spiClassMethod = Arrays.asList(Log.class.getDeclaredMethods()).stream().filter(propertyDescriptor -> {
return PROPERTY_SET_LOGGER.equals(propertyDescriptor.getName());
}).findFirst().orElse(null);
spiClassMethod.setAccessible(true);
spiClassMethod.invoke(Log.class, new Object[] { null });
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
throw new CoreException(e);
}
//
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.core.api.exception.CoreException in project CzechIdMng by bcvsolutions.
the class AbstractReadWriteDtoControllerRestTest method getBaseUrl.
/**
* Entry point url
*
* @return
*/
protected String getBaseUrl() {
Class<?> clazz = AopUtils.getTargetClass(getController());
RequestMapping mapping = clazz.getAnnotation(RequestMapping.class);
if (mapping.value().length > 0) {
return mapping.value()[0];
}
if (mapping.path().length > 0) {
return mapping.path()[0];
}
throw new CoreException("Controller [" + clazz + "] doeasn't have default mapping, cannot be tested by this abstraction.");
}
use of eu.bcvsolutions.idm.core.api.exception.CoreException in project CzechIdMng by bcvsolutions.
the class AdUserConnectorType method getServerCertificate.
/**
* Get server certificates.
*/
private Pair<X509Certificate, Boolean> getServerCertificate(String port, String host) {
try {
SSLSocket socket = null;
try {
socket = (SSLSocket) SSLSocketFactory.getDefault().createSocket(host, Integer.parseInt(port));
socket.startHandshake();
LOG.info("Certificate is already trusted for connection to the AD.");
SSLSession session = socket.getSession();
Certificate[] peerCertificates = session.getPeerCertificates();
if (peerCertificates.length > 0) {
return new Pair<>((X509Certificate) peerCertificates[0], Boolean.TRUE);
}
} catch (SSLException e) {
LOG.info("Certificate is not trusted for connection to the AD.");
SSLContext context = SSLContext.getInstance("TLS");
// Workaround how get server certificates from the AD server if the IdM server doesn't have trusted certificate yet.
SavingTrustManager tm = new SavingTrustManager();
context.init(null, new TrustManager[] { tm }, null);
SSLSocketFactory factory = context.getSocketFactory();
if (socket != null && !socket.isClosed()) {
socket.close();
}
socket = (SSLSocket) factory.createSocket(host, Integer.parseInt(port));
socket.setSoTimeout(10000);
// Start handshake. In the case without check a trusted certificate.
socket.startHandshake();
X509Certificate[] chain = tm.chain;
if (chain.length > 0) {
return new Pair<>(chain[0], Boolean.FALSE);
}
} finally {
if (socket != null && !socket.isClosed()) {
socket.close();
}
}
} catch (IOException | NoSuchAlgorithmException | KeyManagementException ex) {
throw new CoreException(ex.getLocalizedMessage(), ex);
}
return null;
}
Aggregations