@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; } }
/** * get user group on remote windows host * @return list of groups + user person * @throws JSchException * @throws IOException */ List<String> getUserGroups() throws JSchException, IOException { if ( userGroups == null ) { StringBuilder output = new StringBuilder(); int code = this.executeCommand( WHO_AMI_GROUPS_FO_LIST, output ); if ( code != 0 ) { throw new JSchException( "Could not get the groups of the current user (error code: " + code + ")" ); } this.userGroups = getUserGroups( output.toString() ); userGroups.add( getUser() ); } return this.userGroups; }
@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; } }