// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: MIT-0 package com.example.application.security; import com.vaadin.flow.spring.security.AuthenticationContext; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.stereotype.Component; @Component public class SecurityService { private final AuthenticationContext authenticationContext; public SecurityService(AuthenticationContext authenticationContext) { this.authenticationContext = authenticationContext; } public UserDetails getAuthenticatedUser() { return authenticationContext.getAuthenticatedUser(UserDetails.class).get(); } public void logout() { authenticationContext.logout(); } }