summaryrefslogtreecommitdiffstats
blob: cd9f90dc9e683ebba81cddf9a2aba5669e0197f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
 * Copyright (c) 2011-2014, Isode Limited, London, England.
 * All rights reserved.
 */
/*
 * Copyright (c) 2010, Remko Tronçon.
 * All rights reserved.
 */

package com.isode.stroke.tls;

import java.util.List;

import com.isode.stroke.base.ByteArray;
import com.isode.stroke.base.SafeByteArray;
import com.isode.stroke.signals.Signal;
import com.isode.stroke.signals.Signal1;
import com.isode.stroke.tls.TLSError;

public abstract class TLSContext {

    public abstract void connect();

    public abstract boolean setClientCertificate(CertificateWithKey cert);

    public abstract void handleDataFromNetwork(SafeByteArray data);
    public abstract void handleDataFromApplication(SafeByteArray data);

    /**
     * The peer certificate, as presented by the remote entity
     * @return the peer certificate, which may be null
     */
    public abstract Certificate getPeerCertificate();
    /**
     * The peer's certificate chain, as presented by the remote entity
     * @return the peer certificate chain, which may be null.
     */
    public abstract List<Certificate> getPeerCertificateChain();
    public abstract CertificateVerificationError getPeerCertificateVerificationError();

    public abstract ByteArray getFinishMessage();

    public Signal1<SafeByteArray> onDataForNetwork = new Signal1<SafeByteArray>();
    public Signal1<SafeByteArray> onDataForApplication = new Signal1<SafeByteArray>();
    public Signal1<TLSError> onError = new Signal1<TLSError>();
    public Signal onConnected = new Signal();
}