public static function setUser($username , $password = null , $roles = null , $logs = null , $regeneratetokens = false )
	{
		if ( ! is_array( self::$auth ) ) throw new Exception( 'Authentication not initialized' );

		if ( isset( self::$auth['users'][ $username ] ) ) {
			$user = self::$auth['users'][ $username ];
		} else {
			$user = array(
				'roles' => array('user'),
				'pwd'   => '',
				'logs'  => array(),
				'cd'    => date('U'),
				'cb'    => self::getCurrentUsername(),
				'at'    => self::generateSecurityToken(32), // Access token
				'hp'    => self::generateSecurityToken(16), // Presalt for this user, postsalt is the instance security token
			);
		}
		if ( $regeneratetokens === true ) {
			$user['at'] = self::generateSecurityToken(32);
			$user['hp'] = self::generateSecurityToken(16);
		}
		if ( ! is_null( $password ) ) $user['pwd']   = self::getPasswordHash( $username , $password );
		if ( is_array( $logs ) )      $user['logs']  = $logs;
		if ( is_array( $roles ) )     $user['roles'] = $roles;

		self::$auth['users'][ $username ] = $user;

		return true;
	}