// Path: src/main/java/com/tsystems/readyapi/plugin/websocket/Utils.java
// public static String bytesToHexString(byte[] buf) {
//     final String decimals = "0123456789ABCDEF";
//     if (buf == null)
//         return null;
//     char[] r = new char[buf.length * 2];
//     for (int i = 0; i < buf.length; ++i) {
//         r[i * 2] = decimals.charAt((buf[i] & 0xf0) >> 4);
//         r[i * 2 + 1] = decimals.charAt(buf[i] & 0x0f);
//     }
//     return new String(r);
// }
// 
// Path: src/main/java/com/tsystems/readyapi/plugin/websocket/Utils.java
// public static byte[] hexStringToBytes(String str) {
//     if (str == null)
//         return null;
//     if (str.length() % 2 != 0)
//         throw new IllegalArgumentException();
//     byte[] result = new byte[str.length() / 2];
//     try {
//         for (int i = 0; i < result.length; ++i)
//             result[i] = (byte) Short.parseShort(str.substring(i * 2, i * 2 + 2), 16);
//     } catch (NumberFormatException e) {
//         throw new IllegalArgumentException(e);
//     }
//     return result;
// }


import static com.tsystems.readyapi.plugin.websocket.Utils.bytesToHexString;
import static com.tsystems.readyapi.plugin.websocket.Utils.hexStringToBytes;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.util.Objects;
import org.apache.commons.ssl.OpenSSL;
import org.apache.log4j.Logger;
import org.apache.xmlbeans.XmlObject;
import com.eviware.soapui.model.propertyexpansion.PropertyExpansionContext;
import com.eviware.soapui.support.PropertyChangeNotifier;
import com.eviware.soapui.support.xml.XmlObjectConfigurationReader;
        try {
            propertyChangeSupport.removePropertyChangeListener(listener);
        } catch (Throwable t) {
            LOGGER.error(t);
        }
    }

    @Override
    public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
        try {
            propertyChangeSupport.removePropertyChangeListener(propertyName, listener);
        } catch (Throwable t) {
            LOGGER.error(t);
        }
    }

    public XmlObject save() {
        XmlObjectBuilder builder = new XmlObjectBuilder();
        builder.add(NAME_SETTING_NAME, name);
        builder.add(SERVER_URI_SETTING_NAME, originalServerUri);
        if (login != null) {
            builder.add(LOGIN_SETTING_NAME, login);
            if (password != null && password.length() != 0) {
                byte[] encodedPassword = null;
                try {
                    encodedPassword = OpenSSL.encrypt(ENCRYPTION_METHOD, PASSWORD_FOR_ENCODING.toCharArray(),
                            password.getBytes());
                } catch (IOException | GeneralSecurityException e) {
                    LOGGER.error(e);
                }
// Path: src/main/java/com/tsystems/readyapi/plugin/websocket/Utils.java
// public static String bytesToHexString(byte[] buf) {
//     final String decimals = "0123456789ABCDEF";
//     if (buf == null)
//         return null;
//     char[] r = new char[buf.length * 2];
//     for (int i = 0; i < buf.length; ++i) {
//         r[i * 2] = decimals.charAt((buf[i] & 0xf0) >> 4);
//         r[i * 2 + 1] = decimals.charAt(buf[i] & 0x0f);
//     }
//     return new String(r);
// }
// 
// Path: src/main/java/com/tsystems/readyapi/plugin/websocket/Utils.java
// public static byte[] hexStringToBytes(String str) {
//     if (str == null)
//         return null;
//     if (str.length() % 2 != 0)
//         throw new IllegalArgumentException();
//     byte[] result = new byte[str.length() / 2];
//     try {
//         for (int i = 0; i < result.length; ++i)
//             result[i] = (byte) Short.parseShort(str.substring(i * 2, i * 2 + 2), 16);
//     } catch (NumberFormatException e) {
//         throw new IllegalArgumentException(e);
//     }
//     return result;
// }


// Path: src/main/java/com/tsystems/readyapi/plugin/websocket/Connection.java
import static com.tsystems.readyapi.plugin.websocket.Utils.bytesToHexString;
import static com.tsystems.readyapi.plugin.websocket.Utils.hexStringToBytes;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.util.Objects;
import org.apache.commons.ssl.OpenSSL;
import org.apache.log4j.Logger;
import org.apache.xmlbeans.XmlObject;
import com.eviware.soapui.model.propertyexpansion.PropertyExpansionContext;
import com.eviware.soapui.support.PropertyChangeNotifier;
import com.eviware.soapui.support.xml.XmlObjectConfigurationReader;

        try {
            propertyChangeSupport.removePropertyChangeListener(listener);
        } catch (Throwable t) {
            LOGGER.error(t);
        }
    }

    @Override
    public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
        try {
            propertyChangeSupport.removePropertyChangeListener(propertyName, listener);
        } catch (Throwable t) {
            LOGGER.error(t);
        }
    }

    public XmlObject save() {
        XmlObjectBuilder builder = new XmlObjectBuilder();
        builder.add(NAME_SETTING_NAME, name);
        builder.add(SERVER_URI_SETTING_NAME, originalServerUri);
        if (login != null) {
            builder.add(LOGIN_SETTING_NAME, login);
            if (password != null && password.length() != 0) {
                byte[] encodedPassword = null;
                try {
                    encodedPassword = OpenSSL.encrypt(ENCRYPTION_METHOD, PASSWORD_FOR_ENCODING.toCharArray(),
                            password.getBytes());
                } catch (IOException | GeneralSecurityException e) {
                    LOGGER.error(e);
                }
                builder.add(ENCR_PASSWORD_SETTING_NAME, bytesToHexString(encodedPassword));