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.directory.api.ldap.extras.controls.ppolicy;
21
22
23 import org.apache.directory.api.ldap.model.message.Control;
24
25
26 /**
27 * The password policy {@link Control} interface.
28 *
29 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
30 * @version $Rev$, $Date$
31 */
32 public interface PasswordPolicy extends Control
33 {
34 /** the password policy request control */
35 String OID = "1.3.6.1.4.1.42.2.27.8.5.1";
36
37
38 /**
39 * Checks whether this Control is the password policy request or the response
40 * by carrying with it an IPasswordPolicyResponse object. If it is a request,
41 * then no response component will be associated with the control: getResponse()
42 * will return null.
43 *
44 * @return true if this Control carries a response, false if it is a request
45 */
46 boolean hasResponse();
47
48
49 /**
50 * Sets the response. If null hasResponse() will return null and this will be
51 * handled as a password policy request control rather than a response control.
52 *
53 * @param response a valid response object, or null to make this a request
54 */
55 void setResponse( PasswordPolicyResponse response );
56
57
58 /**
59 * If true sets the response to a default newly initialized response object.
60 * If this was previously a request, it automatically becomes a response. If it
61 * was not a request with an already existing response object then that response
62 * is replace with a new one and the old is returned. If false then any response
63 * object set will be cleared to null.
64 *
65 * Effectively this will cause hasResponse() to return whatever you plug into it.
66 *
67 * @param hasResponse true to create default response, false to clear it
68 * @return the old response object, if one did not exist null is returned
69 */
70 PasswordPolicyResponse setResponse( boolean hasResponse );
71
72
73 /**
74 * Get's the response component of this control if this control carries a
75 * response. If {@link #hasResponse()} returns true, this will return a non-null
76 * policy response object.
77 *
78 * @return a non-null policy response or null, if {@link #hasResponse()}
79 * returns false
80 */
81 PasswordPolicyResponse getResponse();
82 }