summaryrefslogtreecommitdiffstats
path: root/src/com/gitblit/JettyLoginService.java
blob: 5173d2133366b02d504f44419890ed1cc0a46bee (plain)
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
package com.gitblit;

import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.server.UserIdentity;

import com.gitblit.wicket.User;

public class JettyLoginService extends HashLoginService implements ILoginService {

	public JettyLoginService(String realmFile) {
		super(Constants.NAME, realmFile);
	}

	@Override
	public User authenticate(String username, char[] password) {
		UserIdentity identity = login(username, new String(password));
		if (identity == null || identity.equals(UserIdentity.UNAUTHENTICATED_IDENTITY)) {
			return null;
		}
		User user = new User(username, password);
		user.canAdmin(identity.isUserInRole(Constants.ADMIN_ROLE, null));
		user.canClone(identity.isUserInRole(Constants.PULL_ROLE, null));
		user.canPush(identity.isUserInRole(Constants.PUSH_ROLE, null));
		return user;
	}

	@Override
	public User authenticate(char[] cookie) {
		// TODO cookie login
		return null;
	}
}