All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.imunity.vaadin.auth.sandbox.SandboxAuthnRouterImpl Maven / Gradle / Ivy

There is a newer version: 4.0.4
Show newest version
/*
 * Copyright (c) 2021 Bixbit - Krzysztof Benedyczak. All rights reserved.
 * See LICENCE.txt file for licensing information.
 */
package io.imunity.vaadin.auth.sandbox;

import com.vaadin.flow.server.VaadinService;
import org.apache.logging.log4j.Logger;

import pl.edu.icm.unity.base.utils.Log;
import pl.edu.icm.unity.engine.api.authn.sandbox.SandboxAuthnEvent;
import pl.edu.icm.unity.engine.api.authn.sandbox.SandboxAuthnRouter;
import pl.edu.icm.unity.engine.api.utils.PrototypeComponent;

import java.util.HashSet;
import java.util.Set;

import static java.util.Collections.synchronizedSet;

@PrototypeComponent
class SandboxAuthnRouterImpl implements SandboxAuthnRouter
{
	private static final Logger LOG = Log.getLogger(Log.U_SERVER_WEB, SandboxAuthnRouterImpl.class);
	private final Set authnListenerList;

	SandboxAuthnRouterImpl()
	{
		authnListenerList = synchronizedSet(new HashSet<>());
	}

	@Override
	public void fireEvent(SandboxAuthnEvent event) 
	{
		LOG.debug("Fire event: {}", event);
		synchronized (authnListenerList)
		{
			for (AuthnResultListener listener: authnListenerList)
				listener.onSandboxAuthnResult(event);
		}
	}

	@Override
	public void addListener(AuthnResultListener listener) 
	{
		String sessionId = VaadinService.getCurrentRequest().getWrappedSession().getId();
		LOG.debug("Adding AuthnResultListener: " + sessionId);
		authnListenerList.add(listener);
	}
	
	@Override
	public void removeListener(AuthnResultListener listener)
	{
		authnListenerList.remove(listener);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy