use of com.yahoo.athenz.zms.RsrcCtxWrapper in project athenz by yahoo.
the class ZMSUtils method getAuditLogMsgBuilder.
/**
* Setup a new AuditLogMsgBuilder object with common values.
*/
public static AuditLogMsgBuilder getAuditLogMsgBuilder(ResourceContext ctx, AuditLogger auditLogger, String domainName, String auditRef, String caller, String method) {
AuditLogMsgBuilder msgBldr = auditLogger.getMsgBuilder();
// get the where - which means where this server is running
msgBldr.where(ZMSImpl.serverHostName);
msgBldr.whatDomain(domainName).why(auditRef).whatApi(caller).whatMethod(method);
if (ctx != null) {
Principal princ = ((RsrcCtxWrapper) ctx).principal();
if (princ != null) {
String unsignedCreds = princ.getUnsignedCredentials();
if (unsignedCreds == null) {
StringBuilder sb = new StringBuilder();
sb.append("who-name=").append(princ.getName());
sb.append(",who-domain=").append(princ.getDomain());
sb.append(",who-fullname=").append(princ.getFullName());
List<String> roles = princ.getRoles();
if (roles != null && roles.size() > 0) {
sb.append(",who-roles=").append(roles.toString());
}
unsignedCreds = sb.toString();
}
msgBldr.who(unsignedCreds);
}
// get the client IP
msgBldr.clientIp(ServletRequestUtil.getRemoteAddress(ctx.request()));
}
return msgBldr;
}
Aggregations