package ${packageName};

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.ModelAttribute;

import edu.uiowa.icts.datatable.DataTable;
import ${daoPackageName}.${daoServiceClassName};

/**
 * Generated by Protogen
 * @since ${date}
 */
public abstract class ${abstractControllerClassName} {

	protected ${daoServiceClassName} ${daoServiceVariableName};

	@Autowired
	public void set${daoServiceClassName}( ${daoServiceClassName} ${daoServiceVariableName} ) {
		this.${daoServiceVariableName} = ${daoServiceVariableName};
	}

	@ModelAttribute( value = "username" )
	public String getUsername() {
		return SecurityContextHolder.getContext().getAuthentication().getName();
	}

	/**
	 * @param e
	 * @param draw
	 * @return {@link DataTable}
	 */
	protected DataTable datatableError( Exception e, String draw ) {
		String stackTrace = e.getMessage() + String.valueOf( '\n' );
		for ( StackTraceElement ste : e.getStackTrace() ) {
			stackTrace += ste.toString() + String.valueOf( '\n' );
		}
		DataTable error = new DataTable();
		error.setDraw( draw );
		error.setRecordsFiltered( 0 );
		error.setRecordsTotal( 0 );
		error.setError( stackTrace );
		return error;
	}

}
@@ -260,16 +260,55 @@
 aTable;%0A
+import edu.uiowa.icts.spring.Security;%0A
 import $
@@ -759,16 +759,55 @@
 ame() %7B%0A
+%09%09if ( Security.isAuthenticated() ) %7B%0A%09
 %09%09return
@@ -873,16 +873,35 @@
 Name();%0A
+%09%09%7D%0A%09%09return null;%0A
 %09%7D%0A%0A%09/**

add is authenticated check for username model attribute