use of org.apache.commons.lang3.SerializationException in project jsql-injection by ron190.
the class TabSelectionMouseHandler method mouseClicked.
@Override
public void mouseClicked(MouseEvent e) {
if (SwingUtilities.isRightMouseButton(e)) {
Component componentSource = (Component) e.getSource();
JPopupMenu menu = new JPopupMenu();
for (int position = 0; position < MediatorGui.menubar().getMenuView().getMenuComponentCount(); position++) {
// Fix #35348: SerializationException on clone()
try {
JMenuItem itemMenu = (JMenuItem) SerializationUtils.clone(MediatorGui.menubar().getMenuView().getMenuComponent(position));
menu.add(itemMenu);
final int positionFinal = position;
itemMenu.addActionListener(actionEvent -> MediatorGui.tabManagers().setSelectedIndex(positionFinal));
} catch (SerializationException ex) {
LOGGER.error(ex, ex);
}
}
menu.show(componentSource, e.getX(), e.getY());
menu.setLocation(ComponentOrientation.getOrientation(I18n.getLocaleDefault()) == ComponentOrientation.RIGHT_TO_LEFT ? e.getXOnScreen() - menu.getWidth() : e.getXOnScreen(), e.getYOnScreen());
}
}
use of org.apache.commons.lang3.SerializationException in project mule by mulesoft.
the class SerializationUtils method deserialize.
/**
* <p>
* Deserializes an <code>Object</code> from the specified stream.
* </p>
* <p/>
* <p>
* The stream will be closed once the object is written. This avoids the need for a finally clause, and maybe also exception
* handling, in the application code.
* </p>
* <p/>
* <p>
* The stream passed in is not buffered internally within this method. This is the responsibility of your application if
* desired.
* </p>
*
* @param inputStream the serialized object input stream, must not be null
* @param cl classloader which can load custom classes from the stream
* @return the deserialized object
* @throws IllegalArgumentException if <code>inputStream</code> is <code>null</code>
* @throws org.apache.commons.lang3.SerializationException (runtime) if the serialization fails
*/
public static Object deserialize(InputStream inputStream, ClassLoader cl, MuleContext muleContext) {
if (inputStream == null) {
throw new IllegalArgumentException("The InputStream must not be null");
}
if (cl == null) {
throw new IllegalArgumentException("The ClassLoader must not be null");
}
ObjectInputStream in = null;
try {
// stream closed in the finally
in = new ClassLoaderObjectInputStream(cl, inputStream);
Object obj = in.readObject();
if (obj instanceof DeserializationPostInitialisable) {
DeserializationPostInitialisable.Implementation.init(obj, muleContext);
}
return obj;
} catch (ClassNotFoundException ex) {
throw new SerializationException(ex);
} catch (IOException ex) {
throw new SerializationException(ex);
} catch (Exception ex) {
throw new SerializationException(ex);
} finally {
try {
if (in != null) {
in.close();
}
} catch (IOException ex) {
// ignore close exception
}
}
}
use of org.apache.commons.lang3.SerializationException in project CzechIdMng by bcvsolutions.
the class AccInitRemoteServerProcessor method process.
@Override
public EventResult<ModuleDescriptorDto> process(EntityEvent<ModuleDescriptorDto> event) {
// all remote systems => will be two at max
List<SysConnectorServerDto> remoteServers = Lists.newArrayList(remoteServerService.find(null).getContent());
// fill password
remoteServers.forEach(remoteServer -> {
remoteServer.setPassword(confidentialStorage.getGuardedString(remoteServer.getId(), SysRemoteServer.class, SysSystemService.REMOTE_SERVER_PASSWORD));
});
//
// find all systems with remote flag and empty related remoteServer
SysSystemFilter systemFilter = new SysSystemFilter();
systemFilter.setRemote(Boolean.TRUE);
systemService.find(systemFilter, null).stream().filter(// remote server is not referenced => old definition with remote flag
system -> Objects.isNull(system.getRemoteServer())).filter(system -> {
// remote server is properly filled
// cannot be filled from frontend, but just for sure
SysConnectorServerDto connectorServer = system.getConnectorServer();
if (connectorServer == null) {
return false;
}
return StringUtils.isNotBlank(connectorServer.getHost());
}).forEach(system -> {
SysConnectorServerDto systemConnector = system.getConnectorServer();
try {
systemConnector.setPassword(confidentialStorage.getGuardedString(system.getId(), SysSystem.class, SysSystemService.REMOTE_SERVER_PASSWORD));
} catch (SerializationException ex) {
LOG.error("Password for configured system [{}] is broken, will be ignored.", system.getCode());
}
// try to find remote system by all fields
SysConnectorServerDto remoteServer = remoteServers.stream().filter(r -> {
return StringUtils.equals(r.getHost(), systemConnector.getHost()) && Integer.compare(r.getPort(), systemConnector.getPort()) == 0 && BooleanUtils.compare(r.isUseSsl(), systemConnector.isUseSsl()) == 0 && Integer.compare(r.getTimeout(), systemConnector.getTimeout()) == 0 && (// password is broken, e.g. when confidential storage was dropped
systemConnector.getPassword() == null || StringUtils.equals(r.getPassword().asString(), systemConnector.getPassword().asString()));
}).findFirst().orElse(null);
//
if (remoteServer != null) {
LOG.info("Remote server [{}] will be used for configured system [{}].", remoteServer.getFullServerName(), system.getCode());
system.setRemoteServer(remoteServer.getId());
systemService.save(system);
} else {
String systemCode = system.getCode();
systemConnector.setDescription(String.format("Created automatically by upgrade to CzechIdM version 10.8.0 by target system [%s].", systemCode));
GuardedString password = systemConnector.getPassword();
remoteServer = remoteServerService.save(systemConnector);
// preserve password
remoteServer.setPassword(password);
remoteServers.add(remoteServer);
system.setRemoteServer(remoteServer.getId());
systemService.save(system);
LOG.info("New remote server [{}] was created and used for configured system [{}].", remoteServer.getFullServerName(), systemCode);
}
});
//
// Turn off for next start => already processed
getConfigurationService().setBooleanValue(getConfigurationPropertyName(ConfigurationService.PROPERTY_ENABLED), false);
//
return new DefaultEventResult<>(event, this);
}
use of org.apache.commons.lang3.SerializationException in project pravega by pravega.
the class VersionImplTests method testFromString.
@Test
public void testFromString() {
val noSegmentVersion = new VersionImpl(VersionImpl.NO_SEGMENT_ID, 1234L);
val s1 = Version.fromString(noSegmentVersion.toString()).asImpl();
Assert.assertEquals(noSegmentVersion, s1);
val withSegmentVersion = new VersionImpl(123L, 567L);
val s2 = Version.fromString(withSegmentVersion.toString()).asImpl();
Assert.assertEquals(withSegmentVersion, s2);
AssertExtensions.assertThrows("Invalid deserialization worked.", () -> Version.fromString("abc"), ex -> ex instanceof SerializationException);
}
use of org.apache.commons.lang3.SerializationException in project x-pipe by ctripcorp.
the class CatTest method testException.
@Test
public /**
* -Dlog4j.configurationFile=log4j2cat.xml
*/
void testException() throws IOException {
logger.error("[testException]", new SerializationException("exception"));
waitForAnyKeyToExit();
}
Aggregations