Constructors Summary |
---|
public RoleSyntax(GeneralNames roleAuthority, GeneralName roleName)Constructor.
if(roleName == null ||
roleName.getTagNo() != GeneralName.uniformResourceIdentifier ||
((DERString)roleName.getName()).getString().equals(""))
{
throw new IllegalArgumentException("the role name MUST be non empty and MUST " +
"use the URI option of GeneralName");
}
this.roleAuthority = roleAuthority;
this.roleName = roleName;
|
public RoleSyntax(GeneralName roleName)Constructor. Invoking this constructor is the same as invoking
new RoleSyntax(null, roleName) .
this(null, roleName);
|
public RoleSyntax(String roleName)Utility constructor. Takes a String argument representing
the role name, builds a GeneralName to hold the role name
and calls the constructor that takes a GeneralName .
this(new GeneralName(GeneralName.uniformResourceIdentifier,
(roleName == null)? "": roleName));
|
public RoleSyntax(org.bouncycastle.asn1.ASN1Sequence seq)Constructor that builds an instance of RoleSyntax by
extracting the encoded elements from the ASN1Sequence
object supplied.
if (seq.size() < 1 || seq.size() > 2)
{
throw new IllegalArgumentException("Bad sequence size: "
+ seq.size());
}
for (int i = 0; i != seq.size(); i++)
{
ASN1TaggedObject taggedObject = ASN1TaggedObject.getInstance(seq.getObjectAt(i));
switch (taggedObject.getTagNo())
{
case 0:
roleAuthority = GeneralNames.getInstance(taggedObject, false);
break;
case 1:
roleName = GeneralName.getInstance(taggedObject, false);
break;
default:
throw new IllegalArgumentException("Unknown tag in RoleSyntax");
}
}
|
Methods Summary |
---|
public static org.bouncycastle.asn1.x509.RoleSyntax | getInstance(java.lang.Object obj)RoleSyntax factory method.
if(obj == null || obj instanceof RoleSyntax)
{
return (RoleSyntax)obj;
}
else if(obj instanceof ASN1Sequence)
{
return new RoleSyntax((ASN1Sequence)obj);
}
throw new IllegalArgumentException("Unknown object in RoleSyntax factory.");
|
public GeneralNames | getRoleAuthority()Gets the role authority of this RoleSyntax.
return this.roleAuthority;
|
public java.lang.String[] | getRoleAuthorityAsString()Gets the role authority as a String[] object.
if(roleAuthority == null)
{
return new String[0];
}
GeneralName[] names = roleAuthority.getNames();
String[] namesString = new String[names.length];
for(int i = 0; i < names.length; i++)
{
DEREncodable value = names[i].getName();
if(value instanceof DERString)
{
namesString[i] = ((DERString)value).getString();
}
else
{
namesString[i] = value.toString();
}
}
return namesString;
|
public GeneralName | getRoleName()Gets the role name of this RoleSyntax.
return this.roleName;
|
public java.lang.String | getRoleNameAsString()Gets the role name as a java.lang.String object.
DERString str = (DERString)this.roleName.getName();
return str.getString();
|
public org.bouncycastle.asn1.DERObject | toASN1Object()Implementation of the method toASN1Object as
required by the superclass ASN1Encodable .
RoleSyntax ::= SEQUENCE {
roleAuthority [0] GeneralNames OPTIONAL,
roleName [1] GeneralName
}
ASN1EncodableVector v = new ASN1EncodableVector();
if(this.roleAuthority != null)
{
v.add(new DERTaggedObject(false, 0, roleAuthority));
}
v.add(new DERTaggedObject(false, 1, roleName));
return new DERSequence(v);
|
public java.lang.String | toString()
StringBuffer buff = new StringBuffer("Name: " + this.getRoleNameAsString() +
" - Auth: ");
if(this.roleAuthority == null || roleAuthority.getNames().length == 0)
{
buff.append("N/A");
}
else
{
String[] names = this.getRoleAuthorityAsString();
buff.append('[").append(names[0]);
for(int i = 1; i < names.length; i++)
{
buff.append(", ").append(names[i]);
}
buff.append(']");
}
return buff.toString();
|