<commit_before>package org.vaadin.example.shiro;

import java.util.logging.Level;
import java.util.logging.Logger;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;

import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.PasswordField;
import com.vaadin.ui.TextField;

public class LoginView extends FormLayout implements View, ClickListener {

	private TextField username = new TextField("Username");
	private PasswordField password = new PasswordField("Password");
	private Button loginBtn = new Button("Login", this);
	private Label invalidPassword = new Label("Invalid username or password");

	public LoginView() {
		username.focus();
		addComponent(username);
		addComponent(password);
		addComponent(loginBtn);
		addComponent(invalidPassword);
		invalidPassword.setVisible(false);
	}

	@Override
	public void enter(ViewChangeEvent event) {
		// TODO Auto-generated method stub

	}

	@Override
	public void buttonClick(ClickEvent event) {
		Subject currentUser = SecurityUtils.getSubject();
		UsernamePasswordToken token = new UsernamePasswordToken(
				username.getValue(), password.getValue());
		try {
			currentUser.login(token);
			getUI().getNavigator().addView("secure", SecureView.class);
			getUI().getNavigator().navigateTo("secure");
		} catch (Exception e) {
			Logger.getAnonymousLogger().log(Level.INFO, e.getMessage());
			username.setValue("");
			password.setValue("");
			invalidPassword.setVisible(true);
		}

	}

}<commit_msg>Reinitialize the session on login<commit_after>package org.vaadin.example.shiro;

import java.util.logging.Level;
import java.util.logging.Logger;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;

import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.server.VaadinService;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.PasswordField;
import com.vaadin.ui.TextField;

public class LoginView extends FormLayout implements View, ClickListener {

	private TextField username = new TextField("Username");
	private PasswordField password = new PasswordField("Password");
	private Button loginBtn = new Button("Login", this);
	private Label invalidPassword = new Label("Invalid username or password");

	public LoginView() {
		username.focus();
		addComponent(username);
		addComponent(password);
		addComponent(loginBtn);
		addComponent(invalidPassword);
		invalidPassword.setVisible(false);
	}

	@Override
	public void enter(ViewChangeEvent event) {
		// TODO Auto-generated method stub

	}

	@Override
	public void buttonClick(ClickEvent event) {
		Subject currentUser = SecurityUtils.getSubject();
		UsernamePasswordToken token = new UsernamePasswordToken(
				username.getValue(), password.getValue());
		try {
			currentUser.login(token);
			getUI().getNavigator().addView("secure", SecureView.class);
			getUI().getNavigator().navigateTo("secure");
			VaadinService
					.reinitializeSession(VaadinService.getCurrentRequest());
		} catch (Exception e) {
			Logger.getAnonymousLogger().log(Level.INFO, e.getMessage());
			username.setValue("");
			password.setValue("");
			invalidPassword.setVisible(true);
		}

	}

}
{'fraction_non_alphanumeric': 0.1175033921302578, 'fraction_numerical': 0.0, 'mean_word_length': 5.629496402877698, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6206448', 'n_tokens_mistral': 1163, 'n_tokens_neox': 1061, 'n_words': 220}