/** * <p>In case it's impossible to determine the actual permissions, returns an "always-true" permission.</p> * * @param checkIds * @return * @throws Exception */ @Override protected PosixPermissions getPermissions( boolean checkIds ) throws Exception { if ( checkIds && ( getAbstractFileSystem() instanceof SftpFileSystemWindows ) && ( (SftpFileSystemWindows) getAbstractFileSystem() ).isExecDisabled() ) { // Exec is disabled, so we won't be able to ascertain the current user's UID and GID. // Return "always-true" permissions as a workaround, knowing that the SFTP server won't // let us perform unauthorized actions anyway. return new PretendUserIsOwnerPosixPermissions(); } return super.getPermissions( checkIds ); }
@Override protected boolean doIsReadable() throws Exception { SftpFileSystemWindows fileSystem = (SftpFileSystemWindows) getAbstractFileSystem(); if ( !fileSystem.isRemoteHostWindows() ) { return super.doIsReadable(); } else { List<String> userGroups = fileSystem.getUserGroups(); Map<String, String> filePermissions = fileSystem.getFilePermission( this.path ); for ( String group : userGroups ) { String acl = filePermissions.get( group ); if ( acl != null ) { return acl.contains( FULL_ACCESS ) || acl.contains( MODIFY_ACCESS ) || acl.contains( READ_AND_EXECUTE_ACCESS ) || acl.contains( READ_ACCESS ) || acl.contains( WRITE_ACCESS ) || acl.contains( WRITE_DATA_ADD_FILES_ACCESS ) || acl.contains( READ_DATA_ADD_FILES_ACCESS ); } } return false; } }
@Override protected boolean doIsWriteable() throws Exception { SftpFileSystemWindows fileSystem = (SftpFileSystemWindows) getAbstractFileSystem(); if ( !fileSystem.isRemoteHostWindows() ) { return super.doIsWriteable(); } else { List<String> userGroups = fileSystem.getUserGroups(); Map<String, String> filePermissions = fileSystem.getFilePermission( this.path ); for ( String group : userGroups ) { String acl = filePermissions.get( group ); if ( acl != null ) { return acl.contains( FULL_ACCESS ) || acl.contains( MODIFY_ACCESS ) || acl.contains( WRITE_ACCESS ) || acl.contains( WRITE_DATA_ADD_FILES_ACCESS ); } } return false; } }