All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openhealthtools.ihe.atna.context.SecurityContextInitializer Maven / Gradle / Ivy

The newest version!
/*******************************************************************************
 * Copyright (c) 2008 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.openhealthtools.ihe.atna.context;

import java.lang.reflect.Method;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Static Security Context initializer for active loading and configuration
 * of the Security Context as well as for calling associated module contexts
 * that should be initialized by default upon loading of the security context.
 * 
 * @author  clazz = Class.forName(moduleName + MODULE_INITIALIZER_CLASS);
				
				// Get the method instance for the module initializer's initialization method
				Method method = clazz.getMethod(MODULE_INITIALIZER_METHOD, (Class[])null);
				
				// Invoke the initialization method
				Object invokeResult = method.invoke(clazz.newInstance(), (Object[])null);
				
				// Validate that the result of the initialization is a valid module context
				if (invokeResult instanceof AbstractModuleContext) {
					
					// Register the module context
					context.registerModuleContext(moduleName, (AbstractModuleContext)invokeResult);
				} else {
					throw new IllegalArgumentException("Initializer method did not return correct type");
				}

				if (LOGGER.isInfoEnabled()) {
					LOGGER.info("SecurityContext module "+ moduleName + " initialized");
				}
			}  catch (ClassNotFoundException cnfe) {
				LOGGER.warn("SecurityContext module "+ moduleName + " not found, skipping.");
				if (LOGGER.isDebugEnabled()) {
					LOGGER.debug("Stack trace: ", cnfe);
				}
			} catch (NoSuchMethodException nsme) {
				LOGGER.warn("SecurityContext module "+ moduleName + " does not support default initialization, skipping.", nsme);
				if (LOGGER.isDebugEnabled()) {
					LOGGER.debug("Stack trace: ", nsme);
				}
			} catch (Throwable t) {
				LOGGER.error("Error initializing SecurityContext module "+ moduleName, t);
			} finally {

			}
		}
		if (LOGGER.isDebugEnabled()) {
			LOGGER.debug("SecurityContext default module initializer ending");
		}		
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy