View Javadoc

1   /****************************************************************
2    * Licensed to the Apache Software Foundation (ASF) under one   *
3    * or more contributor license agreements.  See the NOTICE file *
4    * distributed with this work for additional information        *
5    * regarding copyright ownership.  The ASF licenses this file   *
6    * to you under the Apache License, Version 2.0 (the            *
7    * "License"); you may not use this file except in compliance   *
8    * with the License.  You may obtain a copy of the License at   *
9    *                                                              *
10   *   http://www.apache.org/licenses/LICENSE-2.0                 *
11   *                                                              *
12   * Unless required by applicable law or agreed to in writing,   *
13   * software distributed under the License is distributed on an  *
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
15   * KIND, either express or implied.  See the License for the    *
16   * specific language governing permissions and limitations      *
17   * under the License.                                           *
18   ****************************************************************/
19  
20  package org.apache.james.api.user;
21  
22  import java.io.Serializable;
23  
24  /**
25   * <p>Contains flexible meta-data related to users.
26   * Values should be serializable to allow easy remote transport
27   * and persistence. Keys are strings.
28   * </p><p>
29   * <strong>Note</strong> conventionally keys should be URIs
30   * and so naturally namespaced. In particular, all keys starting with
31   * <code>http://james.apache.org/</code> are reserved for 
32   * use by JAMES.
33   * </p>
34   */
35  public interface UserMetaDataRespository {
36      
37      public static final String ROLE = "org.apache.james.api.user.UserMetaDataRespository";
38      
39      /**
40       * Gets the attribute for the given key.
41       * @param username the name of the user, not null
42       * @param key conventionally an URI, not null
43       * @return value, or null if the keyed attribute has 
44       * no associated value.
45       */
46      public Serializable getAttribute(String username, String key) throws UserRepositoryException;
47      
48      /**
49       * Sets the attribute keyed to the given value.
50       * @param username the name of the user which meta-data is to be set, not null
51       * @param value <code>Serializable</code> value, possibly null
52       * @param key conventionally an URI, not null
53       */
54      public void setAttribute(String username, Serializable value, String key) throws UserRepositoryException;
55      
56      /**
57       * Clears all attributes for the given user.
58       * @param username the name of the user who meta data is to be cleared, not null
59       * @throws UserRepositoryException
60       */
61      public void clear(String username) throws UserRepositoryException;
62  }