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   *     https://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.actions.CheckNotNullLength;
25  import org.apache.directory.api.asn1.ber.grammar.AbstractGrammar;
26  import org.apache.directory.api.asn1.ber.grammar.Grammar;
27  import org.apache.directory.api.asn1.ber.grammar.GrammarTransition;
28  import org.apache.directory.api.asn1.ber.tlv.UniversalTag;
29  
30  
31  /**
32   * Grammar for decoding PasswordPolicyResponseControl.
33   *
34   * PasswordPolicyResponseValue ::= SEQUENCE {
35   *      warning [0] CHOICE {
36   *         timeBeforeExpiration [0] INTEGER (0 .. maxInt),
37   *         graceAuthNsRemaining [1] INTEGER (0 .. maxInt) 
38   *      } OPTIONAL,
39   *      error   [1] ENUMERATED {
40   *          passwordExpired             (0),
41   *          accountLocked               (1),
42   *          changeAfterReset            (2),
43   *          passwordModNotAllowed       (3),
44   *          mustSupplyOldPassword       (4),
45   *          insufficientPasswordQuality (5),
46   *          passwordTooShort            (6),
47   *          passwordTooYoung            (7),
48   *          passwordInHistory           (8) 
49   *      } OPTIONAL 
50   * }
51   *          
52   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
53   */
54  public final class PasswordPolicyResponseGrammar extends AbstractGrammar<PasswordPolicyResponseContainer>
55  {
56      /** PasswordPolicyResponseControlGrammar singleton instance */
57      private static final PasswordPolicyResponseGrammar INSTANCE = new PasswordPolicyResponseGrammar();
58  
59  
60      @SuppressWarnings("unchecked")
61      private PasswordPolicyResponseGrammar()
62      {
63          setName( PasswordPolicyResponseGrammar.class.getName() );
64  
65          super.transitions = new GrammarTransition[PasswordPolicyResponseStates.END_STATE.ordinal()][256];
66  
67          // PasswordPolicyResponseValue ::= SEQUENCE {
68          // ...
69          super.transitions[PasswordPolicyResponseStates.START_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition<PasswordPolicyResponseContainer>(
70              PasswordPolicyResponseStates.START_STATE, PasswordPolicyResponseStates.PPOLICY_RESP_SEQ_STATE,
71              UniversalTag.SEQUENCE.getValue(),
72              new PPolicyResponseInit() );
73  
74          // PasswordPolicyResponseValue ::= SEQUENCE {
75          //              warning [0] CHOICE {
76          super.transitions[PasswordPolicyResponseStates.PPOLICY_RESP_SEQ_STATE.ordinal()][PasswordPolicyTags.PPOLICY_WARNING_TAG
77              .getValue()] = new GrammarTransition<PasswordPolicyResponseContainer>(
78              PasswordPolicyResponseStates.PPOLICY_RESP_SEQ_STATE, PasswordPolicyResponseStates.PPOLICY_RESP_WARNING_TAG_STATE,
79              PasswordPolicyTags.PPOLICY_WARNING_TAG.getValue(),
80              new CheckNotNullLength<PasswordPolicyResponseContainer>() );
81  
82          // PasswordPolicyResponseValue ::= SEQUENCE {
83          //              ...
84          //              error   [1] ENUMERATED {
85          super.transitions[PasswordPolicyResponseStates.PPOLICY_RESP_SEQ_STATE.ordinal()][PasswordPolicyTags.PPOLICY_ERROR_TAG
86              .getValue()] = new GrammarTransition<PasswordPolicyResponseContainer>(
87              PasswordPolicyResponseStates.PPOLICY_RESP_SEQ_STATE, PasswordPolicyResponseStates.PPOLICY_RESP_ERROR_TAG_STATE,
88              PasswordPolicyTags.PPOLICY_ERROR_TAG.getValue(),
89              new StoreError<PasswordPolicyResponseContainer>() );
90  
91          // PasswordPolicyResponseValue ::= SEQUENCE {
92          //              warning [0] CHOICE {
93          //                      timeBeforeExpiration [0] INTEGER (0 .. maxInt),
94          super.transitions[PasswordPolicyResponseStates.PPOLICY_RESP_WARNING_TAG_STATE.ordinal()][PasswordPolicyTags.TIME_BEFORE_EXPIRATION_TAG
95              .getValue()] = new GrammarTransition<PasswordPolicyResponseContainer>(
96              PasswordPolicyResponseStates.PPOLICY_RESP_WARNING_TAG_STATE, PasswordPolicyResponseStates.PPOLICY_RESP_TIME_BEFORE_EXPIRATION_STATE,
97              PasswordPolicyTags.TIME_BEFORE_EXPIRATION_TAG.getValue(),
98              new StoreTimeBeforeExpiration() );
99  
100         // PasswordPolicyResponseValue ::= SEQUENCE {
101         //              warning [0] CHOICE {
102         //                      ...
103         //                      graceAuthNsRemaining [1] INTEGER (0 .. maxInt) } OPTIONAL,
104         super.transitions[PasswordPolicyResponseStates.PPOLICY_RESP_WARNING_TAG_STATE.ordinal()][PasswordPolicyTags.GRACE_AUTHNS_REMAINING_TAG
105             .getValue()] = new GrammarTransition<PasswordPolicyResponseContainer>(
106             PasswordPolicyResponseStates.PPOLICY_RESP_WARNING_TAG_STATE, PasswordPolicyResponseStates.PPOLICY_RESP_GRACE_AUTHNS_REMAINING_STATE,
107             PasswordPolicyTags.GRACE_AUTHNS_REMAINING_TAG.getValue(),
108             new StoreGraceAuthNRemaining() );
109 
110         // PasswordPolicyResponseValue ::= SEQUENCE {
111         //              ...
112         //              error   [1] ENUMERATED {
113         super.transitions[PasswordPolicyResponseStates.PPOLICY_RESP_TIME_BEFORE_EXPIRATION_STATE.ordinal()][PasswordPolicyTags.PPOLICY_ERROR_TAG
114             .getValue()] = new GrammarTransition<PasswordPolicyResponseContainer>(
115             PasswordPolicyResponseStates.PPOLICY_RESP_TIME_BEFORE_EXPIRATION_STATE, PasswordPolicyResponseStates.PPOLICY_RESP_ERROR_TAG_STATE,
116             PasswordPolicyTags.PPOLICY_ERROR_TAG.getValue(),
117             new StoreError<PasswordPolicyResponseContainer>() );
118 
119         // PasswordPolicyResponseValue ::= SEQUENCE {
120         //              ...
121         //              error   [1] ENUMERATED {
122         super.transitions[PasswordPolicyResponseStates.PPOLICY_RESP_GRACE_AUTHNS_REMAINING_STATE.ordinal()][PasswordPolicyTags.GRACE_AUTHNS_REMAINING_TAG
123             .getValue()] = new GrammarTransition<PasswordPolicyResponseContainer>(
124             PasswordPolicyResponseStates.PPOLICY_RESP_GRACE_AUTHNS_REMAINING_STATE, PasswordPolicyResponseStates.PPOLICY_RESP_ERROR_TAG_STATE,
125             PasswordPolicyTags.GRACE_AUTHNS_REMAINING_TAG.getValue(),
126             new StoreError<PasswordPolicyResponseContainer>() );
127     }
128 
129 
130     /**
131      * @return the singleton instance of the PasswordPolicyResponseGrammar
132      */
133     public static Grammar<PasswordPolicyResponseContainer> getInstance()
134     {
135         return INSTANCE;
136     }
137 }