@EventListener(ContextRefreshedEvent.class)
public void setHttpProperties() throws NoSuchAlgorithmException, KeyManagementException {
- SSLContext sslContext = SSLContext.getInstance("SSL");
- sslContext.init(null, this.trustAll, new java.security.SecureRandom());
- HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
- // Install the all-trusting host verifier
- HttpsURLConnection.setDefaultHostnameVerifier(this.hostnameVerifier);
- DefaultClientConfig config = new DefaultClientConfig();
- Map<String, Object> properties = config.getProperties();
- HTTPSProperties httpsProperties = new HTTPSProperties((str, sslSession) -> true, sslContext);
- properties.put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, httpsProperties);
+ if (System.getenv("TRUST_ALL") != null && System.getenv("TRUST_ALL").equals("true")) {
+ SSLContext sslContext = SSLContext.getInstance("SSL");
+ sslContext.init(null, this.trustAll, new java.security.SecureRandom());
+ HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
+ // Install the all-trusting host verifier
+ HttpsURLConnection.setDefaultHostnameVerifier(this.hostnameVerifier);
+ DefaultClientConfig config = new DefaultClientConfig();
+ Map<String, Object> properties = config.getProperties();
+ HTTPSProperties httpsProperties = new HTTPSProperties((str, sslSession) -> true, sslContext);
+ properties.put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, httpsProperties);
+ }
}
@EventListener(ContextRefreshedEvent.class)
- public void updateUsers() throws RuntimeException, IOException, CipherUtilException {
+ public void updateAdminUser() throws RuntimeException, IOException, CipherUtilException {
User admin = null;
List<User> users = userService.findAllActive();
for (User user : users) {
if (admin == null) {
throw new RuntimeException("Admin user does not exist");
}
- admin.setLoginPwd(CipherUtil.encryptPKC(System.getenv("UI_ADMIN_PASSWORD"), System.getenv("ENCRYPTION_KEY")));
- userService.saveUser(admin);
- User akraino = null;
- for (User user : users) {
- if (user.getLoginId().equals("akraino")) {
- akraino = user;
- }
- }
- if (akraino == null) {
- throw new RuntimeException("Akraino user does not exist");
+ if (admin.getLoginPwd().equals("admin_password")) {
+ admin.setLoginPwd(
+ CipherUtil.encryptPKC(System.getenv("UI_ADMIN_PASSWORD"), System.getenv("ENCRYPTION_KEY")));
+ userService.saveUser(admin);
}
- akraino.setLoginPwd(
- CipherUtil.encryptPKC(System.getenv("UI_AKRAINO_PASSWORD"), System.getenv("ENCRYPTION_KEY")));
- userService.saveUser(akraino);
}
}