ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/catalina/users/GenericGroup.java

Path
ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/java/org/apache/catalina/users/GenericGroup.java
Status
scanned
Type
file
Name
GenericGroup.java
Extension
.java
Programming language
Java
Mime type
text/plain
File type
ASCII text, with CRLF line terminators
Tag

      
    
Rootfs path

      
    
Size
4406 (4.3 KB)
MD5
09808b3169f95f4712ee64e563aa7a23
SHA1
0a37ee4ce73f7e54b2568c9e518d1640eb0661d7
SHA256
568b43926532403142e7137a7319bddd47642c3e6506e910ca40f33082d21a4f
SHA512

      
    
SHA1_git
1ba8d0f192c4cf7408b06bf02ab5c399de9afe7d
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
GenericGroup.java | 4.3 KB |

/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.catalina.users; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; import org.apache.catalina.Role; import org.apache.catalina.User; import org.apache.catalina.UserDatabase; /** * <p> * Concrete implementation of {@link org.apache.catalina.Group} for a {@link UserDatabase}. * </p> * * @param <UD> The specific type of UserDase with which this group is associated */ public class GenericGroup<UD extends UserDatabase> extends AbstractGroup { // ----------------------------------------------------------- Constructors /** * Package-private constructor used by the factory method in {@link UserDatabase}. * * @param database The {@link UserDatabase} that owns this group * @param groupname Group name of this group * @param description Description of this group * @param roles The roles of this group */ GenericGroup(UD database, String groupname, String description, List<Role> roles) { super(); this.database = database; this.groupname = groupname; this.description = description; if (roles != null) { this.roles.addAll(roles); } } // ----------------------------------------------------- Instance Variables /** * The {@link UserDatabase} that owns this group. */ protected final UD database; /** * The set of {@link Role}s associated with this group. */ protected final CopyOnWriteArrayList<Role> roles = new CopyOnWriteArrayList<>(); // ------------------------------------------------------------- Properties @Override public Iterator<Role> getRoles() { return roles.iterator(); } @Override public UserDatabase getUserDatabase() { return this.database; } @Override public Iterator<User> getUsers() { List<User> results = new ArrayList<>(); Iterator<User> users = database.getUsers(); while (users.hasNext()) { User user = users.next(); if (user.isInGroup(this)) { results.add(user); } } return results.iterator(); } // --------------------------------------------------------- Public Methods @Override public void addRole(Role role) { if (roles.addIfAbsent(role)) { database.modifiedGroup(this); } } @Override public boolean isInRole(Role role) { return roles.contains(role); } @Override public void removeRole(Role role) { if (roles.remove(role)) { database.modifiedGroup(this); } } @Override public void removeRoles() { if (!roles.isEmpty()) { roles.clear(); database.modifiedGroup(this); } } @Override public boolean equals(Object obj) { if (obj instanceof GenericGroup<?> group) { return group.database == database && groupname.equals(group.getGroupname()); } return super.equals(obj); } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((database == null) ? 0 : database.hashCode()); result = prime * result + ((groupname == null) ? 0 : groupname.hashCode()); return result; } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
27.36
Copyrights

      
    
Holders

      
    
Authors

      
    
License detections License expression License expression SPDX
apache_2_0-4bde3f57-78aa-4201-96bf-531cba09e7de apache-2.0 Apache-2.0
URL Start line End line
http://www.apache.org/licenses/LICENSE-2.0 9 9