use of de.symeda.sormas.api.sormastosormas.SormasToSormasConfig in project SORMAS-Project by hzi-braunschweig.
the class ConfigFacadeEjb method validateExternalUrls.
@Override
public void validateExternalUrls() {
List<String> urls = Lists.newArrayList(getSymptomJournalConfig().getUrl(), getSymptomJournalConfig().getAuthUrl(), getPatientDiaryConfig().getUrl(), getPatientDiaryConfig().getProbandsUrl(), getPatientDiaryConfig().getAuthUrl(), getPatientDiaryConfig().getFrontendAuthUrl(), getSormasStatsUrl());
SormasToSormasConfig s2sConfig = getS2SConfig();
if (s2sConfig.getOidcServer() != null && s2sConfig.getOidcRealm() != null) {
urls.add(s2sConfig.getOidcRealmCertEndpoint());
urls.add(s2sConfig.getOidcRealmTokenEndpoint());
urls.add(s2sConfig.getOidcRealmUrl());
urls.add(s2sConfig.getOidcServer());
}
UrlValidator urlValidator = new UrlValidator(new String[] { "http", "https" }, UrlValidator.ALLOW_LOCAL_URLS);
urls.forEach(url -> {
if (StringUtils.isBlank(url)) {
return;
}
if (!urlValidator.isValid(url)) {
throw new IllegalArgumentException("'" + url + "' is not a valid URL");
}
});
}
use of de.symeda.sormas.api.sormastosormas.SormasToSormasConfig in project SORMAS-Project by hzi-braunschweig.
the class S2SAuthFilter method fetchPublicKey.
private PublicKey fetchPublicKey() throws VerificationException {
SormasToSormasConfig sormasToSormasConfig = FacadeProvider.getConfigFacade().getS2SConfig();
ObjectMapper mapper = new ObjectMapper();
JSONWebKeySet jwks;
try {
String certEndpoint = sormasToSormasConfig.getOidcRealmCertEndpoint();
jwks = mapper.readValue(new URL(certEndpoint).openStream(), JSONWebKeySet.class);
} catch (IOException e) {
LOGGER.error(String.format("Could not fetch public key for realm: %s", e));
throw new VerificationException("Could not fetch public key for realm");
}
JWK jwk = jwks.getKeys()[0];
return JWKParser.create(jwk).toPublicKey();
}
use of de.symeda.sormas.api.sormastosormas.SormasToSormasConfig in project SORMAS-Project by hzi-braunschweig.
the class SormasToSormasEncryptionFacadeEjb method loadOwnPrivateKey.
private PrivateKey loadOwnPrivateKey() throws CertificateException, KeyStoreException, IOException, NoSuchAlgorithmException, UnrecoverableKeyException {
KeyStore keystore = getKeystore();
SormasToSormasConfig sormasToSormasConfig = configFacadeEjb.getS2SConfig();
PrivateKey privKey = (PrivateKey) keystore.getKey(sormasToSormasConfig.getId(), sormasToSormasConfig.getKeystorePass().toCharArray());
if (privKey == null) {
LOGGER.error("Could not load private key.");
throw new KeyStoreException("Unable to load private key.");
}
LOGGER.info("Successfully loaded private key.");
return privKey;
}
use of de.symeda.sormas.api.sormastosormas.SormasToSormasConfig in project SORMAS-Project by hzi-braunschweig.
the class ReceivedDataProcessor method handleIgnoredProperties.
protected <T> void handleIgnoredProperties(T receivedEntity, T originalEntity) {
Class<?> dtoType = receivedEntity.getClass();
SormasToSormasConfig s2SConfig = configFacade.getS2SConfig();
for (Field field : dtoType.getDeclaredFields()) {
if (field.isAnnotationPresent(S2SIgnoreProperty.class)) {
String s2sConfigProperty = field.getAnnotation(S2SIgnoreProperty.class).configProperty();
if (s2SConfig.getIgnoreProperties().get(s2sConfigProperty)) {
field.setAccessible(true);
try {
Object originalValue = originalEntity != null ? field.get(originalEntity) : null;
field.set(receivedEntity, originalValue);
} catch (IllegalAccessException e) {
logger.error("Could not set field {} for {}", field.getName(), dtoType.getSimpleName());
}
field.setAccessible(false);
}
}
}
}
use of de.symeda.sormas.api.sormastosormas.SormasToSormasConfig in project SORMAS-Project by hzi-braunschweig.
the class ConfigFacadeEjb method getS2SConfig.
@Override
public SormasToSormasConfig getS2SConfig() {
SormasToSormasConfig config = new SormasToSormasConfig();
config.setPath(getProperty(SORMAS2SORMAS_FILES_PATH, null));
config.setKeystoreName(getProperty(SORMAS2SORMAS_KEYSTORE_NAME, null));
config.setKeystorePass(getProperty(SORMAS2SORMAS_KEYSTORE_PASSWORD, null));
config.setTruststoreName(getProperty(SORMAS2SORMAS_TRUSTSTORE_NAME, null));
config.setTruststorePass(getProperty(SORMAS2SORMAS_TRUSTSTORE_PASS, null));
config.setRootCaAlias(getProperty(SORMAS2SORMAS_ROOT_CA_ALIAS, null));
config.setId(getProperty(SORMAS2SORMAS_ID, null));
config.setOidcServer(getProperty(CENTRAL_OIDC_URL, null));
config.setOidcRealm(getProperty(SORMAS2SORMAS_OIDC_REALM, null));
config.setOidcClientId(getProperty(SORMAS2SORMAS_OIDC_CLIENT_ID, null));
config.setOidcClientSecret(getProperty(SORMAS2SORMAS_OIDC_CLIENT_SECRET, null));
config.setKeyPrefix(getProperty(SORMAS2SORMAS_ETCD_KEY_PREFIX, null));
config.getIgnoreProperties().putAll(getS2SIgnoreProperties());
config.setDistrictExternalId(getProperty(SORMAS2SORMAS_DISTRICT_EXTERNAL_ID, null));
return config;
}
Aggregations