public static Pair < AlgorithmType , Boolean > fromRdfString ( String str , boolean convert ) throws IncompatibleException { // default if ( str . length ( ) == 0 ) return pair ( MD5 , true ) ; // Search the list of registered algorithms for ( AlgorithmType algoType : TYPES ) { String name = algoType . rdfName . toLowerCase ( ) ; String hmacName = algoType . rdfHmacName . toLowerCase ( ) ; if ( str . compareTo ( name ) == 0 || str . compareTo ( hmacName ) == 0 ) return pair ( algoType , true ) ; } if ( str . compareTo ( "md5-v0.6" ) == 0 || str . compareTo ( "hmac-md5-v0.6" ) == 0 ) return pair ( AlgorithmType . MD5 , false ) ; // TODO: full support for all invalid types should be present as well as allowing the account to exist and be modified. if ( convert && str . compareTo ( "hmac-sha256" ) == 0 ) { return pair ( AlgorithmType . SHA256 , true ) ; } if ( str . compareTo ( "hmac-sha256" ) == 0 ) throw new IncompatibleException ( "Original hmac-sha256-v1.5.1 implementation has been detected, " + "this is not compatible with PasswordMakerJE due to a bug in the original " + "javascript version. It is recommended that you update this account to use " + "\"HMAC-SHA256\" in the PasswordMaker settings." ) ; if ( str . compareTo ( "md5-v0.6" ) == 0 ) throw new IncompatibleException ( "Original md5-v0.6 implementation has been detected, " + "this is not compatible with PasswordMakerJE due to a bug in the original " + "javascript version. It is recommended that you update this account to use " + "\"MD5\" in the PasswordMaker settings." ) ; if ( str . compareTo ( "hmac-md5-v0.6" ) == 0 ) throw new IncompatibleException ( "Original hmac-md5-v0.6 implementation has been detected, " + "this is not compatible with PasswordMakerJE due to a bug in the original " + "javascript version. It is recommended that you update this account to use " + "\"HMAC-MD5\" in the PasswordMaker settings." ) ; throw new IncompatibleException ( String . format ( "Invalid algorithm type '%1s'" , str ) ) ; }
Converts a string to an algorithm type .