Changeset cb76235


Ignore:
Timestamp:
May 22, 2019 4:01:10 PM (11 months ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
06fa817
Parents:
62649a6
Message:

Data: Cache data for per-client auth

File:
1 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/net/i2p/data/BlindData.java

    r62649a6 rcb76235  
    2626
    2727    /**
     28     * bits 3-0 including per-client bit
     29     * @since 0.9.41
     30     */
     31    public static final int AUTH_NONE = 0;
     32    /**
     33     * bits 3-0 including per-client bit
     34     * @since 0.9.41
     35     */
     36    public static final int AUTH_DH = 1;
     37    /**
     38     * bits 3-0 including per-client bit
     39     * @since 0.9.41
     40     */
     41    public static final int AUTH_PSK = 3;
     42
     43    /**
    2844     *  @param secret may be null or zero-length
    2945     *  @throws IllegalArgumentException on various errors
    3046     */
    3147    public BlindData(I2PAppContext ctx, Destination dest, SigType blindType, String secret) {
    32         this(ctx, dest.getSigningPublicKey(), blindType, secret);
     48        this(ctx, dest, blindType, secret, AUTH_NONE, null);
     49    }
     50
     51    /**
     52     *  @param secret may be null or zero-length
     53     *  @throws IllegalArgumentException on various errors
     54     *  @since 0.9.41
     55     */
     56    public BlindData(I2PAppContext ctx, Destination dest, SigType blindType, String secret,
     57                     int authType, PrivateKey authKey) {
     58        this(ctx, dest.getSigningPublicKey(), blindType, secret, authType, authKey);
    3359        _dest = dest;
    3460    }
     
    3965     */
    4066    public BlindData(I2PAppContext ctx, SigningPublicKey spk, SigType blindType, String secret) {
     67        this(ctx, spk, blindType, secret, AUTH_NONE, null);
     68    }
     69
     70    /**
     71     *  @param secret may be null or zero-length
     72     *  @throws IllegalArgumentException on various errors
     73     *  @since 0.9.41
     74     */
     75    public BlindData(I2PAppContext ctx, SigningPublicKey spk, SigType blindType, String secret,
     76                     int authType, PrivateKey authKey) {
    4177        _context = ctx;
    4278        _clearSPK = spk;
    4379        _blindType = blindType;
    4480        _secret = secret;
    45         _authType = -1;
    46         _authKey = null;
     81        if ((authType != AUTH_NONE && authKey == null) ||
     82            (authType == AUTH_NONE && authKey != null))
     83            throw new IllegalArgumentException();
     84        _authType = authType;
     85        _authKey = authKey;
    4786        // defer until needed
    4887        //calculate();
     
    123162
    124163    /**
    125      *  @return -1 for no client auth
     164     *  @return 0 for no client auth, 1 for DH, 3 for PSK
    126165     */
    127166    public int getAuthType() {
     
    171210            buf.append("\n\tSecret          : \"").append(_secret).append('"');
    172211        buf.append("\n\tAuth Type       : ");
    173         if (_authType >= 0)
     212        if (_authType > 0)
    174213            buf.append(_authType);
    175214        else
Note: See TracChangeset for help on using the changeset viewer.