01: package com.sun.portal.admin.server;
02:
03: import com.sun.cacao.agent.auth.UserPrincipal;
04:
05: import javax.security.auth.Subject;
06: import java.util.Hashtable;
07: import java.security.AccessController;
08:
09: /**
10: * This class is responsible for audit log message construction.
11: */
12: public class AuditLogMessage {
13: /**
14: * Gets the audit messages after adding UserDn to it. The message returned is
15: * string representation of Hashtable - key=value pairs.
16: * @param nameValues Hashtable of context sensitive audit log attribute values
17: * @return Message in name=value pairs
18: */
19: public static String getMessage(Hashtable nameValues) {
20: nameValues.put("UserDN", getUserDN());
21: return nameValues.toString();
22: }
23:
24: /**
25: * Gets the UserDN in the present access context.
26: * @return UserDN
27: */
28: public static String getUserDN() {
29: String dn = null;
30: try {
31: dn = ((UserPrincipal) Subject.getSubject(
32: AccessController.getContext()).getPrincipals(
33: PASPrincipal.class).iterator().next()).getName();
34: } catch (Exception e) {
35: //could not get user dn
36: }
37: return dn;
38: }
39: }
|