<commit_before>package fr.openwide.core.wicket.more.security.authorization;

import org.apache.wicket.Component;
import org.apache.wicket.authorization.IUnauthorizedComponentInstantiationListener;
import org.apache.wicket.authorization.UnauthorizedInstantiationException;
import org.apache.wicket.authroles.authentication.AuthenticatedWebSession;

import fr.openwide.core.wicket.more.AbstractCoreSession;
import fr.openwide.core.wicket.more.application.CoreWicketAuthenticatedApplication;
import fr.openwide.core.wicket.more.request.cycle.RequestCycleUtils;

/**
 * Dans le cas d'un accès non identifié non autorisé, on envoie sur la
 * page d'accueil avec affichage d'un message invitant l'utilisateur
 * à s'identifier.
 */
public class StandardUnauthorizedComponentInstantiationListener implements IUnauthorizedComponentInstantiationListener {

	@Override
	public void onUnauthorizedInstantiation(Component component) {
		if (!AuthenticatedWebSession.exists() || !AuthenticatedWebSession.get().isSignedIn()) {
			AuthenticatedWebSession.get().error(component.getString("access.denied"));
			String currentUrl = RequestCycleUtils.getCurrentRequestUrl();
			if (currentUrl != null) {
				AbstractCoreSession.get().registerRedirectUrl(currentUrl);
			}
			throw CoreWicketAuthenticatedApplication.get().getSignInPageLinkDescriptor()
					.newRestartResponseAtInterceptPageException();
		} else {
			throw new UnauthorizedInstantiationException(component.getClass());
		}
	}
	
	protected void onUnauthorizedComponentInstantiation(Component component) {
		throw new UnauthorizedInstantiationException(component.getClass());
	}

}
<commit_msg>nettoyage des messages de feedback quand on va envoyer un access denied<commit_after>package fr.openwide.core.wicket.more.security.authorization;

import org.apache.wicket.Component;
import org.apache.wicket.authorization.IUnauthorizedComponentInstantiationListener;
import org.apache.wicket.authorization.UnauthorizedInstantiationException;
import org.apache.wicket.authroles.authentication.AuthenticatedWebSession;

import fr.openwide.core.wicket.more.AbstractCoreSession;
import fr.openwide.core.wicket.more.application.CoreWicketAuthenticatedApplication;
import fr.openwide.core.wicket.more.request.cycle.RequestCycleUtils;

/**
 * Dans le cas d'un accès non identifié non autorisé, on envoie sur la
 * page d'accueil avec affichage d'un message invitant l'utilisateur
 * à s'identifier.
 */
public class StandardUnauthorizedComponentInstantiationListener implements IUnauthorizedComponentInstantiationListener {

	@Override
	public void onUnauthorizedInstantiation(Component component) {
		if (!AuthenticatedWebSession.exists() || !AuthenticatedWebSession.get().isSignedIn()) {
			AuthenticatedWebSession.get().getFeedbackMessages().clear();
			AuthenticatedWebSession.get().error(component.getString("access.denied"));
			String currentUrl = RequestCycleUtils.getCurrentRequestUrl();
			if (currentUrl != null && !currentUrl.contains("")) {
				AbstractCoreSession.get().registerRedirectUrl(currentUrl);
			}
			throw CoreWicketAuthenticatedApplication.get().getSignInPageLinkDescriptor()
					.newRestartResponseAtInterceptPageException();
		} else {
			throw new UnauthorizedInstantiationException(component.getClass());
		}
	}
	
	protected void onUnauthorizedComponentInstantiation(Component component) {
		throw new UnauthorizedInstantiationException(component.getClass());
	}

}

{'fraction_non_alphanumeric': 0.09212827988338193, 'fraction_numerical': 0.0, 'mean_word_length': 7.016355140186916, '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': '6278929', 'n_tokens_mistral': 1005, 'n_tokens_neox': 956, 'n_words': 161}