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.api.ldap.extras.controls.ppolicy_impl;
022
023
024import org.apache.directory.api.asn1.ber.AbstractContainer;
025import org.apache.directory.api.ldap.codec.api.LdapApiService;
026import org.apache.directory.api.ldap.extras.controls.ppolicy.PasswordPolicy;
027import org.apache.directory.api.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        setGrammar( PasswordPolicyGrammar.getInstance() );
045        setTransition( PasswordPolicyStates.START_STATE );
046    }
047
048
049    public PasswordPolicyContainer( LdapApiService codec, PasswordPolicy ppolicyResponse )
050    {
051        super();
052
053        if ( ppolicyResponse instanceof PasswordPolicyDecorator )
054        {
055            this.control = ( PasswordPolicyDecorator ) ppolicyResponse;
056        }
057        else
058        {
059            control = new PasswordPolicyDecorator( codec, ppolicyResponse );
060        }
061
062        setGrammar( PasswordPolicyGrammar.getInstance() );
063        setTransition( PasswordPolicyStates.START_STATE );
064    }
065
066
067    public PasswordPolicyDecorator getPasswordPolicyResponseControl()
068    {
069        return control;
070    }
071
072
073    public void setPasswordPolicyResponseControl( PasswordPolicyDecorator control )
074    {
075        this.control = control;
076    }
077
078
079    /**
080     * clean the container
081     */
082    @Override
083    public void clean()
084    {
085        super.clean();
086        control = null;
087    }
088
089}