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;
018:
019: import java.sql.Date;
020:
021: import org.apache.jetspeed.security.spi.CredentialHandler;
022: import org.apache.jetspeed.security.spi.UserSecurityHandler;
023:
024: /**
025: * <p>
026: * Proxy allowing to handle multiple authentication providers.
027: * </p>
028: *
029: * @author <a href="mailto:dlestrat@apache.org">David Le Strat </a>
030: */
031: public interface AuthenticationProviderProxy extends
032: UserSecurityHandler, CredentialHandler {
033: /**
034: * <p>
035: * Returns the default authentication provider.
036: * </p>
037: *
038: * @return The default authentication provider.
039: */
040: String getDefaultAuthenticationProvider();
041:
042: /**
043: * <p>
044: * Returns the authentication provider of a user principal.
045: * @param userName
046: * @return The authentication provider or null if user is unknown.
047: */
048: String getAuthenticationProvider(String userName);
049:
050: /**
051: * <p>
052: * Adds a new user principal in a given authentication provider.
053: * </p>
054: *
055: * @param userPrincipal The new user principal.
056: * @param authenticationProvider The authentication provider name.
057: * @throws SecurityException Throws a security exception.
058: */
059: void addUserPrincipal(UserPrincipal userPrincipal,
060: String authenticationProvider) throws SecurityException;
061:
062: /**
063: * <p>
064: * Updates user principal in a given authentication provider.
065: * </p>
066: *
067: * @param userPrincipal The user principal.
068: * @param authenticationProvider The authentication provider name.
069: * @throws SecurityException Throws a security exception.
070: */
071: void updateUserPrincipal(UserPrincipal userPrincipal,
072: String authenticationProvider) throws SecurityException;
073:
074: /**
075: * <p>
076: * Remove user principal in a given authentication provider.
077: * </p>
078: *
079: * @param userPrincipal The user principal.
080: * @param authenticationProvider The authentication provider name.
081: * @throws SecurityException Throws a security exception.
082: */
083: void removeUserPrincipal(UserPrincipal userPrincipal,
084: String authenticationProvider) throws SecurityException;
085:
086: /**
087: * <p>
088: * Adds or updates a private password credentialin a given authentication provider.<br>
089: * Note that there is no checking of the <code>oldPassword</code> and the provided password is
090: * assumed to be encoded. Hence no encoding will take place.
091: * </p>
092: *
093: * @param username The user to be updated.
094: * @param newPassword The new password.
095: * @throws SecurityException Throws a {@link SecurityException}.
096: */
097: void importPassword(String userName, String newPassword)
098: throws SecurityException;
099:
100: /**
101: * <p>
102: * Adds or updates a private password credentialin a given authentication provider.<br>
103: * Note that there is no checking of the <code>oldPassword</code> and the provided password is
104: * assumed to be encoded. Hence no encoding will take place.
105: * </p>
106: *
107: * @param username The user to be updated.
108: * @param newPassword The new password.
109: * @param authenticationProvider The authentication provider name.
110: * @throws SecurityException Throws a {@link SecurityException}.
111: */
112: void importPassword(String userName, String newPassword,
113: String authenticationProvider) throws SecurityException;
114:
115: /**
116: * <p>
117: * Adds or updates a private password credential in a given authentication provider.<br>
118: * If <code>oldPassword</code> is not null, the oldPassword will first be checked (authenticated).<br>
119: * </p>
120: *
121: * @param userName The name of the user to be updated.
122: * @param oldPassword The old password value.
123: * @param newPassword The new password value.
124: * @param authenticationProvider The authentication provider name.
125: * @throws SecurityException Throws a {@link SecurityException}.
126: */
127: void setPassword(String userName, String oldPassword,
128: String newPassword, String authenticationProvider)
129: throws SecurityException;
130:
131: /**
132: * <p>
133: * Set the update required state of the user password credential in a given authentication provider.
134: * </p>
135: *
136: * @param userName The user name.
137: * @param updateRequired The update required state.
138: * @param authenticationProvider The authentication provider name.
139: * @throws Throws a security exception.
140: */
141: void setPasswordUpdateRequired(String userName,
142: boolean updateRequired, String authenticationProvider)
143: throws SecurityException;
144:
145: /**
146: * <p>
147: * Set the enabled state of the user password credential in a given authentication provider.
148: * </p>
149: *
150: * @param userName The user name.
151: * @param enabled The enabled state.
152: * @param authenticationProvider The authentication provider name.
153: * @throws Throws a security exception.
154: */
155: void setPasswordEnabled(String userName, boolean enabled,
156: String authenticationProvider) throws SecurityException;
157:
158: /**
159: * <p>
160: * Set the expiration date and the expired flag of the password credential in a given authentication provider</p>
161: * <p>
162: * If a date equal or before the current date is provided, the expired flag will be set to true,
163: * otherwise to false.</p>
164: *
165: * @param userName The user name.
166: * @param expirationDate The expiration date to set.
167: * @param authenticationProvider The authentication provider name.
168: * @throws Throws a security exception.
169: */
170: void setPasswordExpiration(String userName, Date expirationDate,
171: String authenticationProvider) throws SecurityException;
172:
173: /**
174: * <p>
175: * Authenticate a user in a given authentication provider
176: * </p>
177: *
178: * @param userName The user name.
179: * @param password The user password.
180: * @param authenticationProvider The authentication provider name.
181: * @return Whether or not a user is authenticated.
182: */
183: boolean authenticate(String userName, String password,
184: String authenticationProvider) throws SecurityException;
185: }
|