class SpringSecurityContext {

	@Nullable
	public static Token getToken() {
		Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
		if (Objects.nonNull(authentication) && authentication.isAuthenticated() &&
				authentication.getDetails() instanceof OAuth2AuthenticationDetails) {
			OAuth2AuthenticationDetails authDetails = (OAuth2AuthenticationDetails) authentication.getDetails();
			String tokenValue = authDetails.getTokenValue();
			// TODO IAS Support
			return new XsuaaTokenWithGrantedAuthorities(tokenValue, authentication.getAuthorities());
		}
		return null;
	}

	private  SpringSecurityContext();

}