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