001package org.apache.commons.ssl.org.bouncycastle.asn1.dvcs; 002 003import java.math.BigInteger; 004 005import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1Enumerated; 006import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1Object; 007import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1Primitive; 008import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1TaggedObject; 009 010 011/** 012 * ServiceType ::= ENUMERATED { cpd(1), vsd(2), cpkc(3), ccpd(4) } 013 */ 014 015public class ServiceType 016 extends ASN1Object 017{ 018 /** 019 * Identifier of CPD service (Certify Possession of Data). 020 */ 021 public static final ServiceType CPD = new ServiceType(1); 022 023 /** 024 * Identifier of VSD service (Verify Signed Document). 025 */ 026 public static final ServiceType VSD = new ServiceType(2); 027 028 /** 029 * Identifier of VPKC service (Verify Public Key Certificates (also referred to as CPKC)). 030 */ 031 public static final ServiceType VPKC = new ServiceType(3); 032 033 /** 034 * Identifier of CCPD service (Certify Claim of Possession of Data). 035 */ 036 public static final ServiceType CCPD = new ServiceType(4); 037 038 private ASN1Enumerated value; 039 040 public ServiceType(int value) 041 { 042 this.value = new ASN1Enumerated(value); 043 } 044 045 private ServiceType(ASN1Enumerated value) 046 { 047 this.value = value; 048 } 049 050 public static ServiceType getInstance(Object obj) 051 { 052 if (obj instanceof ServiceType) 053 { 054 return (ServiceType)obj; 055 } 056 else if (obj != null) 057 { 058 return new ServiceType(ASN1Enumerated.getInstance(obj)); 059 } 060 061 return null; 062 } 063 064 public static ServiceType getInstance( 065 ASN1TaggedObject obj, 066 boolean explicit) 067 { 068 return getInstance(ASN1Enumerated.getInstance(obj, explicit)); 069 } 070 071 public BigInteger getValue() 072 { 073 return value.getValue(); 074 } 075 076 public ASN1Primitive toASN1Primitive() 077 { 078 return value; 079 } 080 081 public String toString() 082 { 083 int num = value.getValue().intValue(); 084 return "" + num + ( 085 num == CPD.getValue().intValue() ? "(CPD)" : 086 num == VSD.getValue().intValue() ? "(VSD)" : 087 num == VPKC.getValue().intValue() ? "(VPKC)" : 088 num == CCPD.getValue().intValue() ? "(CCPD)" : 089 "?"); 090 } 091 092}