001package org.apache.commons.ssl.org.bouncycastle.asn1.isismtt.x509; 002 003import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1Object; 004import org.apache.commons.ssl.org.bouncycastle.asn1.ASN1Primitive; 005import org.apache.commons.ssl.org.bouncycastle.asn1.x500.DirectoryString; 006 007/** 008 * Some other restriction regarding the usage of this certificate. 009 * 010 * <pre> 011 * RestrictionSyntax ::= DirectoryString (SIZE(1..1024)) 012 * </pre> 013 */ 014public class Restriction 015 extends ASN1Object 016{ 017 private DirectoryString restriction; 018 019 public static Restriction getInstance(Object obj) 020 { 021 if (obj instanceof Restriction) 022 { 023 return (Restriction)obj; 024 } 025 026 if (obj != null) 027 { 028 return new Restriction(DirectoryString.getInstance(obj)); 029 } 030 031 return null; 032 } 033 034 /** 035 * Constructor from DirectoryString. 036 * <p> 037 * The DirectoryString is of type RestrictionSyntax: 038 * <pre> 039 * RestrictionSyntax ::= DirectoryString (SIZE(1..1024)) 040 * </pre> 041 * </p> 042 * @param restriction A DirectoryString. 043 */ 044 private Restriction(DirectoryString restriction) 045 { 046 this.restriction = restriction; 047 } 048 049 /** 050 * Constructor from a given details. 051 * 052 * @param restriction The describtion of the restriction. 053 */ 054 public Restriction(String restriction) 055 { 056 this.restriction = new DirectoryString(restriction); 057 } 058 059 public DirectoryString getRestriction() 060 { 061 return restriction; 062 } 063 064 /** 065 * Produce an object suitable for an ASN1OutputStream. 066 * <p> 067 * Returns: 068 * <pre> 069 * RestrictionSyntax ::= DirectoryString (SIZE(1..1024)) 070 * </pre> 071 * 072 * @return a DERObject 073 */ 074 public ASN1Primitive toASN1Primitive() 075 { 076 return restriction.toASN1Primitive(); 077 } 078}