core/src/main/java/org/apache/commons/vfs2/provider/HostFileNameParser.java
/**
     * Extracts the scheme, userinfo, hostname and port components of a
     * generic URI.
     *
     * @param uri  The absolute URI to parse.
     * @param name Used to return the remainder of the URI.
     */
Extracts the scheme, userinfo, hostname and port components of a
generic URI.

@param uri  The absolute URI to parse.
@param name Used to return the remainder of the URI.
Extracts the scheme userinfo hostname and port components of a generic URI . @param uri The absolute URI to parse . @param name Used to return the remainder of the URI .
protected Authority extractToPath(final String uri,
                                      final StringBuilder name)
        throws FileSystemException
    {
        final Authority auth = new Authority();
        auth.scheme = UriParser.extractScheme(uri, name);
        if (name.length() < 2 || name.charAt(0) != '/' || name.charAt(1) != '/')
        {
            throw new FileSystemException("vfs.provider/missing-double-slashes.error", uri);
        }
        name.delete(0, 2);
        final String userInfo = extractUserInfo(name);
        final String userName;
        final String password;
        if (userInfo != null)
        {
            int idx = userInfo.indexOf(':');
            if (idx == -1)
            {
                userName = userInfo;
                password = null;
            }
            else
            {
                userName = userInfo.substring(0, idx);
                password = userInfo.substring(idx + 1);
            }
        }
        else
        {
            userName = null;
            password = null;
        }
        auth.userName = UriParser.decode(userName);
        auth.password = UriParser.decode(password);
        if (auth.password != null && auth.password.startsWith("{") && auth.password.endsWith("}"))
        {
            try
            {
                Cryptor cryptor = CryptorFactory.getCryptor();
                auth.password = cryptor.decrypt(auth.password.substring(1, auth.password.length() - 1));
            }
            catch (Exception ex)
            {
                throw new FileSystemException("Unable to decrypt password", ex);
            }
        }
        final String hostName = extractHostName(name);
        if (hostName == null)
        {
            throw new FileSystemException("vfs.provider/missing-hostname.error", uri);
        }
        auth.hostName = hostName.toLowerCase();
        auth.port = extractPort(name, uri);
        if (name.length() > 0 && name.charAt(0) != '/')
        {
            throw new FileSystemException("vfs.provider/missing-hostname-path-sep.error", uri);
        }
        return auth;
    }
protected Authority extractToPath ( final String uri , final StringBuilder name ) throws FileSystemException { final Authority auth = new Authority ( ) ; auth . scheme = UriParser . extractScheme ( uri , name ) ; if ( name . length ( ) < 2 || name . charAt ( 0 ) != '/' || name . charAt ( 1 ) != '/' ) { throw new FileSystemException ( "vfs.provider/missing-double-slashes.error" , uri ) ; } name . delete ( 0 , 2 ) ; final String userInfo = extractUserInfo ( name ) ; final String userName ; final String password ; if ( userInfo != null ) { int idx = userInfo . indexOf ( ':' ) ; if ( idx == - 1 ) { userName = userInfo ; password = null ; } else { userName = userInfo . substring ( 0 , idx ) ; password = userInfo . substring ( idx + 1 ) ; } } else { userName = null ; password = null ; } auth . userName = UriParser . decode ( userName ) ; auth . password = UriParser . decode ( password ) ; if ( auth . password != null && auth . password . startsWith ( "{" ) && auth . password . endsWith ( "}" ) ) { try { Cryptor cryptor = CryptorFactory . getCryptor ( ) ; auth . password = cryptor . decrypt ( auth . password . substring ( 1 , auth . password . length ( ) - 1 ) ) ; } catch ( Exception ex ) { throw new FileSystemException ( "Unable to decrypt password" , ex ) ; } } final String hostName = extractHostName ( name ) ; if ( hostName == null ) { throw new FileSystemException ( "vfs.provider/missing-hostname.error" , uri ) ; } auth . hostName = hostName . toLowerCase ( ) ; auth . port = extractPort ( name , uri ) ; if ( name . length ( ) > 0 && name . charAt ( 0 ) != '/' ) { throw new FileSystemException ( "vfs.provider/missing-hostname-path-sep.error" , uri ) ; } return auth ; }
Extracts the scheme, userinfo, hostname and port components of a
 generic URI.
Extracts the scheme userinfo hostname and port components of a generic URI .
// Extract the scheme // Expecting "//" // Extract userinfo, and split into username and password // Extract hostname, and normalise (lowercase) // Extract port // Expecting '/' or empty name