KEYCLOAK-1779 NPE due to missing web.xml/jboss-web.xml
- improved code readability and npe fix
This commit is contained in:
parent
e6745532ce
commit
b0095154d1
1 changed files with 20 additions and 15 deletions
|
@ -64,23 +64,28 @@ public class KeycloakAdapterConfigDeploymentProcessor implements DeploymentUnitP
|
||||||
|
|
||||||
KeycloakAdapterConfigService service = KeycloakAdapterConfigService.getInstance();
|
KeycloakAdapterConfigService service = KeycloakAdapterConfigService.getInstance();
|
||||||
|
|
||||||
// if secure-deployment configuration exists for web app, we force KEYCLOAK auth method on it
|
// otherwise
|
||||||
// otherwise we only set up KEYCLOAK auth if it's requested through web.xml auth-method
|
|
||||||
LoginConfigMetaData loginConfig = webMetaData.getLoginConfig();
|
LoginConfigMetaData loginConfig = webMetaData.getLoginConfig();
|
||||||
if (!service.isSecureDeployment(deploymentName) || loginConfig == null || !loginConfig.getAuthMethod().equalsIgnoreCase("KEYCLOAK")) {
|
|
||||||
return;
|
boolean hasSubsystemConfig = service.isSecureDeployment(deploymentName);
|
||||||
|
boolean webRequiresKC = loginConfig != null && "KEYCLOAK".equalsIgnoreCase(loginConfig.getAuthMethod());
|
||||||
|
|
||||||
|
if (hasSubsystemConfig || webRequiresKC) {
|
||||||
|
log.debug("Setting up KEYCLOAK auth method for WAR: " + deploymentName);
|
||||||
|
|
||||||
|
// if secure-deployment configuration exists for web app, we force KEYCLOAK auth method on it
|
||||||
|
if (hasSubsystemConfig) {
|
||||||
|
addJSONData(service.getJSON(deploymentName), warMetaData);
|
||||||
|
if (loginConfig != null) {
|
||||||
|
loginConfig.setAuthMethod("KEYCLOAK");
|
||||||
|
loginConfig.setRealmName(service.getRealmName(deploymentName));
|
||||||
|
} else {
|
||||||
|
log.warn("Failed to set up KEYCLOAK auth method for WAR: " + deploymentName + " (loginConfig == null)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
addValve(webMetaData);
|
||||||
|
KeycloakLogger.ROOT_LOGGER.deploymentSecured(deploymentName);
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug("Setting up KEYCLOAK auth method for WAR: " + deploymentName);
|
|
||||||
loginConfig.setAuthMethod("KEYCLOAK");
|
|
||||||
|
|
||||||
if (service.isSecureDeployment(deploymentName)) {
|
|
||||||
addJSONData(service.getJSON(deploymentName), warMetaData);
|
|
||||||
loginConfig.setRealmName(service.getRealmName(deploymentName));
|
|
||||||
}
|
|
||||||
addValve(webMetaData);
|
|
||||||
|
|
||||||
KeycloakLogger.ROOT_LOGGER.deploymentSecured(deploymentName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addValve(JBossWebMetaData webMetaData) {
|
private void addValve(JBossWebMetaData webMetaData) {
|
||||||
|
|
Loading…
Reference in a new issue