1 // ========================================================================
2 // Copyright (c) 2008-2009 Mort Bay Consulting Pty. Ltd.
3 // ------------------------------------------------------------------------
4 // All rights reserved. This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v1.0
6 // and Apache License v2.0 which accompanies this distribution.
7 // The Eclipse Public License is available at
8 // http://www.eclipse.org/legal/epl-v10.html
9 // The Apache License v2.0 is available at
10 // http://www.opensource.org/licenses/apache2.0.php
11 // You may elect to redistribute this code under either of these licenses.
12 // ========================================================================
13
14 package org.eclipse.jetty.security;
15
16 import java.security.Principal;
17
18 import javax.security.auth.Subject;
19
20 import org.eclipse.jetty.http.security.Credential;
21 import org.eclipse.jetty.security.MappedLoginService.KnownUser;
22 import org.eclipse.jetty.security.MappedLoginService.RolePrincipal;
23 import org.eclipse.jetty.server.UserIdentity;
24
25
26 /* ------------------------------------------------------------ */
27 /**
28 * Default Identity Service implementation.
29 * This service handles only role reference maps passed in an
30 * associated {@link org.eclipse.jetty.server.UserIdentity.Scope}. If there are roles
31 * refs present, then associate will wrap the UserIdentity with one
32 * that uses the role references in the
33 * {@link org.eclipse.jetty.server.UserIdentity#isUserInRole(String, org.eclipse.jetty.server.UserIdentity.Scope)}
34 * implementation. All other operations are effectively noops.
35 *
36 */
37 public class DefaultIdentityService implements IdentityService
38 {
39 /* ------------------------------------------------------------ */
40 public DefaultIdentityService()
41 {
42 }
43
44 /* ------------------------------------------------------------ */
45 /**
46 * If there are roles refs present in the scope, then wrap the UserIdentity
47 * with one that uses the role references in the {@link UserIdentity#isUserInRole(String, org.eclipse.jetty.server.UserIdentity.Scope)}
48 */
49 public Object associate(UserIdentity user)
50 {
51 return null;
52 }
53
54 /* ------------------------------------------------------------ */
55 public void disassociate(Object previous)
56 {
57 }
58
59 /* ------------------------------------------------------------ */
60 public Object setRunAs(UserIdentity user, RunAsToken token)
61 {
62 return token;
63 }
64
65 /* ------------------------------------------------------------ */
66 public void unsetRunAs(Object lastToken)
67 {
68 }
69
70 /* ------------------------------------------------------------ */
71 public RunAsToken newRunAsToken(String runAsName)
72 {
73 return new RoleRunAsToken(runAsName);
74 }
75
76 /* ------------------------------------------------------------ */
77 public UserIdentity getSystemUserIdentity()
78 {
79 return null;
80 }
81
82 /* ------------------------------------------------------------ */
83 public UserIdentity newUserIdentity(final Subject subject, final Principal userPrincipal, final String[] roles)
84 {
85 return new DefaultUserIdentity(subject,userPrincipal,roles);
86 }
87
88 }