rename to TestUserIdentity

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
Lachlan Roberts 2023-08-23 11:06:14 +10:00
parent f0953e4d29
commit d319431281
1 changed files with 0 additions and 72 deletions

View File

@ -1,72 +0,0 @@
//
// ========================================================================
// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
//
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
// ========================================================================
//
package org.eclipse.jetty.ee10.servlet.security;
import java.security.Principal;
import javax.security.auth.Subject;
import org.eclipse.jetty.security.DefaultIdentityService;
import org.eclipse.jetty.security.UserIdentity;
/**
* The default implementation of UserIdentity.
*/
public class DefaultUserIdentity implements UserIdentity
{
private final Subject _subject;
private final Principal _userPrincipal;
private final String[] _roles;
public DefaultUserIdentity(Subject subject, Principal userPrincipal, String[] roles)
{
_subject = subject;
_userPrincipal = userPrincipal;
_roles = roles;
}
@Override
public Subject getSubject()
{
return _subject;
}
@Override
public Principal getUserPrincipal()
{
return _userPrincipal;
}
@Override
public boolean isUserInRole(String role)
{
if (role == null)
return false;
if (DefaultIdentityService.isRoleAssociated(role))
return true;
for (String r : _roles)
{
if (r.equals(role))
return true;
}
return false;
}
@Override
public String toString()
{
return DefaultUserIdentity.class.getSimpleName() + "('" + _userPrincipal + "')";
}
}