private static String getUPNStringFromSequence ( final ASN1Sequence seq ) { if ( seq == null ) { return null ; } val id = ASN1ObjectIdentifier . getInstance ( seq . getObjectAt ( 0 ) ) ; if ( id != null && UPN_OBJECTID . equals ( id . getId ( ) ) ) { val obj = ( ASN1TaggedObject ) seq . getObjectAt ( 1 ) ; val primitiveObj = obj . getObject ( ) ; val func = FunctionUtils . doIf ( Predicates . instanceOf ( ASN1TaggedObject . class ) , ( ) -> ASN1TaggedObject . getInstance ( primitiveObj ) . getObject ( ) , ( ) -> primitiveObj ) ; val prim = func . apply ( primitiveObj ) ; if ( prim instanceof ASN1OctetString ) { return new String ( ( ( ASN1OctetString ) prim ) . getOctets ( ) , StandardCharsets . UTF_8 ) ; } if ( prim instanceof ASN1String ) { return ( ( ASN1String ) prim ) . getString ( ) ; } } return null ; }
Get UPN String .