CertificateLocalizationService extends AbstractService implements CertificateLocalization, CertificateLocalizationMBean { @VisibleForTesting public Path getMaterializeDirectory() { return materializeDir; } CertificateLocalizationService(ServiceType service); char[] readSupersuperPassword(); @Override String getSuperKeystoreLocation(); @Override String getSuperKeystorePass(); @Override String getSuperKeyPassword(); @Override String getSuperTruststoreLocation(); @Override String getSuperTruststorePass(); @Override String getSuperMaterialPasswordFile(); @VisibleForTesting Path getMaterializeDirectory(); @Override void materializeCertificates(String username, String user,
      ByteBuffer keyStore, String keyStorePassword,
      ByteBuffer trustStore, String trustStorePassword); @Override void materializeCertificates(String username, String applicationId, String user,
      ByteBuffer keyStore, String keyStorePassword,
      ByteBuffer trustStore, String trustStorePassword); @Override void updateX509(String username, String applicationId, ByteBuffer keyStore,
      String keyStorePassword, ByteBuffer trustStore, String trustStorePassword); @Override void updateJWT(String username, String applicationId, String jwt); @Override void materializeJWT(String username, String applicationId, String userFolder, String jwt); @Override void removeX509Material(String username); @Override void removeX509Material(String username, String applicationId); @Override void removeJWTMaterial(String username, String applicationId); @Override X509SecurityMaterial getX509MaterialLocation(String username); @Override X509SecurityMaterial getX509MaterialLocation(String username, String applicationId); @Override JWTSecurityMaterial getJWTMaterialLocation(String username, String applicationId); @Override String getState(); @Override boolean forceRemoveMaterial(String username); @Override boolean forceRemoveMaterial(String username, String applicationId); static final String JMX_MATERIALIZED_KEY; static final String JMX_FORCE_REMOVE_OP; }
@Test public void testLocalizationDirectory() throws Exception { Path materializeDir = certLocSrv.getMaterializeDirectory(); Set<PosixFilePermission> permissionSet = Files.getPosixFilePermissions(materializeDir); Set<PosixFilePermission> expectedPermissionSet = null; if (service == CertificateLocalizationService.ServiceType.NM) { expectedPermissionSet = EnumSet.of(PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE, PosixFilePermission.OWNER_EXECUTE, PosixFilePermission.GROUP_EXECUTE, PosixFilePermission.OTHERS_EXECUTE); } else { expectedPermissionSet = EnumSet.of(PosixFilePermission.OWNER_READ, PosixFilePermission.OWNER_WRITE, PosixFilePermission.OWNER_EXECUTE); } assertTrue(permissionSet.containsAll(expectedPermissionSet)); }