Search in sources :

Example 1 with SerializationException

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());
    }
}
Also used : SerializationException(org.apache.commons.lang3.SerializationException) Component(java.awt.Component) JMenuItem(javax.swing.JMenuItem) JPopupMenu(javax.swing.JPopupMenu)

Example 2 with SerializationException

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
        }
    }
}
Also used : SerializationException(org.apache.commons.lang3.SerializationException) DeserializationPostInitialisable(org.mule.runtime.core.privileged.store.DeserializationPostInitialisable) ClassLoaderObjectInputStream(org.apache.commons.io.input.ClassLoaderObjectInputStream) IOException(java.io.IOException) SerializationException(org.apache.commons.lang3.SerializationException) IOException(java.io.IOException) ObjectInputStream(java.io.ObjectInputStream) ClassLoaderObjectInputStream(org.apache.commons.io.input.ClassLoaderObjectInputStream)

Example 3 with SerializationException

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);
}
Also used : Description(org.springframework.context.annotation.Description) SysSystem(eu.bcvsolutions.idm.acc.entity.SysSystem) AbstractInitApplicationProcessor(eu.bcvsolutions.idm.core.api.event.processor.AbstractInitApplicationProcessor) SysSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemFilter) SysSystemService(eu.bcvsolutions.idm.acc.service.api.SysSystemService) Autowired(org.springframework.beans.factory.annotation.Autowired) BooleanUtils(org.apache.commons.lang3.BooleanUtils) ConfigurationService(eu.bcvsolutions.idm.core.api.service.ConfigurationService) StringUtils(org.apache.commons.lang3.StringUtils) SysConnectorServerDto(eu.bcvsolutions.idm.acc.dto.SysConnectorServerDto) SysRemoteServer(eu.bcvsolutions.idm.acc.entity.SysRemoteServer) Objects(java.util.Objects) CoreEvent(eu.bcvsolutions.idm.core.api.event.CoreEvent) List(java.util.List) Component(org.springframework.stereotype.Component) ConfidentialStorage(eu.bcvsolutions.idm.core.api.service.ConfidentialStorage) Lists(com.google.common.collect.Lists) SerializationException(org.apache.commons.lang3.SerializationException) SysRemoteServerService(eu.bcvsolutions.idm.acc.service.api.SysRemoteServerService) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) EventResult(eu.bcvsolutions.idm.core.api.event.EventResult) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) EntityEvent(eu.bcvsolutions.idm.core.api.event.EntityEvent) ModuleDescriptorDto(eu.bcvsolutions.idm.core.api.dto.ModuleDescriptorDto) SysSystem(eu.bcvsolutions.idm.acc.entity.SysSystem) SerializationException(org.apache.commons.lang3.SerializationException) SysSystemFilter(eu.bcvsolutions.idm.acc.dto.filter.SysSystemFilter) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) SysConnectorServerDto(eu.bcvsolutions.idm.acc.dto.SysConnectorServerDto) SysRemoteServer(eu.bcvsolutions.idm.acc.entity.SysRemoteServer)

Example 4 with SerializationException

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);
}
Also used : lombok.val(lombok.val) SerializationException(org.apache.commons.lang3.SerializationException) Test(org.junit.Test)

Example 5 with 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();
}
Also used : SerializationException(org.apache.commons.lang3.SerializationException) Test(org.junit.Test) AbstractTest(com.ctrip.xpipe.AbstractTest)

Aggregations

SerializationException (org.apache.commons.lang3.SerializationException)5 Test (org.junit.Test)2 AbstractTest (com.ctrip.xpipe.AbstractTest)1 Lists (com.google.common.collect.Lists)1 SysConnectorServerDto (eu.bcvsolutions.idm.acc.dto.SysConnectorServerDto)1 SysSystemFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSystemFilter)1 SysRemoteServer (eu.bcvsolutions.idm.acc.entity.SysRemoteServer)1 SysSystem (eu.bcvsolutions.idm.acc.entity.SysSystem)1 SysRemoteServerService (eu.bcvsolutions.idm.acc.service.api.SysRemoteServerService)1 SysSystemService (eu.bcvsolutions.idm.acc.service.api.SysSystemService)1 ModuleDescriptorDto (eu.bcvsolutions.idm.core.api.dto.ModuleDescriptorDto)1 CoreEvent (eu.bcvsolutions.idm.core.api.event.CoreEvent)1 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)1 EntityEvent (eu.bcvsolutions.idm.core.api.event.EntityEvent)1 EventResult (eu.bcvsolutions.idm.core.api.event.EventResult)1 AbstractInitApplicationProcessor (eu.bcvsolutions.idm.core.api.event.processor.AbstractInitApplicationProcessor)1 ConfidentialStorage (eu.bcvsolutions.idm.core.api.service.ConfidentialStorage)1 ConfigurationService (eu.bcvsolutions.idm.core.api.service.ConfigurationService)1 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)1 Component (java.awt.Component)1