Search in sources :

Example 1 with LogMessageProvider

use of com.sun.identity.log.messageid.LogMessageProvider in project OpenAM by OpenRock.

the class OpenSSOLogger method log.

public static void log(LogLevel type, Level level, String msgid, String[] msgdata, Subject logFor) {
    Logger logger = (type.equals(LogLevel.ERROR)) ? LoggerFactory.getLogger(LOG_NAME + ".error") : LoggerFactory.getLogger(LOG_NAME + ".access");
    if (logger.isLoggable(level)) {
        try {
            LogMessageProvider msgProvider = MessageProviderFactory.getProvider(LOG_MSG_XML);
            LogRecord logRec = msgProvider.createLogRecord(msgid, msgdata, SubjectUtils.getSSOToken(logFor));
            if (logRec != null) {
                logger.log(getERecord(logRec));
            }
        } catch (IOException ex) {
            Logger.getLogger(OpenSSOLogger.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
Also used : LogMessageProvider(com.sun.identity.log.messageid.LogMessageProvider) ELogRecord(com.sun.identity.entitlement.log.ELogRecord) LogRecord(com.sun.identity.log.LogRecord) IOException(java.io.IOException) Logger(java.util.logging.Logger)

Example 2 with LogMessageProvider

use of com.sun.identity.log.messageid.LogMessageProvider in project OpenAM by OpenRock.

the class TokenLogUtils method access.

/**
     * Logs message to core token access logs.
     *
     * @param level the log level , these are based on those
     *          defined in java.util.logging.Level, the values for
     *          level can be any one of the following : <br>
     *          <ul>
     *          <li>SEVERE (highest value) <br>
     *          <li>WARNING <br>
     *          <li>INFO <br>
     *          <li>CONFIG <br>
     *          <li>FINE <br>
     *          <li>FINER <br>
     *          <li>FINEST (lowest value) <br>
     *          </ul>
     * @param msgid the message or a message identifier.
     * @param data string array of dynamic data to be replaced in the message.
     * @param session the User's session object
     * @param nameId value for NameID logging field
     */
public static void access(Level level, String msgid, String[] data, SSOToken session, String nameId) {
    if (logActive) {
        try {
            if (isAccessLoggable(level)) {
                SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
                LogMessageProvider msgProvider = MessageProviderFactory.getProvider(LOG_MSG_XML);
                LogRecord logRec = msgProvider.createLogRecord(msgid, data, session);
                logRec.addLogInfo(TokenLogUtils.TOKEN_NAME_ID, nameId);
                if (logRec != null) {
                    accessLogger.log(logRec, adminToken);
                }
            }
        } catch (IOException le) {
            CoreTokenUtils.debug.error("TokenLogUtils.error:Couldn't write error log:", le);
        }
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) LogMessageProvider(com.sun.identity.log.messageid.LogMessageProvider) LogRecord(com.sun.identity.log.LogRecord) IOException(java.io.IOException)

Example 3 with LogMessageProvider

use of com.sun.identity.log.messageid.LogMessageProvider in project OpenAM by OpenRock.

the class TokenLogUtils method error.

/** 
     * Logs error messages to core token error log.
     *
     * @param level the log level , these are based on those
     *          defined in java.util.logging.Level, the values for
     *          level can be any one of the following : <br>
     *          <ul>
     *          <li>SEVERE (highest value) <br>
     *          <li>WARNING <br>
     *          <li>INFO <br>
     *          <li>CONFIG <br>
     *          <li>FINE <br>
     *          <li>FINER <br>
     *          <li>FINEST (lowest value) <br>
     *          </ul>
     * @param msgid the message or a message identifier.
     * @param data string array of dynamic data to be replaced in the message.
     * @param session the User's Session object.
     * @param nameId value for NameID logging field
      */
public static void error(Level level, String msgid, String[] data, SSOToken session, String nameId) {
    if (logActive) {
        try {
            if (isErrorLoggable(level)) {
                SSOToken adminToken = (SSOToken) AccessController.doPrivileged(AdminTokenAction.getInstance());
                LogMessageProvider msgProvider = MessageProviderFactory.getProvider(LOG_MSG_XML);
                LogRecord logRec = msgProvider.createLogRecord(msgid, data, session);
                logRec.addLogInfo(TokenLogUtils.TOKEN_NAME_ID, nameId);
                if (logRec != null) {
                    errorLogger.log(logRec, adminToken);
                }
            }
        } catch (IOException le) {
            CoreTokenUtils.debug.error("TokenLogUtils.error:Couldn't write error log:", le);
        }
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) LogMessageProvider(com.sun.identity.log.messageid.LogMessageProvider) LogRecord(com.sun.identity.log.LogRecord) IOException(java.io.IOException)

Example 4 with LogMessageProvider

use of com.sun.identity.log.messageid.LogMessageProvider in project OpenAM by OpenRock.

the class LogWriter method log.

/**
     * Writes to log.
     *
     * @param mgr Command Manager Object.
     * @param type Type of log message.
     * @param level Logging level of the message.
     * @param msgid ID for message.
     * @param msgdata array of log message "data".
     * @param ssoToken Single Sign On Token of the user who committed the
     *        operation.
     * @throws CLIException if log cannot be written.
     */
public static void log(CommandManager mgr, int type, Level level, String msgid, String[] msgdata, SSOToken ssoToken) throws CLIException {
    if (!mgr.isLogOff()) {
        Logger logger;
        String logName = mgr.getLogName();
        switch(type) {
            case LOG_ERROR:
                logger = (com.sun.identity.log.Logger) Logger.getLogger(logName + ".error");
                break;
            default:
                logger = (com.sun.identity.log.Logger) Logger.getLogger(logName + ".access");
        }
        try {
            LogMessageProvider msgProvider = MessageProviderFactory.getProvider(LOG_MSG_XML);
            SSOToken adminSSOToken = AccessController.doPrivileged(AdminTokenAction.getInstance());
            if (ssoToken == null) {
                ssoToken = adminSSOToken;
            }
            if (logger.isLoggable(level)) {
                LogRecord logRec = msgProvider.createLogRecord(msgid, msgdata, ssoToken);
                if (logRec != null) {
                    logger.log(logRec, adminSSOToken);
                }
            }
            logToAuditService(type, msgid, msgdata, ssoToken, msgProvider, adminSSOToken);
        } catch (Exception e) {
            throw new CLIException(e, ExitCodes.CANNOT_WRITE_LOG);
        }
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) LogMessageProvider(com.sun.identity.log.messageid.LogMessageProvider) LogRecord(com.sun.identity.log.LogRecord) Logger(com.sun.identity.log.Logger) URISyntaxException(java.net.URISyntaxException) HttpApplicationException(org.forgerock.http.HttpApplicationException) NeverThrowsException(org.forgerock.util.promise.NeverThrowsException) IOException(java.io.IOException)

Example 5 with LogMessageProvider

use of com.sun.identity.log.messageid.LogMessageProvider in project OpenAM by OpenRock.

the class AMModelBase method logEvent.

/**
     * Writes log event.
     *
     * @param id Log Message ID.
     * @param data Log Data.
     */
public void logEvent(String id, String[] data) {
    try {
        LogMessageProvider provider = MessageProviderFactory.getProvider(LOG_PROVIDER);
        LogRecord rec = provider.createLogRecord(id, data, ssoToken);
        if (rec != null) {
            AMAdminLog.getInstance().doLog(rec);
        } else {
            debug.error("AMModelBase.logEvent: missing log entry, " + id);
        }
    } catch (IOException e) {
        debug.error("AMModelBase.logEvent", e);
    }
}
Also used : LogMessageProvider(com.sun.identity.log.messageid.LogMessageProvider) LogRecord(com.sun.identity.log.LogRecord) IOException(java.io.IOException)

Aggregations

LogRecord (com.sun.identity.log.LogRecord)5 LogMessageProvider (com.sun.identity.log.messageid.LogMessageProvider)5 IOException (java.io.IOException)5 SSOToken (com.iplanet.sso.SSOToken)3 ELogRecord (com.sun.identity.entitlement.log.ELogRecord)1 Logger (com.sun.identity.log.Logger)1 URISyntaxException (java.net.URISyntaxException)1 Logger (java.util.logging.Logger)1 HttpApplicationException (org.forgerock.http.HttpApplicationException)1 NeverThrowsException (org.forgerock.util.promise.NeverThrowsException)1