001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.directory.api.ldap.extras.controls.ppolicy; 021 022 023import org.apache.directory.api.ldap.model.message.Control; 024 025 026/** 027 * The password policy {@link Control} interface. 028 * 029 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 030 * @version $Rev$, $Date$ 031 */ 032public interface PasswordPolicy extends Control 033{ 034 /** the password policy request control */ 035 static final String OID = "1.3.6.1.4.1.42.2.27.8.5.1"; 036 037 038 /** 039 * Checks whether this Control is the password policy request or the response 040 * by carrying with it an IPasswordPolicyResponse object. If it is a request, 041 * then no response component will be associated with the control: getResponse() 042 * will return null. 043 * 044 * @return true if this Control carries a response, false if it is a request 045 */ 046 boolean hasResponse(); 047 048 049 /** 050 * Sets the response. If null hasResponse() will return null and this will be 051 * handled as a password policy request control rather than a response control. 052 * 053 * @param response a valid response object, or null to make this a request 054 */ 055 void setResponse( PasswordPolicyResponse response ); 056 057 058 /** 059 * If true sets the response to a default newly initialized response object. 060 * If this was previously a request, it automatically becomes a response. If it 061 * was not a request with an already existing response object then that response 062 * is replace with a new one and the old is returned. If false then any response 063 * object set will be cleared to null. 064 * 065 * Effectively this will cause hasResponse() to return whatever you plug into it. 066 * 067 * @param hasResponse true to create default response, false to clear it 068 * @return the old response object, if one did not exist null is returned 069 */ 070 PasswordPolicyResponse setResponse( boolean hasResponse ); 071 072 073 /** 074 * Get's the response component of this control if this control carries a 075 * response. If {@link #hasResponse()} returns true, this will return a non-null 076 * policy response object. 077 * 078 * @return a non-null policy response or null, if {@link #hasResponse()} 079 * returns false 080 */ 081 PasswordPolicyResponse getResponse(); 082}