private UsernamePasswordCredentials getCreds ( String url ) throws Exception { url = normalizeURL ( url ) ; url = url . substring ( url . indexOf ( "/" ) + 2 ) ; UsernamePasswordCredentials longestMatch = null ; int longestMatchLength = 0 ; Iterator < String > iter = m_creds . keySet ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { String realmPath = ( String ) iter . next ( ) ; if ( url . startsWith ( realmPath ) ) { int matchLength = realmPath . length ( ) ; if ( matchLength > longestMatchLength ) { longestMatchLength = matchLength ; longestMatch = ( UsernamePasswordCredentials ) m_creds . get ( realmPath ) ; } } } return longestMatch ; }
Return the credentials for the realmPath that most closely matches the given url or null if none found .