Search in sources :

Example 11 with LogRecord

use of com.sun.identity.log.LogRecord 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)

Example 12 with LogRecord

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

the class OAuth2AuditLogger method logAccessMessage.

/**
     * Logs an access message.
     *
     * @param msgIdName The message id name.
     * @param data The data to log.
     * @param token The SSO Token to authenticate the log operation.
     */
public void logAccessMessage(String msgIdName, String[] data, SSOToken token) {
    try {
        getLogMessageProvider();
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
        logger.error("disabling logging");
        logStatus = false;
    }
    if ((accessLogger != null) && (msgProvider != null)) {
        final LogRecord lr = msgProvider.createLogRecord(msgIdName, data, token);
        if (lr != null) {
            final SSOToken ssoToken = AccessController.doPrivileged(AdminTokenAction.getInstance());
            accessLogger.log(lr, ssoToken);
        }
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) LogRecord(com.sun.identity.log.LogRecord) IOException(java.io.IOException)

Example 13 with LogRecord

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

the class OAuth2AuditLogger method logErrorMessage.

/**
     * Logs an error message.
     *
     * @param msgIdName The message id name.
     * @param data The data to log.
     * @param token The SSO Token to authenticate the log operation.
     */
public void logErrorMessage(String msgIdName, String[] data, SSOToken token) {
    try {
        getLogMessageProvider();
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
        logger.error("disabling logging");
        logStatus = false;
    }
    if (errorLogger != null && msgProvider != null) {
        final LogRecord lr = msgProvider.createLogRecord(msgIdName, data, token);
        if (lr != null) {
            final SSOToken ssoToken = AccessController.doPrivileged(AdminTokenAction.getInstance());
            errorLogger.log(lr, ssoToken);
        }
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) LogRecord(com.sun.identity.log.LogRecord) IOException(java.io.IOException)

Example 14 with LogRecord

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

the class SessionLogging method logIt.

private void logIt(SessionInfo sessionInfo, String eventId) {
    try {
        String clientID = sessionInfo.getClientID();
        String uidData;
        if (StringUtils.isEmpty(clientID)) {
            uidData = "N/A";
        } else {
            StringTokenizer st = new StringTokenizer(clientID, ",");
            uidData = (st.hasMoreTokens()) ? st.nextToken() : clientID;
        }
        String[] data = { uidData };
        LogRecord lr = getLogMessageProvider().createLogRecord(eventId, data, null);
        lr.addLogInfo(LogConstants.LOGIN_ID_SID, sessionInfo.getSessionID());
        lr.addLogInfo(LogConstants.CONTEXT_ID, sessionInfo.getProperties().get(Constants.AM_CTX_ID));
        lr.addLogInfo(LogConstants.LOGIN_ID, clientID);
        lr.addLogInfo(LogConstants.LOG_LEVEL, lr.getLevel().toString());
        lr.addLogInfo(LogConstants.DOMAIN, sessionInfo.getClientDomain());
        lr.addLogInfo(LogConstants.IP_ADDR, sessionInfo.getProperties().get(HOST_PROP));
        lr.addLogInfo(LogConstants.HOST_NAME, sessionInfo.getProperties().get(HOSTNAME_PROP));
        getLogger().log(lr, AccessController.doPrivileged(adminTokenAction));
    } catch (Exception ex) {
        sessionDebug.error("SessionService.logIt(): Cannot write to the session log file: ", ex);
    }
}
Also used : StringTokenizer(java.util.StringTokenizer) LogRecord(com.sun.identity.log.LogRecord)

Example 15 with LogRecord

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

the class SessionLogging method logSystemMessage.

public void logSystemMessage(String msgID, Level level) {
    if (!serviceConfig.isLoggingEnabled()) {
        return;
    }
    try {
        String[] data = { msgID };
        LogRecord lr = getLogMessageProvider().createLogRecord(msgID, data, null);
        SSOToken serviceToken = AccessController.doPrivileged(adminTokenAction);
        lr.addLogInfo(LogConstants.LOGIN_ID_SID, serviceToken.getTokenID().toString());
        lr.addLogInfo(LogConstants.LOGIN_ID, serviceToken.getPrincipal().getName());
        getErrorLogger().log(lr, serviceToken);
    } catch (Exception ex) {
        sessionDebug.error("SessionService.logSystemMessage(): Cannot write to the session error log file: ", ex);
    }
}
Also used : SSOToken(com.iplanet.sso.SSOToken) LogRecord(com.sun.identity.log.LogRecord)

Aggregations

LogRecord (com.sun.identity.log.LogRecord)21 SSOToken (com.iplanet.sso.SSOToken)14 IOException (java.io.IOException)9 LogMessageProvider (com.sun.identity.log.messageid.LogMessageProvider)5 Logger (com.sun.identity.log.Logger)4 SSOException (com.iplanet.sso.SSOException)3 AMLogException (com.sun.identity.log.AMLogException)3 Level (java.util.logging.Level)2 Response (com.iplanet.services.comm.share.Response)1 SSOTokenManager (com.iplanet.sso.SSOTokenManager)1 AuthContext (com.sun.identity.authentication.AuthContext)1 AuthLoginException (com.sun.identity.authentication.spi.AuthLoginException)1 ELogRecord (com.sun.identity.entitlement.log.ELogRecord)1 IdRepoException (com.sun.identity.idm.IdRepoException)1 AccessDenied (com.sun.identity.idsvcs.AccessDenied)1 GeneralFailure (com.sun.identity.idsvcs.GeneralFailure)1 LogResponse (com.sun.identity.idsvcs.LogResponse)1 SsoServerLoggingHdlrEntryImpl (com.sun.identity.monitoring.SsoServerLoggingHdlrEntryImpl)1 SsoServerLoggingSvcImpl (com.sun.identity.monitoring.SsoServerLoggingSvcImpl)1 LogException (com.sun.identity.plugin.log.LogException)1