@Test public void testEmpty() throws Exception { String userHome = System.getProperty("user.home"); try { File tempDir = Files.createTempDirectory("d-m-p").toFile(); System.setProperty("user.home", tempDir.getAbsolutePath()); assertEquals(handler.create(RegistryAuthConfig.Kind.PUSH, null, "blubberbla:1611", s->s), null); } finally { System.setProperty("user.home", userHome); } }
@Override public AuthConfig create(RegistryAuthConfig.Kind kind, String user, String registry, Function<String, String> decryptor) { Properties props = System.getProperties(); String username = registryAuthConfig.extractFromProperties(props, kind, RegistryAuth.USERNAME); String password = registryAuthConfig.extractFromProperties(props, kind, RegistryAuth.PASSWORD); if (username == null) { return null; } if (password == null) { throw new IllegalArgumentException("No password provided for username " + username); } log.debug("AuthConfig: credentials from system properties"); return new AuthConfig.Builder() .username(username) .password(password, decryptor) .email(registryAuthConfig.extractFromProperties(props, kind, RegistryAuth.EMAIL)) .auth(registryAuthConfig.extractFromProperties(props, kind, RegistryAuth.AUTH)) .build(); }
SystemPropertyRegistryAuthHandler implements RegistryAuthHandler { @Override public AuthConfig create(RegistryAuthConfig.Kind kind, String user, String registry, Function<String, String> decryptor) { Properties props = System.getProperties(); String username = registryAuthConfig.extractFromProperties(props, kind, RegistryAuth.USERNAME); String password = registryAuthConfig.extractFromProperties(props, kind, RegistryAuth.PASSWORD); if (username == null) { return null; } if (password == null) { throw new IllegalArgumentException("No password provided for username " + username); } log.debug("AuthConfig: credentials from system properties"); return new AuthConfig.Builder() .username(username) .password(password, decryptor) .email(registryAuthConfig.extractFromProperties(props, kind, RegistryAuth.EMAIL)) .auth(registryAuthConfig.extractFromProperties(props, kind, RegistryAuth.AUTH)) .build(); } }
SystemPropertyRegistryAuthHandler implements RegistryAuthHandler { @Override public AuthConfig create(RegistryAuthConfig.Kind kind, String user, String registry, Function<String, String> decryptor) { Properties props = System.getProperties(); String username = registryAuthConfig.extractFromProperties(props, kind, RegistryAuth.USERNAME); String password = registryAuthConfig.extractFromProperties(props, kind, RegistryAuth.PASSWORD); if (username == null) { return null; } if (password == null) { throw new IllegalArgumentException("No password provided for username " + username); } log.debug("AuthConfig: credentials from system properties"); return new AuthConfig.Builder() .username(username) .password(password, decryptor) .email(registryAuthConfig.extractFromProperties(props, kind, RegistryAuth.EMAIL)) .auth(registryAuthConfig.extractFromProperties(props, kind, RegistryAuth.AUTH)) .build(); } SystemPropertyRegistryAuthHandler(RegistryAuthConfig registryAuthConfig, KitLogger log); }
SystemPropertyRegistryAuthHandler implements RegistryAuthHandler { @Override public AuthConfig create(RegistryAuthConfig.Kind kind, String user, String registry, Function<String, String> decryptor) { Properties props = System.getProperties(); String username = registryAuthConfig.extractFromProperties(props, kind, RegistryAuth.USERNAME); String password = registryAuthConfig.extractFromProperties(props, kind, RegistryAuth.PASSWORD); if (username == null) { return null; } if (password == null) { throw new IllegalArgumentException("No password provided for username " + username); } log.debug("AuthConfig: credentials from system properties"); return new AuthConfig.Builder() .username(username) .password(password, decryptor) .email(registryAuthConfig.extractFromProperties(props, kind, RegistryAuth.EMAIL)) .auth(registryAuthConfig.extractFromProperties(props, kind, RegistryAuth.AUTH)) .build(); } SystemPropertyRegistryAuthHandler(RegistryAuthConfig registryAuthConfig, KitLogger log); @Override String getId(); @Override AuthConfig create(RegistryAuthConfig.Kind kind, String user, String registry, Function<String, String> decryptor); }
SystemPropertyRegistryAuthHandler implements RegistryAuthHandler { @Override public AuthConfig create(RegistryAuthConfig.Kind kind, String user, String registry, Function<String, String> decryptor) { Properties props = System.getProperties(); String username = registryAuthConfig.extractFromProperties(props, kind, RegistryAuth.USERNAME); String password = registryAuthConfig.extractFromProperties(props, kind, RegistryAuth.PASSWORD); if (username == null) { return null; } if (password == null) { throw new IllegalArgumentException("No password provided for username " + username); } log.debug("AuthConfig: credentials from system properties"); return new AuthConfig.Builder() .username(username) .password(password, decryptor) .email(registryAuthConfig.extractFromProperties(props, kind, RegistryAuth.EMAIL)) .auth(registryAuthConfig.extractFromProperties(props, kind, RegistryAuth.AUTH)) .build(); } SystemPropertyRegistryAuthHandler(RegistryAuthConfig registryAuthConfig, KitLogger log); @Override String getId(); @Override AuthConfig create(RegistryAuthConfig.Kind kind, String user, String registry, Function<String, String> decryptor);  }