/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: LogSample.java,v 1.5 2008/07/17 05:05:11 bigfatrat Exp $
*
*/
/**
* This sample demonstrates use of the log writing portion of
* the Logging API. It also demonstrates the login process and
* retrieving of the SSOTokens. Two users are necessary for this
* sample:
* 1. the "subject" userid to which the LogRecord refers
* (shown in the "LoginID" field); and
* 2. the "logging" userid (shown in the "LoggedBy" field).
* The "logging" userid, if not "amAdmin", must have explicit
* log writing privileges as provided by being a member of a group
* or role with that privilege.
*
* @see com.sun.identity.log.LogRecord
* @see com.sun.identity.log.Logger
*/
public class LogSample {
public LogSample () {
sampleUtils = new LogSampleUtils();
}
}
private void logWriteProcessing() {
/*
* get:
* 1. subject userid (subject of the LogRecord)
* 2. subject userid's password
* 3. Log filename to log to
* 4. LogRecord's "data"
* 5. LoggedBy userid (who's doing the logging)
* 6. LoggedBy userid's password
* 7. Realm (for both subject userid and LoggedBy userid
* in this sample)
*/
"'s password", DEF_USERPSWD);
// get AuthContexts for subject userid and loggedby userid
try {
} catch (AuthLoginException le) {
"LogSampleUtils: could not get AuthContext for realm " +
}
// do user and loggedby login and get the SSOToken
try {
} catch (SSOException ssoe) {
"logWriteProcessing: could not get SSOToken: " +
ssoe.getMessage());
} catch (AuthLoginException ale) {
"logWriteProcessing: could not authenticate: " +
ale.getMessage());
} catch (Exception e) {
"logWriteProcessing: exception getting SSOToken: " +
e.getMessage());
}
try {
} catch (AMLogException amex) {
amex.getMessage());
"Is user '" + loggedBySID +
"' a member of a Role or Group with log writing privileges?");
}
}
}