Skip to main content
summaryrefslogtreecommitdiffstats
blob: d24001ac599ba4c193d5456c7f90b0664e6d8398 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*******************************************************************************
 * Copyright (c) 2007, 2008 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.equinox.internal.security.auth.events;

import java.util.Iterator;
import java.util.Vector;
import javax.security.auth.Subject;
import javax.security.auth.login.LoginException;
import org.eclipse.equinox.security.auth.ILoginContextListener;

public class SecurityEventsManager {

	private Vector listeners = new Vector(5);

	synchronized public void addListener(ILoginContextListener listener) {
		listeners.add(listener);
	}

	synchronized public void removeListener(ILoginContextListener listener) {
		listeners.remove(listener);
	}

	public void notifyLoginBegin(Subject subject) {
		for (Iterator i = listeners.iterator(); i.hasNext();) {
			Object listener = i.next();
			if (listener instanceof ILoginContextListener)
				((ILoginContextListener) listener).onLoginStart(subject);
		}
	}

	public void notifyLoginEnd(Subject subject, LoginException loginException) {
		for (Iterator i = listeners.iterator(); i.hasNext();) {
			Object listener = i.next();
			if (listener instanceof ILoginContextListener)
				((ILoginContextListener) listener).onLoginFinish(subject, loginException);
		}
	}

	public void notifyLogoutBegin(Subject subject) {
		for (Iterator i = listeners.iterator(); i.hasNext();) {
			Object listener = i.next();
			if (listener instanceof ILoginContextListener)
				((ILoginContextListener) listener).onLogoutStart(subject);
		}
	}

	public void notifyLogoutEnd(Subject subject, LoginException loginException) {
		for (Iterator i = listeners.iterator(); i.hasNext();) {
			Object listener = i.next();
			if (listener instanceof ILoginContextListener)
				((ILoginContextListener) listener).onLogoutFinish(subject, loginException);
		}
	}
}

Back to the top