aboutsummaryrefslogtreecommitdiffstats
path: root/libraries/spongycastle/core/src/main/java/org/spongycastle/asn1/dvcs/ServiceType.java
blob: 0cc4acc1f6d3be2552805040ec58b020382bd5d2 (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package org.spongycastle.asn1.dvcs;

import java.math.BigInteger;

import org.spongycastle.asn1.ASN1Enumerated;
import org.spongycastle.asn1.ASN1Object;
import org.spongycastle.asn1.ASN1Primitive;
import org.spongycastle.asn1.ASN1TaggedObject;


/**
 * ServiceType ::= ENUMERATED { cpd(1), vsd(2), cpkc(3), ccpd(4) }
 */

public class ServiceType
    extends ASN1Object
{
    /**
     * Identifier of CPD service (Certify Possession of Data).
     */
    public static final ServiceType CPD = new ServiceType(1);

    /**
     * Identifier of VSD service (Verify Signed Document).
     */
    public static final ServiceType VSD = new ServiceType(2);

    /**
     * Identifier of VPKC service (Verify Public Key Certificates (also referred to as CPKC)).
     */
    public static final ServiceType VPKC = new ServiceType(3);

    /**
     * Identifier of CCPD service (Certify Claim of Possession of Data).
     */
    public static final ServiceType CCPD = new ServiceType(4);

    private ASN1Enumerated value;

    public ServiceType(int value)
    {
        this.value = new ASN1Enumerated(value);
    }

    private ServiceType(ASN1Enumerated value)
    {
        this.value = value;
    }

    public static ServiceType getInstance(Object obj)
    {
        if (obj instanceof ServiceType)
        {
            return (ServiceType)obj;
        }
        else if (obj != null)
        {
            return new ServiceType(ASN1Enumerated.getInstance(obj));
        }

        return null;
    }

    public static ServiceType getInstance(
        ASN1TaggedObject obj,
        boolean explicit)
    {
        return getInstance(ASN1Enumerated.getInstance(obj, explicit));
    }

    public BigInteger getValue()
    {
        return value.getValue();
    }

    public ASN1Primitive toASN1Primitive()
    {
        return value;
    }

    public String toString()
    {
        int num = value.getValue().intValue();
        return "" + num + (
            num == CPD.getValue().intValue() ? "(CPD)" :
                num == VSD.getValue().intValue() ? "(VSD)" :
                    num == VPKC.getValue().intValue() ? "(VPKC)" :
                        num == CCPD.getValue().intValue() ? "(CCPD)" :
                            "?");
    }

}