Commit 8ddfa975 by Tuukka Kivilahti

TODO: insert there some nice description to this commit.

1 parent 1b4f025e
...@@ -44,4 +44,41 @@ public class SecurityBean implements SecurityBeanLocal { ...@@ -44,4 +44,41 @@ public class SecurityBean implements SecurityBeanLocal {
logger.debug(entry.toString(), exception); logger.debug(entry.toString(), exception);
entryFacade.create(entry); entryFacade.create(entry);
} }
public void logException(User user, Exception exception) {
LogEntryType type = typeFacade.findOrCreate(SecurityLogType.unknownException);
LogEntry entry = new LogEntry();
entry.setType(type);
entry.setTime(Calendar.getInstance());
entry.setDescription(exception.getMessage());
entry.setUser(user);
logger.debug(entry.toString(), exception);
entryFacade.create(entry);
}
public void logMessage(User user, String description) {
logMessage(SecurityLogType.genericMessage, user, description);
}
public void logMessage(SecurityLogType paramType, User user, String description) {
LogEntryType type = typeFacade.findOrCreate(paramType);
LogEntry entry = new LogEntry();
entry.setType(type);
entry.setTime(Calendar.getInstance());
entry.setDescription(description);
entry.setUser(user);
entryFacade.create(entry);
}
public void logMessage(String description) {
logMessage(SecurityLogType.genericMessage, description);
}
public void logMessage(SecurityLogType type, String description) {
logMessage(type, null, description);
}
} }
...@@ -7,6 +7,14 @@ import fi.insomnia.bortal.model.User; ...@@ -7,6 +7,14 @@ import fi.insomnia.bortal.model.User;
@Local @Local
public interface SecurityBeanLocal { public interface SecurityBeanLocal {
void logPermissionDenied(User user, Exception permissionDeniedException); void logPermissionDenied(User user, Exception exception);
void logException(User user, Exception exception);
void logMessage(User user, String description);
void logMessage(SecurityLogType type, User user, String description);
void logMessage(String description);
void logMessage(SecurityLogType type, String description);
} }
package fi.insomnia.bortal.beans; package fi.insomnia.bortal.beans;
public enum SecurityLogType { public enum SecurityLogType {
permissionDenied permissionDenied,
unknownException,
genericMessage
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!