// Path: src/main/java/org/andidev/applicationname/config/logging/MDC.java
// public class MDC {
// 
//     public static void putSession(String session) {
//         org.slf4j.MDC.put("session", left(session, 9));
//     }
// 
//     public static void removeSession() {
//         org.slf4j.MDC.remove("session");
//     }
// 
//     public static void putUsername(String username) {
//         org.slf4j.MDC.put("username", username);
//     }
// 
//     public static void removeUsername() {
//         org.slf4j.MDC.remove("username");
//     }
// }
// 
// Path: src/main/java/org/andidev/applicationname/entity/User.java
// @Entity
// @NoArgsConstructor(access = PROTECTED)
// @RequiredArgsConstructor
// @Setter
// @Getter
// public class User extends IdEntity implements UserDetails, Serializable {
// 
//     @Column(unique = true)
//     @NonNull
//     private String username;
//     @NonNull
//     private String password;
//     private String firstName;
//     private String lastName;
//     private String email;
//     private boolean accountNonExpired;
//     private boolean accountNonLocked;
//     private boolean credentialsNonExpired;
//     private boolean enabled;
//     private Period automaticLogoutTime;
//     private Locale locale;
//     private DateTimeZone timeZone;
//     private String dateFormat = "yyyy/MM/dd";
//     private String timeFormat = "HH.mm";
//     @ElementCollection(targetClass = Role.class, fetch = EAGER)
//     @Enumerated(STRING)
//     private Set<Role> userRoles = EnumSet.noneOf(Role.class);
//     @ManyToMany(mappedBy = "users", fetch = EAGER)
//     private Set<Group> groups = new HashSet();
//     @OneToMany(fetch = EAGER)
//     private Set<PreferenceValue> preferenceValues = new HashSet();
// 
//     public Set<Role> getRoles() {
//         Set<Role> roles = EnumSet.noneOf(Role.class);
//         roles.addAll(getUserRoles());
//         roles.addAll(getGroupRoles());
//         return roles;
//     }
// 
//     private Set<Role> getGroupRoles() {
//         Set<Role> roles = EnumSet.noneOf(Role.class);
//         for (Group group : getGroups()) {
//             roles.addAll(group.getGroupRoles());
//         }
//         return roles;
//     }
// 
//     @Override
//     public Collection<? extends GrantedAuthority> getAuthorities() {
//         Set<GrantedAuthority> grantedAuthorities = new LinkedHashSet<>();
//         for (Role role : getRoles()) {
//             grantedAuthorities.add(new SimpleGrantedAuthority(role.name()));
//         }
//         return grantedAuthorities;
//     }
// }
// 
// Path: src/main/java/org/andidev/applicationname/util/ApplicationUtils.java
// public static HttpSession getSession() {
//     return getRequest().getSession();
// }
// 
// Path: src/main/java/org/andidev/applicationname/util/ApplicationUtils.java
// public static User getUser() {
//     // Check authentication exists
//     Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
//     if (authentication == null) {
//         return null;
//     }
// 
//     // Get user
//     Object principal = authentication.getPrincipal();
//     if (principal instanceof User) {
//         return (User) principal;
//     }
// 
//     throw new RuntimeException("Unable to get user. Unknown user type found in SecurityContextHolder's principal = " + ReflectionToStringBuilder.toString(principal));
// }
// 
// Path: src/main/java/org/andidev/applicationname/util/ApplicationUtils.java
// public static String getUsername() {
//     User user = getUser();
//     if (user == null) {
//         return null;
//     }
// 
//     return user.getUsername();
// }
// 
// Path: src/main/java/org/andidev/applicationname/util/StringUtils.java
// public static String quote(String text) {
//     return "\"" + text + "\"";
// }
// 
// Path: src/main/java/org/andidev/applicationname/util/TimeUtils.java
// public static String format(Period milliSeconds) {
//     return PeriodFormat.getDefault().print(milliSeconds);
// }


import javax.inject.Inject;
import lombok.extern.slf4j.Slf4j;
import org.andidev.applicationname.config.logging.MDC;
import org.andidev.applicationname.entity.User;
import static org.andidev.applicationname.util.ApplicationUtils.getSession;
import static org.andidev.applicationname.util.ApplicationUtils.getUser;
import static org.andidev.applicationname.util.ApplicationUtils.getUsername;
import static org.andidev.applicationname.util.StringUtils.quote;
import static org.andidev.applicationname.util.TimeUtils.format;
import org.joda.time.Period;
import org.springframework.context.ApplicationListener;
import org.springframework.security.authentication.event.InteractiveAuthenticationSuccessEvent;
import org.springframework.security.web.authentication.switchuser.AuthenticationSwitchUserEvent;
import org.springframework.stereotype.Component;
package org.andidev.applicationname.config.springsecurity;


@Slf4j
@Component
// Path: src/main/java/org/andidev/applicationname/config/logging/MDC.java
// public class MDC {
// 
//     public static void putSession(String session) {
//         org.slf4j.MDC.put("session", left(session, 9));
//     }
// 
//     public static void removeSession() {
//         org.slf4j.MDC.remove("session");
//     }
// 
//     public static void putUsername(String username) {
//         org.slf4j.MDC.put("username", username);
//     }
// 
//     public static void removeUsername() {
//         org.slf4j.MDC.remove("username");
//     }
// }
// 
// Path: src/main/java/org/andidev/applicationname/entity/User.java
// @Entity
// @NoArgsConstructor(access = PROTECTED)
// @RequiredArgsConstructor
// @Setter
// @Getter
// public class User extends IdEntity implements UserDetails, Serializable {
// 
//     @Column(unique = true)
//     @NonNull
//     private String username;
//     @NonNull
//     private String password;
//     private String firstName;
//     private String lastName;
//     private String email;
//     private boolean accountNonExpired;
//     private boolean accountNonLocked;
//     private boolean credentialsNonExpired;
//     private boolean enabled;
//     private Period automaticLogoutTime;
//     private Locale locale;
//     private DateTimeZone timeZone;
//     private String dateFormat = "yyyy/MM/dd";
//     private String timeFormat = "HH.mm";
//     @ElementCollection(targetClass = Role.class, fetch = EAGER)
//     @Enumerated(STRING)
//     private Set<Role> userRoles = EnumSet.noneOf(Role.class);
//     @ManyToMany(mappedBy = "users", fetch = EAGER)
//     private Set<Group> groups = new HashSet();
//     @OneToMany(fetch = EAGER)
//     private Set<PreferenceValue> preferenceValues = new HashSet();
// 
//     public Set<Role> getRoles() {
//         Set<Role> roles = EnumSet.noneOf(Role.class);
//         roles.addAll(getUserRoles());
//         roles.addAll(getGroupRoles());
//         return roles;
//     }
// 
//     private Set<Role> getGroupRoles() {
//         Set<Role> roles = EnumSet.noneOf(Role.class);
//         for (Group group : getGroups()) {
//             roles.addAll(group.getGroupRoles());
//         }
//         return roles;
//     }
// 
//     @Override
//     public Collection<? extends GrantedAuthority> getAuthorities() {
//         Set<GrantedAuthority> grantedAuthorities = new LinkedHashSet<>();
//         for (Role role : getRoles()) {
//             grantedAuthorities.add(new SimpleGrantedAuthority(role.name()));
//         }
//         return grantedAuthorities;
//     }
// }
// 
// Path: src/main/java/org/andidev/applicationname/util/ApplicationUtils.java
// public static HttpSession getSession() {
//     return getRequest().getSession();
// }
// 
// Path: src/main/java/org/andidev/applicationname/util/ApplicationUtils.java
// public static User getUser() {
//     // Check authentication exists
//     Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
//     if (authentication == null) {
//         return null;
//     }
// 
//     // Get user
//     Object principal = authentication.getPrincipal();
//     if (principal instanceof User) {
//         return (User) principal;
//     }
// 
//     throw new RuntimeException("Unable to get user. Unknown user type found in SecurityContextHolder's principal = " + ReflectionToStringBuilder.toString(principal));
// }
// 
// Path: src/main/java/org/andidev/applicationname/util/ApplicationUtils.java
// public static String getUsername() {
//     User user = getUser();
//     if (user == null) {
//         return null;
//     }
// 
//     return user.getUsername();
// }
// 
// Path: src/main/java/org/andidev/applicationname/util/StringUtils.java
// public static String quote(String text) {
//     return "\"" + text + "\"";
// }
// 
// Path: src/main/java/org/andidev/applicationname/util/TimeUtils.java
// public static String format(Period milliSeconds) {
//     return PeriodFormat.getDefault().print(milliSeconds);
// }


// Path: src/main/java/org/andidev/applicationname/config/springsecurity/LoginListener.java
import javax.inject.Inject;
import lombok.extern.slf4j.Slf4j;
import org.andidev.applicationname.config.logging.MDC;
import org.andidev.applicationname.entity.User;
import static org.andidev.applicationname.util.ApplicationUtils.getSession;
import static org.andidev.applicationname.util.ApplicationUtils.getUser;
import static org.andidev.applicationname.util.ApplicationUtils.getUsername;
import static org.andidev.applicationname.util.StringUtils.quote;
import static org.andidev.applicationname.util.TimeUtils.format;
import org.joda.time.Period;
import org.springframework.context.ApplicationListener;
import org.springframework.security.authentication.event.InteractiveAuthenticationSuccessEvent;
import org.springframework.security.web.authentication.switchuser.AuthenticationSwitchUserEvent;
import org.springframework.stereotype.Component;

package org.andidev.applicationname.config.springsecurity;


@Slf4j
@Component
public class LoginListener {