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 */ 020 021package org.apache.directory.shared.ldap.extras.controls.ppolicy; 022 023 024import org.apache.directory.shared.asn1.ber.AbstractContainer; 025import org.apache.directory.shared.ldap.codec.api.LdapApiService; 026import org.apache.directory.shared.ldap.extras.controls.ppolicy.PasswordPolicy; 027import org.apache.directory.shared.ldap.extras.controls.ppolicy.PasswordPolicyImpl; 028 029 030/** 031 * container for PasswordPolicyResponseControl. 032 * 033 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 034 */ 035public class PasswordPolicyContainer extends AbstractContainer 036{ 037 private PasswordPolicyDecorator control; 038 039 040 public PasswordPolicyContainer( LdapApiService codec ) 041 { 042 super(); 043 control = new PasswordPolicyDecorator( codec, new PasswordPolicyImpl() ); 044 stateStack = new int[1]; 045 grammar = PasswordPolicyGrammar.getInstance(); 046 setTransition( PasswordPolicyStates.START_STATE ); 047 } 048 049 050 public PasswordPolicyContainer( LdapApiService codec, PasswordPolicy ppolicyResponse ) 051 { 052 super(); 053 054 if( ppolicyResponse instanceof PasswordPolicyDecorator ) 055 { 056 this.control = ( PasswordPolicyDecorator ) ppolicyResponse; 057 } 058 else 059 { 060 control = new PasswordPolicyDecorator( codec, ppolicyResponse ); 061 } 062 063 stateStack = new int[1]; 064 grammar = PasswordPolicyGrammar.getInstance(); 065 setTransition( PasswordPolicyStates.START_STATE ); 066 } 067 068 069 public PasswordPolicyDecorator getPasswordPolicyResponseControl() 070 { 071 return control; 072 } 073 074 075 public void setPasswordPolicyResponseControl( PasswordPolicyDecorator control ) 076 { 077 this.control = control; 078 } 079 080 081 /** 082 * clean the container 083 */ 084 @Override 085 public void clean() 086 { 087 super.clean(); 088 control = null; 089 } 090 091}