View Javadoc

1   /* 
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *     http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.jetspeed.security.spi;
18  
19  import java.security.Principal;
20  import java.util.List;
21  
22  import org.apache.jetspeed.security.SecurityException;
23  import org.apache.jetspeed.security.UserPrincipal;
24  
25  /***
26   * <p>
27   * This interface encapsulates the persistence of a user security.
28   * </p>
29   * <p>
30   * This provides a central placeholder for changing the persistence of user
31   * security information.
32   * </p>
33   * <p>
34   * A security implementation wanting to store user security implementation in
35   * LDAP for instance would need to provide an LDAP implementation of this
36   * interface.
37   * </p>
38   * 
39   * @author <a href="mailto:dlestrat@apache.org">David Le Strat </a>
40   */
41  public interface UserSecurityHandler
42  {
43      /***
44       * <p>
45       * Checks if a UserPrincipal exists 
46       * @param userName
47       * @return true if a UserPrincipal exists
48       */
49      boolean isUserPrincipal(String userName);
50      
51      /***
52       * <p>
53       * Gets the user principal for the given user name.
54       * </p>
55       * 
56       * @param username The user name.
57       * @return The <code>Principal</p>
58       */
59      Principal getUserPrincipal(String username);
60      
61      /***
62       * <p>
63       * Gets the an iterator of user principals for a given filter.
64       * </p>
65       * 
66       * @param filter The filter.
67       * @return The list of <code>Principal</code>
68       */
69      List getUserPrincipals(String filter);
70      
71      /***
72       * <p>
73       * Adds a new user principal in the backing store.
74       * </p>
75       * 
76       * @param userPrincipal The new <code>UserPrincipal</code>.
77       * @throws SecurityException Throws a {@link SecurityException}.
78       */
79      void addUserPrincipal(UserPrincipal userPrincipal) throws SecurityException;
80      
81      /***
82       * <p>
83       * Updates the user principal in the backing store.
84       * </p>
85       * 
86       * @param userPrincipal The <code>UserPrincipal</code>.
87       * @throws SecurityException Throws a {@link SecurityException}.
88       */
89      void updateUserPrincipal(UserPrincipal userPrincipal) throws SecurityException;
90      
91      /***
92       * <p>
93       * Removes the user principal.
94       * </p>
95       * 
96       * @param userPrincipal The <code>UserPrincipal</code>.
97       * @throws SecurityException Throws a {@link SecurityException}.
98       */
99      void removeUserPrincipal(UserPrincipal userPrincipal) throws SecurityException;
100 }