package org.mxchange.jjobs.beans;
import java.io.Serializable;
+import java.security.Principal;
import java.text.MessageFormat;
import java.util.Locale;
import java.util.MissingResourceException;
*/
private static final long serialVersionUID = 50_837_597_127_567_140L;
+ /**
+ * Determines principal's name or returns null if no principal (security) is
+ * set.
+ * <p>
+ * @return Principal's name or null
+ */
+ protected String determinePrincipalName () {
+ // Get principal
+ Principal userPrincipal = FacesContext.getCurrentInstance().getExternalContext().getUserPrincipal();
+
+ // Init with null
+ String principalName = null;
+
+ // Is the principal set?
+ if (userPrincipal instanceof Principal) {
+ // Get principal's name
+ principalName = userPrincipal.getName();
+ }
+
+ // Return it
+ return principalName;
+ }
+
/**
* Returns given property key or throws an exception if not found.
* <p>
}
// Create new activity object
- LogableUserActivity userActivity = new UserActivityLog(activityType, user, new GregorianCalendar());
+ LogableUserActivity userActivity = new UserActivityLog(activityType, user, new GregorianCalendar(), this.determinePrincipalName());
// Call bean to add it
this.userActivityBean.addUserActivityLog(userActivity);
}
// Create new activity object
- LogableUserActivity userActivity = new UserActivityLog(message, activityType, user, new GregorianCalendar());
+ LogableUserActivity userActivity = new UserActivityLog(message, activityType, user, new GregorianCalendar(), this.determinePrincipalName());
// Call bean to add it
this.userActivityBean.addUserActivityLog(userActivity);
if (null == event) {
// Throw NPE
throw new NullPointerException("event is null"); //NOI18N
- } else if (event.getLoggedOutUser()== null) {
+ } else if (event.getLoggedOutUser() == null) {
// Throw NPE again
throw new NullPointerException("event.loggedOutUser is null"); //NOI18N
} else if (event.getLoggedOutUser().getUserId() == null) {
ADMIN_ACTIVITY_USER_LOGGED_OUT=Benutzer hat sich ausgeloggt.
USER_ACTIVITY_USER_LOGGED_OUT=Sie haben sich ausgeloggt.
ERROR_GUEST_USER_NAME_REQUIRED_DISABLED=Fehler: Die Anwendung verwendet keine Benutzernamen, dennoch wurde dieses Template geladen.
+ADMIN_SHOW_PRINCIPAL_NAME=Admin-Login:
ADMIN_ACTIVITY_USER_LOGGED_OUT=User has logged out.
USER_ACTIVITY_USER_LOGGED_OUT=You have logged out.
ERROR_GUEST_USER_NAME_REQUIRED_DISABLED=Error: This application requires no user name, still this template has been loaded.
+ADMIN_SHOW_PRINCIPAL_NAME=Admin-Login:
</h:column>
</ui:fragment>
+ <h:column>
+ <f:facet name="header">
+ <h:outputText value="#{msg.ADMIN_SHOW_PRINCIPAL_NAME}" />
+ </f:facet>
+
+ <h:outputText value="#{userActivity.activityPrincipalName}" />
+ </h:column>
+
<h:column>
<f:facet name="header">
<h:outputText value="#{msg.ADMIN_LIST_USER_GENDER}" />