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: package org.apache.jetspeed.security.spi;
018:
019: import java.security.Principal;
020: import java.util.List;
021:
022: import org.apache.jetspeed.security.SecurityException;
023: import org.apache.jetspeed.security.UserPrincipal;
024:
025: /**
026: * <p>
027: * This interface encapsulates the persistence of a user security.
028: * </p>
029: * <p>
030: * This provides a central placeholder for changing the persistence of user
031: * security information.
032: * </p>
033: * <p>
034: * A security implementation wanting to store user security implementation in
035: * LDAP for instance would need to provide an LDAP implementation of this
036: * interface.
037: * </p>
038: *
039: * @author <a href="mailto:dlestrat@apache.org">David Le Strat </a>
040: */
041: public interface UserSecurityHandler {
042: /**
043: * <p>
044: * Checks if a UserPrincipal exists
045: * @param userName
046: * @return true if a UserPrincipal exists
047: */
048: boolean isUserPrincipal(String userName);
049:
050: /**
051: * <p>
052: * Gets the user principal for the given user name.
053: * </p>
054: *
055: * @param username The user name.
056: * @return The <code>Principal</p>
057: */
058: Principal getUserPrincipal(String username);
059:
060: /**
061: * <p>
062: * Gets the an iterator of user principals for a given filter.
063: * </p>
064: *
065: * @param filter The filter.
066: * @return The list of <code>Principal</code>
067: */
068: List getUserPrincipals(String filter);
069:
070: /**
071: * <p>
072: * Adds a new user principal in the backing store.
073: * </p>
074: *
075: * @param userPrincipal The new <code>UserPrincipal</code>.
076: * @throws SecurityException Throws a {@link SecurityException}.
077: */
078: void addUserPrincipal(UserPrincipal userPrincipal)
079: throws SecurityException;
080:
081: /**
082: * <p>
083: * Updates the user principal in the backing store.
084: * </p>
085: *
086: * @param userPrincipal The <code>UserPrincipal</code>.
087: * @throws SecurityException Throws a {@link SecurityException}.
088: */
089: void updateUserPrincipal(UserPrincipal userPrincipal)
090: throws SecurityException;
091:
092: /**
093: * <p>
094: * Removes the user principal.
095: * </p>
096: *
097: * @param userPrincipal The <code>UserPrincipal</code>.
098: * @throws SecurityException Throws a {@link SecurityException}.
099: */
100: void removeUserPrincipal(UserPrincipal userPrincipal)
101: throws SecurityException;
102: }
|