001 /** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018 019 package org.apache.geronimo.javamail.store.imap; 020 021 /** 022 * A named access control list for IMAP resources. 023 */ 024 public class ACL implements Cloneable { 025 /** 026 * The name of the resource this ACL applies to. 027 */ 028 private String name; 029 /** 030 * The rights associated with this resource. 031 */ 032 private Rights rights; 033 034 /** 035 * Create an ACL for a resource. The ACL will have an empty Rights set. 036 * 037 * @param name The name of the resource. 038 */ 039 public ACL(String name) { 040 this.name = name; 041 this.rights = new Rights(); 042 } 043 044 /** 045 * Create a named ACL instance with an initial Rights set. 046 * 047 * @param name The name of the resouce this ACL applies to. 048 * @param rights The Rights associated with this resource. 049 */ 050 public ACL(String name, Rights rights) { 051 this.name = name; 052 this.rights = rights; 053 } 054 055 /** 056 * Get the ACL name. 057 * 058 * @return The string name of the ACL. 059 */ 060 public String getName() { 061 return name; 062 } 063 064 /** 065 * Get the Rights associated with this ACL. 066 * 067 * @return The Rights set supported for this resource. 068 */ 069 public Rights getRights() { 070 return rights; 071 } 072 073 /** 074 * Set a new set of Rights for this ACL instance. 075 * 076 * @param rights The new Rights set. 077 */ 078 public void setRights(Rights rights) { 079 this.rights = rights; 080 } 081 082 083 /** 084 * Creates and returns a copy of this object. 085 * 086 * @return A cloned copy of this object. This is a deep 087 * copy, given that a new Rights set is also created. 088 * @exception CloneNotSupportedException 089 */ 090 protected Object clone() throws CloneNotSupportedException { 091 return new ACL(name, new Rights(rights)); 092 } 093 }