Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*
  * Copyright (c) SiteWhere, LLC. All rights reserved. http://www.sitewhere.com
  *
  * The software in this package is published under the terms of the CPAL v1.0
  * license, a copy of which has been included with this distribution in the
  * LICENSE.txt file.
  */
 package com.sitewhere.security;
 
Provides helper methods for dealing with currently logged in user.

Author(s):
Derek
public class LoginManager {

Get the currently logged in user from Spring Security.

	public static IUser getCurrentlyLoggedInUser() throws SiteWhereException {
		Authentication auth = SecurityContextHolder.getContext().getAuthentication();
		if (auth == null) {
		}
		if (!(auth instanceof SitewhereAuthentication)) {
			throw new SiteWhereException("Authentication was not of expected type: "
SitewhereAuthentication.class.getName() + " found " + auth.getClass().getName()
" instead.");
		}
	}
New to GrepCode? Check out our FAQ X