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.grammar.AbstractGrammar; 025import org.apache.directory.shared.asn1.ber.grammar.Grammar; 026import org.apache.directory.shared.asn1.ber.grammar.GrammarTransition; 027import org.apache.directory.shared.asn1.ber.tlv.UniversalTag; 028import org.apache.directory.shared.asn1.actions.CheckNotNullLength; 029 030 031/** 032 * Grammar for decoding PasswordPolicyResponseControl. 033 * 034 * PasswordPolicyResponseValue ::= SEQUENCE { 035 * warning [0] CHOICE { 036 * timeBeforeExpiration [0] INTEGER (0 .. maxInt), 037 * graceAuthNsRemaining [1] INTEGER (0 .. maxInt) } OPTIONAL, 038 * 039 * error [1] ENUMERATED { 040 * passwordExpired (0), 041 * accountLocked (1), 042 * changeAfterReset (2), 043 * passwordModNotAllowed (3), 044 * mustSupplyOldPassword (4), 045 * insufficientPasswordQuality (5), 046 * passwordTooShort (6), 047 * passwordTooYoung (7), 048 * passwordInHistory (8) } OPTIONAL } 049 * 050 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 051 */ 052public class PasswordPolicyGrammar extends AbstractGrammar<PasswordPolicyContainer> 053{ 054 /** PasswordPolicyResponseControlGrammar singleton instance */ 055 private static final PasswordPolicyGrammar INSTANCE = new PasswordPolicyGrammar(); 056 057 058 @SuppressWarnings({ "unchecked", "rawtypes" }) 059 private PasswordPolicyGrammar() 060 { 061 setName( PasswordPolicyGrammar.class.getName() ); 062 063 super.transitions = new GrammarTransition[PasswordPolicyStates.END_STATE.ordinal()][256]; 064 065 066 // PasswordPolicyResponseValue ::= SEQUENCE { 067 // ... 068 super.transitions[PasswordPolicyStates.START_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition( 069 PasswordPolicyStates.START_STATE, PasswordPolicyStates.PPOLICY_SEQ_STATE, UniversalTag.SEQUENCE.getValue(), 070 new PPolicyInit()); 071 072 // PasswordPolicyResponseValue ::= SEQUENCE { 073 // warning [0] CHOICE { 074 super.transitions[PasswordPolicyStates.PPOLICY_SEQ_STATE.ordinal()][PasswordPolicyTags.PPOLICY_WARNING_TAG.getValue()] = new GrammarTransition( 075 PasswordPolicyStates.PPOLICY_SEQ_STATE, PasswordPolicyStates.PPOLICY_WARNING_TAG_STATE, PasswordPolicyTags.PPOLICY_WARNING_TAG.getValue(), 076 new CheckNotNullLength()); 077 078 // PasswordPolicyResponseValue ::= SEQUENCE { 079 // ... 080 // error [1] ENUMERATED { 081 super.transitions[PasswordPolicyStates.PPOLICY_SEQ_STATE.ordinal()][PasswordPolicyTags.PPOLICY_ERROR_TAG.getValue()] = new GrammarTransition( 082 PasswordPolicyStates.PPOLICY_SEQ_STATE, PasswordPolicyStates.PPOLICY_ERROR_TAG_STATE, PasswordPolicyTags.PPOLICY_ERROR_TAG.getValue(), 083 new StoreError()); 084 085 // PasswordPolicyResponseValue ::= SEQUENCE { 086 // warning [0] CHOICE { 087 // timeBeforeExpiration [0] INTEGER (0 .. maxInt), 088 super.transitions[PasswordPolicyStates.PPOLICY_WARNING_TAG_STATE.ordinal()][PasswordPolicyTags.TIME_BEFORE_EXPIRATION_TAG.getValue()] = new GrammarTransition( 089 PasswordPolicyStates.PPOLICY_WARNING_TAG_STATE, PasswordPolicyStates.PPOLICY_TIME_BEFORE_EXPIRATION_STATE, PasswordPolicyTags.TIME_BEFORE_EXPIRATION_TAG.getValue(), 090 new StoreTimeBeforeExpiration()); 091 092 // PasswordPolicyResponseValue ::= SEQUENCE { 093 // warning [0] CHOICE { 094 // ... 095 // graceAuthNsRemaining [1] INTEGER (0 .. maxInt) } OPTIONAL, 096 super.transitions[PasswordPolicyStates.PPOLICY_WARNING_TAG_STATE.ordinal()][PasswordPolicyTags.GRACE_AUTHNS_REMAINING_TAG.getValue()] = new GrammarTransition( 097 PasswordPolicyStates.PPOLICY_WARNING_TAG_STATE, PasswordPolicyStates.PPOLICY_GRACE_AUTHNS_REMAINING_STATE, PasswordPolicyTags.GRACE_AUTHNS_REMAINING_TAG.getValue(), 098 new StoreGraceAuthsRemaining()); 099 100 // PasswordPolicyResponseValue ::= SEQUENCE { 101 // ... 102 // error [1] ENUMERATED { 103 super.transitions[PasswordPolicyStates.PPOLICY_TIME_BEFORE_EXPIRATION_STATE.ordinal()][PasswordPolicyTags.PPOLICY_ERROR_TAG.getValue()] = new GrammarTransition( 104 PasswordPolicyStates.PPOLICY_TIME_BEFORE_EXPIRATION_STATE, PasswordPolicyStates.PPOLICY_ERROR_TAG_STATE, PasswordPolicyTags.PPOLICY_ERROR_TAG.getValue(), 105 new StoreError()); 106 107 // PasswordPolicyResponseValue ::= SEQUENCE { 108 // ... 109 // error [1] ENUMERATED { 110 super.transitions[PasswordPolicyStates.PPOLICY_GRACE_AUTHNS_REMAINING_STATE.ordinal()][PasswordPolicyTags.GRACE_AUTHNS_REMAINING_TAG.getValue()] = new GrammarTransition( 111 PasswordPolicyStates.PPOLICY_GRACE_AUTHNS_REMAINING_STATE, PasswordPolicyStates.PPOLICY_ERROR_TAG_STATE, PasswordPolicyTags.GRACE_AUTHNS_REMAINING_TAG.getValue(), 112 new StoreError()); 113 } 114 115 116 public static Grammar<PasswordPolicyContainer> getInstance() 117 { 118 return INSTANCE; 119 } 120}