public static String getPublicId ( String otp ) { if ( ( otp == null ) || ( otp . length ( ) < OTP_MIN_LEN ) ) { //not a valid OTP format, throw an exception throw new IllegalArgumentException ( "The OTP is too short to be valid" ) ; } Integer len = otp . length ( ) ; /* The OTP part is always the last 32 bytes of otp. Whatever is before that * (if anything) is the public ID of the YubiKey. The ID can be set to '' * through personalization. */ return otp . substring ( 0 , len - 32 ) . toLowerCase ( ) ; }
Extract the public ID of a YubiKey from an OTP it generated .