导航菜单

页面标题

页面副标题

bbinstant v6.24.0 - NoSSLv3SocketFactory.java 源代码

正在查看: bbinstant v6.24.0 应用的 NoSSLv3SocketFactory.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.simpl.approvalsdk.util;

import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.InetAddress;
import java.net.Socket;
import java.net.SocketAddress;
import java.nio.channels.SocketChannel;
import java.util.ArrayList;
import java.util.Arrays;
import javax.net.ssl.HandshakeCompletedListener;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;

public final class NoSSLv3SocketFactory extends SSLSocketFactory {
    private final SSLSocketFactory delegate;

    public class DelegateSSLSocket extends SSLSocket {
        protected final SSLSocket delegate;

        DelegateSSLSocket(SSLSocket sSLSocket) {
            this.delegate = sSLSocket;
        }

        @Override
        public void addHandshakeCompletedListener(HandshakeCompletedListener handshakeCompletedListener) {
            this.delegate.addHandshakeCompletedListener(handshakeCompletedListener);
        }

        @Override
        public void bind(SocketAddress socketAddress) {
            this.delegate.bind(socketAddress);
        }

        @Override
        public synchronized void close() {
            this.delegate.close();
        }

        @Override
        public void connect(SocketAddress socketAddress) {
            this.delegate.connect(socketAddress);
        }

        public boolean equals(Object obj) {
            return this.delegate.equals(obj);
        }

        @Override
        public SocketChannel getChannel() {
            return this.delegate.getChannel();
        }

        @Override
        public boolean getEnableSessionCreation() {
            return this.delegate.getEnableSessionCreation();
        }

        @Override
        public String[] getEnabledCipherSuites() {
            return this.delegate.getEnabledCipherSuites();
        }

        @Override
        public String[] getEnabledProtocols() {
            return this.delegate.getEnabledProtocols();
        }

        @Override
        public InetAddress getInetAddress() {
            return this.delegate.getInetAddress();
        }

        @Override
        public InputStream getInputStream() {
            return this.delegate.getInputStream();
        }

        @Override
        public boolean getKeepAlive() {
            return this.delegate.getKeepAlive();
        }

        @Override
        public InetAddress getLocalAddress() {
            return this.delegate.getLocalAddress();
        }

        @Override
        public int getLocalPort() {
            return this.delegate.getLocalPort();
        }

        @Override
        public SocketAddress getLocalSocketAddress() {
            return this.delegate.getLocalSocketAddress();
        }

        @Override
        public boolean getNeedClientAuth() {
            return this.delegate.getNeedClientAuth();
        }

        @Override
        public boolean getOOBInline() {
            return this.delegate.getOOBInline();
        }

        @Override
        public OutputStream getOutputStream() {
            return this.delegate.getOutputStream();
        }

        @Override
        public int getPort() {
            return this.delegate.getPort();
        }

        @Override
        public synchronized int getReceiveBufferSize() {
            return this.delegate.getReceiveBufferSize();
        }

        @Override
        public SocketAddress getRemoteSocketAddress() {
            return this.delegate.getRemoteSocketAddress();
        }

        @Override
        public boolean getReuseAddress() {
            return this.delegate.getReuseAddress();
        }

        @Override
        public synchronized int getSendBufferSize() {
            return this.delegate.getSendBufferSize();
        }

        @Override
        public SSLSession getSession() {
            return this.delegate.getSession();
        }

        @Override
        public int getSoLinger() {
            return this.delegate.getSoLinger();
        }

        @Override
        public synchronized int getSoTimeout() {
            return this.delegate.getSoTimeout();
        }

        @Override
        public String[] getSupportedCipherSuites() {
            return this.delegate.getSupportedCipherSuites();
        }

        @Override
        public String[] getSupportedProtocols() {
            return this.delegate.getSupportedProtocols();
        }

        @Override
        public boolean getTcpNoDelay() {
            return this.delegate.getTcpNoDelay();
        }

        @Override
        public int getTrafficClass() {
            return this.delegate.getTrafficClass();
        }

        @Override
        public boolean getUseClientMode() {
            return this.delegate.getUseClientMode();
        }

        @Override
        public boolean getWantClientAuth() {
            return this.delegate.getWantClientAuth();
        }

        @Override
        public boolean isBound() {
            return this.delegate.isBound();
        }

        @Override
        public boolean isClosed() {
            return this.delegate.isClosed();
        }

        @Override
        public boolean isConnected() {
            return this.delegate.isConnected();
        }

        @Override
        public boolean isInputShutdown() {
            return this.delegate.isInputShutdown();
        }

        @Override
        public boolean isOutputShutdown() {
            return this.delegate.isOutputShutdown();
        }

        @Override
        public void removeHandshakeCompletedListener(HandshakeCompletedListener handshakeCompletedListener) {
            this.delegate.removeHandshakeCompletedListener(handshakeCompletedListener);
        }

        @Override
        public void sendUrgentData(int i2) {
            this.delegate.sendUrgentData(i2);
        }

        @Override
        public void setEnableSessionCreation(boolean z) {
            this.delegate.setEnableSessionCreation(z);
        }

        @Override
        public void setEnabledCipherSuites(String[] strArr) {
            this.delegate.setEnabledCipherSuites(strArr);
        }

        @Override
        public void setEnabledProtocols(String[] strArr) {
            this.delegate.setEnabledProtocols(strArr);
        }

        @Override
        public void setKeepAlive(boolean z) {
            this.delegate.setKeepAlive(z);
        }

        @Override
        public void setNeedClientAuth(boolean z) {
            this.delegate.setNeedClientAuth(z);
        }

        @Override
        public void setOOBInline(boolean z) {
            this.delegate.setOOBInline(z);
        }

        @Override
        public void setPerformancePreferences(int i2, int i3, int i4) {
            this.delegate.setPerformancePreferences(i2, i3, i4);
        }

        @Override
        public synchronized void setReceiveBufferSize(int i2) {
            this.delegate.setReceiveBufferSize(i2);
        }

        @Override
        public void setReuseAddress(boolean z) {
            this.delegate.setReuseAddress(z);
        }

        @Override
        public synchronized void setSendBufferSize(int i2) {
            this.delegate.setSendBufferSize(i2);
        }

        @Override
        public void setSoLinger(boolean z, int i2) {
            this.delegate.setSoLinger(z, i2);
        }

        @Override
        public synchronized void setSoTimeout(int i2) {
            this.delegate.setSoTimeout(i2);
        }

        @Override
        public void setTcpNoDelay(boolean z) {
            this.delegate.setTcpNoDelay(z);
        }

        @Override
        public void setTrafficClass(int i2) {
            this.delegate.setTrafficClass(i2);
        }

        @Override
        public void setUseClientMode(boolean z) {
            this.delegate.setUseClientMode(z);
        }

        @Override
        public void setWantClientAuth(boolean z) {
            this.delegate.setWantClientAuth(z);
        }

        @Override
        public void shutdownInput() {
            this.delegate.shutdownInput();
        }

        @Override
        public void shutdownOutput() {
            this.delegate.shutdownOutput();
        }

        @Override
        public void startHandshake() {
            this.delegate.startHandshake();
        }

        @Override
        public String toString() {
            return this.delegate.toString();
        }

        @Override
        public void connect(SocketAddress socketAddress, int i2) {
            this.delegate.connect(socketAddress, i2);
        }
    }

    class a extends DelegateSSLSocket {
        private a(SSLSocket sSLSocket) {
            super(sSLSocket);
        }

        @Override
        public final void setEnabledProtocols(String[] strArr) {
            PrintStream printStream;
            String str;
            if (strArr != null && strArr.length == 1 && "SSLv3".equals(strArr[0])) {
                ArrayList arrayList = new ArrayList(Arrays.asList(this.delegate.getEnabledProtocols()));
                if (arrayList.size() > 1) {
                    arrayList.remove("SSLv3");
                    printStream = System.out;
                    str = "Removed SSLv3 from enabled protocols";
                } else {
                    printStream = System.out;
                    str = "SSL stuck with protocol available for " + String.valueOf(arrayList);
                }
                printStream.println(str);
                strArr = (String[]) arrayList.toArray(new String[arrayList.size()]);
            }
            super.setEnabledProtocols(strArr);
        }

        a(NoSSLv3SocketFactory noSSLv3SocketFactory, SSLSocket sSLSocket, byte b) {
            this(sSLSocket);
        }
    }

    public NoSSLv3SocketFactory() {
        this.delegate = HttpsURLConnection.getDefaultSSLSocketFactory();
    }

    private Socket makeSocketSafe(Socket socket) {
        return socket instanceof SSLSocket ? new a(this, (SSLSocket) socket, (byte) 0) : socket;
    }

    @Override
    public final Socket createSocket(String str, int i2) {
        return makeSocketSafe(this.delegate.createSocket(str, i2));
    }

    @Override
    public final String[] getDefaultCipherSuites() {
        return this.delegate.getDefaultCipherSuites();
    }

    @Override
    public final String[] getSupportedCipherSuites() {
        return this.delegate.getSupportedCipherSuites();
    }

    public NoSSLv3SocketFactory(SSLSocketFactory sSLSocketFactory) {
        this.delegate = sSLSocketFactory;
    }

    @Override
    public final Socket createSocket(String str, int i2, InetAddress inetAddress, int i3) {
        return makeSocketSafe(this.delegate.createSocket(str, i2, inetAddress, i3));
    }

    @Override
    public final Socket createSocket(InetAddress inetAddress, int i2) {
        return makeSocketSafe(this.delegate.createSocket(inetAddress, i2));
    }

    @Override
    public final Socket createSocket(InetAddress inetAddress, int i2, InetAddress inetAddress2, int i3) {
        return makeSocketSafe(this.delegate.createSocket(inetAddress, i2, inetAddress2, i3));
    }

    @Override
    public final Socket createSocket(Socket socket, String str, int i2, boolean z) {
        return makeSocketSafe(this.delegate.createSocket(socket, str, i2, z));
    }
}