public UserPrincipalLookupService getUserPrincipalLookupService()

in src/main/java/com/pastdev/jsch/nio/file/UnixSshFileSystem.java [209:234]


    public UserPrincipalLookupService getUserPrincipalLookupService() {
        return new UserPrincipalLookupService() {
            @Override
            public UserPrincipal lookupPrincipalByName( String user ) throws IOException {
                if ( getCommandRunner().execute( "id " + user ).getExitCode() == 0 ) {
                    return new StandardUserPrincipal( user );
                }
                else {
                    throw new UserPrincipalNotFoundException( user + " does not exist" );
                }
            }

            @Override
            public GroupPrincipal lookupPrincipalByGroupName( String group ) throws IOException {
                // I don't like this, but don't have a better way right
                // now...
                // Should be pretty safe in most instances
                if ( getCommandRunner().execute( "egrep -i \"^" + group + "\" /etc/group" ).getExitCode() == 0 ) {
                    return new StandardGroupPrincipal( group );
                }
                else {
                    throw new UserPrincipalNotFoundException( group + " does not exist" );
                }
            }
        };
    }