new TomcatAuthenticationContainerDiscovery()
};
@Override
public void init(FilterConfig filterConfig) throws ServletException {
ConfigManager config = (ConfigManager) filterConfig.getServletContext().getAttribute("ConfigManager");
String defaultRolePrincipalClasses = "";
if (System.getProperty("karaf.name") != null) {
defaultRolePrincipalClasses = "org.apache.karaf.jaas.boot.principal.RolePrincipal,org.apache.karaf.jaas.modules.RolePrincipal,org.apache.karaf.jaas.boot.principal.GroupPrincipal";
}
if (config != null) {
configuration.setRealm(config.get("realm", "karaf"));
// we have either role or roles
String roles = config.get("role", null);
if (roles == null) {
roles = config.get("roles", null);
}
if (roles == null) {
// use default roles (karaf roles)
roles = "admin,viewer";
}
configuration.setRole(roles);
configuration.setRolePrincipalClasses(config.get("rolePrincipalClasses", defaultRolePrincipalClasses));
configuration.setEnabled(Boolean.parseBoolean(config.get("authenticationEnabled", "true")));
configuration.setNoCredentials401(Boolean.parseBoolean(config.get("noCredentials401", "false")));
}
// JVM system properties can override always
if (System.getProperty(HAWTIO_AUTHENTICATION_ENABLED) != null) {
configuration.setEnabled(Boolean.getBoolean(HAWTIO_AUTHENTICATION_ENABLED));