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.server.UserIdentity; 21 22 23 /* ------------------------------------------------------------ */ 24 /** 25 * Default Identity Service implementation. 26 * This service handles only role reference maps passed in an 27 * associated {@link UserIdentity.Scope}. If there are roles 28 * refs present, then associate will wrap the UserIdentity with one 29 * that uses the role references in the {@link UserIdentity#isUserInRole(String, org.eclipse.jetty.server.UserIdentity.Scope)} 30 * implementation. All other operations are effectively noops. 31 * 32 */ 33 public class DefaultIdentityService implements IdentityService 34 { 35 /* ------------------------------------------------------------ */ 36 public DefaultIdentityService() 37 { 38 } 39 40 /* ------------------------------------------------------------ */ 41 /** 42 * If there are roles refs present in the scope, then wrap the UserIdentity 43 * with one that uses the role references in the {@link UserIdentity#isUserInRole(String, org.eclipse.jetty.server.UserIdentity.Scope)} 44 */ 45 public Object associate(UserIdentity user) 46 { 47 return null; 48 } 49 50 /* ------------------------------------------------------------ */ 51 public void disassociate(Object previous) 52 { 53 } 54 55 /* ------------------------------------------------------------ */ 56 public Object setRunAs(UserIdentity user, RunAsToken token) 57 { 58 return token; 59 } 60 61 /* ------------------------------------------------------------ */ 62 public void unsetRunAs(Object lastToken) 63 { 64 } 65 66 /* ------------------------------------------------------------ */ 67 public RunAsToken newRunAsToken(String runAsName) 68 { 69 return new RoleRunAsToken(runAsName); 70 } 71 72 /* ------------------------------------------------------------ */ 73 public UserIdentity getSystemUserIdentity() 74 { 75 return null; 76 } 77 78 /* ------------------------------------------------------------ */ 79 public UserIdentity newUserIdentity(final Subject subject, final Principal userPrincipal, final String[] roles) 80 { 81 return new DefaultUserIdentity(subject,userPrincipal,roles); 82 } 83 84 }