* @param sequence
* @return The {@link PrincipalName}.
*/
public static PrincipalName decode( DERSequence sequence )
{
PrincipalName principalName = new PrincipalName();
for ( Enumeration<DEREncodable> e = sequence.getObjects(); e.hasMoreElements(); )
{
DERTaggedObject object = ( DERTaggedObject ) e.nextElement();
int tag = object.getTagNo();
DEREncodable derObject = object.getObject();
switch ( tag )
{
case 0:
DERInteger nameType = ( DERInteger ) derObject;
principalName.setNameType( nameType.intValue() );
break;
case 1:
DERSequence nameString = ( DERSequence ) derObject;
decodeNameString( nameString, principalName );