View Javadoc
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  
21  package org.apache.directory.api.ldap.extras.controls.ppolicy_impl;
22  
23  
24  import org.apache.directory.api.asn1.ber.AbstractContainer;
25  import org.apache.directory.api.ldap.codec.api.LdapApiService;
26  import org.apache.directory.api.ldap.extras.controls.ppolicy.PasswordPolicy;
27  import org.apache.directory.api.ldap.extras.controls.ppolicy.PasswordPolicyImpl;
28  
29  
30  /**
31   * container for PasswordPolicyResponseControl.
32   *
33   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
34   */
35  public class PasswordPolicyContainer extends AbstractContainer
36  {
37      private PasswordPolicyDecorator control;
38  
39  
40      /**
41       * Creates a new StoredProcedureContainer instance
42       * 
43       * @param codec The LDAP Service to use
44       */
45      public PasswordPolicyContainer( LdapApiService codec )
46      {
47          super();
48          control = new PasswordPolicyDecorator( codec, new PasswordPolicyImpl() );
49          setGrammar( PasswordPolicyGrammar.getInstance() );
50          setTransition( PasswordPolicyStates.START_STATE );
51      }
52  
53  
54      /**
55       * Creates a new StoredProcedureContainer instance
56       * 
57       * @param codec The LDAP Service to use
58       * @param ppolicyResponse The PasswordPolicy response
59       */
60      public PasswordPolicyContainer( LdapApiService codec, PasswordPolicy ppolicyResponse )
61      {
62          super();
63  
64          if ( ppolicyResponse instanceof PasswordPolicyDecorator )
65          {
66              this.control = ( PasswordPolicyDecorator ) ppolicyResponse;
67          }
68          else
69          {
70              control = new PasswordPolicyDecorator( codec, ppolicyResponse );
71          }
72  
73          setGrammar( PasswordPolicyGrammar.getInstance() );
74          setTransition( PasswordPolicyStates.START_STATE );
75      }
76  
77  
78      /**
79       * @return The decorated PasswordPolicy control
80       */
81      public PasswordPolicyDecorator getPasswordPolicyResponseControl()
82      {
83          return control;
84      }
85  
86  
87      /**
88       * Sets the password policy control
89       * 
90       * @param control The decorated PasswordPolicy control
91       */
92      public void setPasswordPolicyResponseControl( PasswordPolicyDecorator control )
93      {
94          this.control = control;
95      }
96  
97  
98      /**
99       * clean the container
100      */
101     @Override
102     public void clean()
103     {
104         super.clean();
105         control = null;
106     }
107 
108 }