use of org.ovirt.engine.core.extensions.mgr.ExtensionProxy in project ovirt-engine by oVirt.
the class EngineExtensionsManager method engineInitialize.
public void engineInitialize() {
for (File directory : EngineLocalConfig.getInstance().getExtensionsDirectories()) {
if (!directory.exists()) {
log.warn("The directory '{}' cotaning configuration files does not exist.", directory.getAbsolutePath());
} else {
// The order of the files inside the directory is relevant, as the objects are created in
// the same order
// that
// the files are processed, so it is better to sort them so that objects will always be
// created in the
// same
// order regardless of how the filesystem decides to store the entries of the directory:
File[] files = directory.listFiles();
if (files != null) {
sort(files);
for (File file : files) {
if (file.getName().endsWith(".properties")) {
try {
load(file);
} catch (Exception ex) {
log.error("Could not load extension based on configuration file '{}'. Please check the configuration file is valid. Exception message is: {}", file.getAbsolutePath(), ex.getMessage());
log.debug("", ex);
}
}
}
}
}
}
Pattern pattern = Pattern.compile(EngineLocalConfig.getInstance().getProperty(ENGINE_EXTENSIONS_IGNORED));
for (ExtensionProxy extension : getLoadedExtensions()) {
if (EngineLocalConfig.getInstance().getBoolean(ENGINE_EXTENSION_ENABLED + normalizeName(extension.getContext().get(Base.ContextKeys.INSTANCE_NAME)), Boolean.parseBoolean(extension.getContext().<Properties>get(Base.ContextKeys.CONFIGURATION).getProperty(Base.ConfigKeys.ENABLED, "true"))) && extension.getContext().<Collection<String>>get(Base.ContextKeys.PROVIDES).stream().noneMatch(p -> pattern.matcher(p).matches())) {
try {
initialize(extension.getContext().get(Base.ContextKeys.INSTANCE_NAME));
} catch (Exception ex) {
log.error("Could not initialize extension '{}'. Exception message is: {}", extension.getContext().<String>get(Base.ContextKeys.INSTANCE_NAME), ex.getMessage());
log.debug("", ex);
}
}
}
dump();
}
use of org.ovirt.engine.core.extensions.mgr.ExtensionProxy in project ovirt-engine by oVirt.
the class LoggerHandler method publish.
@Override
public void publish(LogRecord record) {
ExtMap publishInputMap = new ExtMap().mput(Base.InvokeKeys.COMMAND, Logger.InvokeCommands.PUBLISH).mput(Logger.InvokeKeys.LOG_RECORD, record);
ExtMap publishOutputMap = new ExtMap();
for (ExtensionProxy extension : extensions) {
try {
extension.invoke(publishInputMap, publishOutputMap);
} catch (Exception ex) {
// ignore, logging this exception will result in infinite loop
}
}
}
use of org.ovirt.engine.core.extensions.mgr.ExtensionProxy in project ovirt-engine by oVirt.
the class SsoExtensionsManager method initialize.
private void initialize() {
String path = localConfig.getExtensionsPath();
List<File> extensionsDirectories = new ArrayList<>();
if (path != null) {
for (String currentPath : path.split(":")) {
if (StringUtils.isNotBlank(currentPath)) {
extensionsDirectories.add(new File(currentPath));
}
}
}
for (File directory : extensionsDirectories) {
if (!directory.exists()) {
log.warn("The directory '{}' cotaning configuration files does not exist.", directory.getAbsolutePath());
} else {
// The order of the files inside the directory is relevant, as the objects are created in
// the same order
// that
// the files are processed, so it is better to sort them so that objects will always be
// created in the
// same
// order regardless of how the filesystem decides to store the entries of the directory:
File[] files = directory.listFiles();
if (files != null) {
sort(files);
for (File file : files) {
if (file.getName().endsWith(".properties")) {
try {
load(file);
} catch (Exception ex) {
log.error("Could not load extension based on configuration file '{}'. " + "Please check the configuration file is valid. Exception message is: {}", file.getAbsolutePath(), ex.getMessage());
log.debug("Exception", ex);
}
}
}
}
}
}
for (ExtensionProxy extension : getLoadedExtensions()) {
if (localConfig.getBoolean(ENGINE_EXTENSION_ENABLED + normalizeName(extension.getContext().get(Base.ContextKeys.INSTANCE_NAME)), Boolean.parseBoolean(extension.getContext().<Properties>get(Base.ContextKeys.CONFIGURATION).getProperty(Base.ConfigKeys.ENABLED, "true")))) {
try {
initialize(extension.getContext().get(Base.ContextKeys.INSTANCE_NAME));
} catch (Exception ex) {
log.error("Could not initialize extension '{}'. Exception message is: {}", extension.getContext().<String>get(Base.ContextKeys.INSTANCE_NAME), ex.getMessage());
log.debug("Exception", ex);
}
}
}
dump();
}
use of org.ovirt.engine.core.extensions.mgr.ExtensionProxy in project ovirt-engine by oVirt.
the class TokenCleanupUtility method invokeAuthnLogout.
private static void invokeAuthnLogout(SsoContext ssoContext, SsoSession ssoSession) throws Exception {
String profileName = ssoSession.getProfile();
String principalName = ssoSession.getUserId();
ExtMap authRecord = null;
ExtensionProxy authn = null;
try {
authRecord = ssoSession.getAuthRecord();
if (StringUtils.isNotEmpty(profileName) && StringUtils.isNotEmpty(principalName)) {
for (ExtensionProxy authnExtension : ssoContext.getSsoExtensionsManager().getExtensionsByService(Authn.class.getName())) {
Properties config = authnExtension.getContext().get(Base.ContextKeys.CONFIGURATION);
if (profileName.equals(config.getProperty(Authn.ConfigKeys.PROFILE_NAME))) {
authn = authnExtension;
break;
}
}
}
} catch (Exception ex) {
throw new RuntimeException(String.format("Unable to invalidate sessions for token: %s", ex.getMessage()));
} finally {
if (authn != null && authRecord != null && (authn.getContext().<Long>get(Authn.ContextKeys.CAPABILITIES) & Authn.Capabilities.LOGOUT) != 0) {
authn.invoke(new ExtMap().mput(Base.InvokeKeys.COMMAND, Authn.InvokeCommands.LOGOUT).mput(Authn.InvokeKeys.AUTH_RECORD, authRecord));
}
}
}
Aggregations