Search in sources :

Example 1 with SecureLogHelper

use of com.sun.identity.log.secure.SecureLogHelper in project OpenAM by OpenRock.

the class SecureFileHandler method initializeVerifier.

/**
     * Initialize SecureLog verifier
     * @param verPass verifier password
     * @param token AM token
     */
public static void initializeVerifier(AMPassword verPass, Object token) {
    /*  Remove the relevant verifier initialization code when deploying
         *  it finally. For the timebeing it will be done in the old way
         *  of doing it in the constructor thru initializeSecurity();
         */
    try {
        setVerPassword(verPass, token);
        LogManager lmanager = LogManagerUtil.getLogManager();
        String logPath = lmanager.getProperty(LogConstants.LOG_LOCATION);
        if (!logPath.endsWith("/"))
            logPath += "/";
        LogManager manager = LogManagerUtil.getLogManager();
        Enumeration e = manager.getLoggerNames();
        while (e.hasMoreElements()) {
            String FileName = (String) e.nextElement();
            String verifierFileName = logPath + PREFIX + "ver." + FileName;
            SecureLogHelper helper = getSecureLogHelper(FileName);
            AMPassword logPassword = getLogPassword();
            // explicit auditor role in DSAME to initialize ver.
            if (helper != null) {
                helper.initializeVerifier(verifierFileName, logPassword, verPassword);
                try {
                    Debug.message(FileName + ":Trying to start the Verifier Thread");
                    Logger logger = (com.sun.identity.log.Logger) Logger.getLogger(FileName);
                    Handler[] handlers = logger.getHandlers();
                    ((com.sun.identity.log.handlers.SecureFileHandler) handlers[0]).startVerifierThread();
                    Debug.message(FileName + ":Started Log Verifier thread");
                } catch (Exception ex) {
                    Debug.error(FileName + ":Unable to start Verifier Thread", ex);
                // throw custom exception
                }
            }
            verificationInitialized = true;
        }
    } catch (Exception e) {
        Debug.error("Error initializing Verification", e);
    }
}
Also used : Enumeration(java.util.Enumeration) Handler(java.util.logging.Handler) Logger(com.sun.identity.log.Logger) NullLocationException(com.iplanet.log.NullLocationException) IOException(java.io.IOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) AMPassword(com.sun.identity.security.keystore.AMPassword) LogManager(java.util.logging.LogManager) SecureLogHelper(com.sun.identity.log.secure.SecureLogHelper)

Example 2 with SecureLogHelper

use of com.sun.identity.log.secure.SecureLogHelper in project OpenAM by OpenRock.

the class SecureFileHandler method getSecureLogHelperInst.

/**
     * Returns SecureLogHelper instance
     * @return SecureLogHelper instance
     */
public static SecureLogHelper getSecureLogHelperInst() {
    SecureLogHelper helper = null;
    String helperClass = LogManagerUtil.getLogManager().getProperty(LogConstants.SECURE_LOG_HELPER);
    if (Debug.messageEnabled()) {
        Debug.message("Configured SecureLogHelper Impl class : " + helperClass);
    }
    try {
        helper = (SecureLogHelper) Class.forName(helperClass).newInstance();
    } catch (Exception e) {
        Debug.error("Could not instantiate class " + helperClass, e);
    }
    return helper;
}
Also used : SecureLogHelper(com.sun.identity.log.secure.SecureLogHelper) NullLocationException(com.iplanet.log.NullLocationException) IOException(java.io.IOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Aggregations

NullLocationException (com.iplanet.log.NullLocationException)2 SecureLogHelper (com.sun.identity.log.secure.SecureLogHelper)2 IOException (java.io.IOException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 Logger (com.sun.identity.log.Logger)1 AMPassword (com.sun.identity.security.keystore.AMPassword)1 Enumeration (java.util.Enumeration)1 Handler (java.util.logging.Handler)1 LogManager (java.util.logging.LogManager)1