@Override public boolean isPathEncrypted(Path path) throws IOException { Path fullPath; if (path.isAbsolute()) { fullPath = path; } else { fullPath = path.getFileSystem(conf).makeQualified(path); } if(!"hdfs".equalsIgnoreCase(path.toUri().getScheme())) { return false; } return (getEncryptionZoneForPath(fullPath) != null); }
private EncryptionZone getEncryptionZoneForPath(Path path) throws IOException { if (path.getFileSystem(conf).exists(path)) { return hdfsAdmin.getEncryptionZoneForPath(path); } else if (!path.getParent().equals(path)) { return getEncryptionZoneForPath(path.getParent()); } else { return null; } }
@Override public boolean isPathEncrypted(Path path) throws IOException { Path fullPath; if (path.isAbsolute()) { fullPath = path; } else { fullPath = path.getFileSystem(conf).makeQualified(path); } if(!"hdfs".equalsIgnoreCase(path.toUri().getScheme())) { return false; } return (getEncryptionZoneForPath(fullPath) != null); }
/** * Compares two encryption key strengths. * * @param path1 First path to compare * @param path2 Second path to compare * @return 1 if path1 is stronger; 0 if paths are equals; -1 if path1 is weaker. * @throws IOException If an error occurred attempting to get key metadata */ @Override public int comparePathKeyStrength(Path path1, Path path2) throws IOException { EncryptionZone zone1, zone2; zone1 = getEncryptionZoneForPath(path1); zone2 = getEncryptionZoneForPath(path2); if (zone1 == null && zone2 == null) { return 0; } else if (zone1 == null) { return -1; } else if (zone2 == null) { return 1; } return compareKeyStrength(zone1, zone2); }
private EncryptionZone getEncryptionZoneForPath(Path path) throws IOException { if (path.getFileSystem(conf).exists(path)) { return hdfsAdmin.getEncryptionZoneForPath(path); } else if (!path.getParent().equals(path)) { return getEncryptionZoneForPath(path.getParent()); } else { return null; } }
@Override public boolean arePathsOnSameEncryptionZone(Path path1, Path path2) throws IOException { return equivalentEncryptionZones(getEncryptionZoneForPath(path1), getEncryptionZoneForPath(path2)); }
/** * Compares two encryption key strengths. * * @param path1 First path to compare * @param path2 Second path to compare * @return 1 if path1 is stronger; 0 if paths are equals; -1 if path1 is weaker. * @throws IOException If an error occurred attempting to get key metadata */ @Override public int comparePathKeyStrength(Path path1, Path path2) throws IOException { EncryptionZone zone1, zone2; zone1 = getEncryptionZoneForPath(path1); zone2 = getEncryptionZoneForPath(path2); if (zone1 == null && zone2 == null) { return 0; } else if (zone1 == null) { return -1; } else if (zone2 == null) { return 1; } return compareKeyStrength(zone1, zone2); }
@Override public boolean arePathsOnSameEncryptionZone(Path path1, Path path2) throws IOException { return equivalentEncryptionZones(getEncryptionZoneForPath(path1), getEncryptionZoneForPath(path2)); }