CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-com-squareup-okhttp--okhttp

An HTTP & SPDY client for Android and Java applications with efficient connection pooling, interceptors, and modern protocol support

Pending
Overview
Eval results
Files

authentication-security.mddocs/

Authentication and Security

Authentication handling, certificate pinning, TLS handshake management, and credential utilities.

Capabilities

Authenticator

Responds to HTTP authentication challenges (401/407 responses).

public interface Authenticator {
    Request authenticate(Proxy proxy, Response response) throws IOException;
    Request authenticateProxy(Proxy proxy, Response response) throws IOException;
}

CertificatePinner

Constrains trusted certificates by pinning specific certificate hashes.

public final class CertificatePinner {
    public static final CertificatePinner DEFAULT;
    public static String pin(Certificate certificate);
    public void check(String hostname, List<Certificate> peerCertificates) throws SSLPeerUnverifiedException;
    public void check(String hostname, Certificate... peerCertificates) throws SSLPeerUnverifiedException;
}

Credentials

Factory for HTTP authorization credentials.

public final class Credentials {
    public static String basic(String userName, String password);
}

Challenge

RFC 2617 authentication challenge from HTTP response.

public final class Challenge {
    public Challenge(String scheme, String realm);
    public String getScheme();
    public String getRealm();
}

Handshake

Record of TLS handshake with certificate chain information.

public final class Handshake {
    public static Handshake get(SSLSession session);
    public static Handshake get(String cipherSuite, List<Certificate> peerCertificates, List<Certificate> localCertificates);
    public String cipherSuite();
    public List<Certificate> peerCertificates();
    public Principal peerPrincipal();
    public List<Certificate> localCertificates();
    public Principal localPrincipal();
}

Usage Examples:

// Basic authentication
client.setAuthenticator(new Authenticator() {
    @Override
    public Request authenticate(Proxy proxy, Response response) {
        String credential = Credentials.basic("username", "password");
        return response.request().newBuilder()
            .header("Authorization", credential)
            .build();
    }
    
    @Override
    public Request authenticateProxy(Proxy proxy, Response response) {
        return null; // No proxy auth
    }
});

// Certificate pinning
CertificatePinner pinner = new CertificatePinner.Builder()
    .add("api.example.com", "sha1/ABC123...")
    .build();
client.setCertificatePinner(pinner);

Install with Tessl CLI

npx tessl i tessl/maven-com-squareup-okhttp--okhttp

docs

async-execution.md

authentication-security.md

caching.md

connection-management.md

form-data-multipart.md

http-client.md

http-utilities.md

index.md

interceptors.md

request-building.md

request-response-bodies.md

response-handling.md

tile.json