1
2
3
4
5
6
7
8
9
10
11
12
13
14 package org.eclipse.jetty.security;
15
16 import java.io.Serializable;
17
18 import org.eclipse.jetty.security.authentication.LoginAuthenticator;
19 import org.eclipse.jetty.server.Authentication;
20 import org.eclipse.jetty.server.UserIdentity;
21 import org.eclipse.jetty.server.UserIdentity.Scope;
22
23
24
25
26
27 public class UserAuthentication implements Authentication.User
28 {
29 private final String _method;
30 private final UserIdentity _userIdentity;
31
32 public UserAuthentication(String method, UserIdentity userIdentity)
33 {
34 _method = method;
35 _userIdentity = userIdentity;
36 }
37
38 public String getAuthMethod()
39 {
40 return _method;
41 }
42
43 public UserIdentity getUserIdentity()
44 {
45 return _userIdentity;
46 }
47
48 public boolean isUserInRole(Scope scope, String role)
49 {
50 return _userIdentity.isUserInRole(role, scope);
51 }
52
53 @Override
54 public String toString()
55 {
56 return "{User,"+getAuthMethod()+","+_userIdentity+"}";
57 }
58
59 public void logout()
60 {
61 SecurityHandler security=SecurityHandler.getCurrentSecurityHandler();
62 if (security!=null)
63 security.logout(this);
64 }
65 }