Skip to content

Commit

Permalink
Migrate NullSslSession to Java to fix deprecation warning
Browse files Browse the repository at this point in the history
  • Loading branch information
marianobarrios committed Jun 8, 2023
1 parent e888306 commit 1057b64
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 34 deletions.
116 changes: 116 additions & 0 deletions src/test/scala/tlschannel/helpers/NullSslSession.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
package tlschannel.helpers;

import java.security.Principal;
import java.security.cert.Certificate;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSessionContext;
import javax.security.cert.X509Certificate;

public class NullSslSession implements SSLSession {

private final int bufferSize;

public NullSslSession(int bufferSize) {
this.bufferSize = bufferSize;
}

@Override
public byte[] getId() {
return new byte[0];
}

@Override
public SSLSessionContext getSessionContext() {
return null;
}

@Override
public long getCreationTime() {
return System.currentTimeMillis();
}

@Override
public long getLastAccessedTime() {
return System.currentTimeMillis();
}

@Override
public void invalidate() {}

@Override
public boolean isValid() {
return false;
}

@Override
public void putValue(String name, Object value) {}

@Override
public Object getValue(String name) {
return null;
}

@Override
public void removeValue(String name) {}

@Override
public String[] getValueNames() {
return new String[0];
}

@Override
public Certificate[] getPeerCertificates() {
return new Certificate[0];
}

@Override
public Certificate[] getLocalCertificates() {
return new Certificate[0];
}

@Override
public Principal getPeerPrincipal() {
return null;
}

@Override
public Principal getLocalPrincipal() {
return null;
}

@Override
public String getCipherSuite() {
return null;
}

@Override
public String getProtocol() {
return "";
}

@Override
public String getPeerHost() {
return null;
}

@Override
public int getPeerPort() {
return 0;
}

@Override
public int getPacketBufferSize() {
return 0;
}

@Override
public int getApplicationBufferSize() {
return bufferSize;
}

@Override
@SuppressWarnings("removal")
public X509Certificate[] getPeerCertificateChain() {
return new X509Certificate[0];
}
}
34 changes: 0 additions & 34 deletions src/test/scala/tlschannel/helpers/NullSslSession.scala

This file was deleted.

0 comments on commit 1057b64

Please sign in to comment.