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 * https://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.actions.CheckNotNullLength; 025import org.apache.directory.api.asn1.ber.grammar.AbstractGrammar; 026import org.apache.directory.api.asn1.ber.grammar.Grammar; 027import org.apache.directory.api.asn1.ber.grammar.GrammarTransition; 028import org.apache.directory.api.asn1.ber.tlv.UniversalTag; 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) 038 * } OPTIONAL, 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) 049 * } OPTIONAL 050 * } 051 * 052 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 053 */ 054public final class PasswordPolicyResponseGrammar extends AbstractGrammar<PasswordPolicyResponseContainer> 055{ 056 /** PasswordPolicyResponseControlGrammar singleton instance */ 057 private static final PasswordPolicyResponseGrammar INSTANCE = new PasswordPolicyResponseGrammar(); 058 059 060 @SuppressWarnings("unchecked") 061 private PasswordPolicyResponseGrammar() 062 { 063 setName( PasswordPolicyResponseGrammar.class.getName() ); 064 065 super.transitions = new GrammarTransition[PasswordPolicyResponseStates.END_STATE.ordinal()][256]; 066 067 // PasswordPolicyResponseValue ::= SEQUENCE { 068 // ... 069 super.transitions[PasswordPolicyResponseStates.START_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition<PasswordPolicyResponseContainer>( 070 PasswordPolicyResponseStates.START_STATE, PasswordPolicyResponseStates.PPOLICY_RESP_SEQ_STATE, 071 UniversalTag.SEQUENCE.getValue(), 072 new PPolicyResponseInit() ); 073 074 // PasswordPolicyResponseValue ::= SEQUENCE { 075 // warning [0] CHOICE { 076 super.transitions[PasswordPolicyResponseStates.PPOLICY_RESP_SEQ_STATE.ordinal()][PasswordPolicyTags.PPOLICY_WARNING_TAG 077 .getValue()] = new GrammarTransition<PasswordPolicyResponseContainer>( 078 PasswordPolicyResponseStates.PPOLICY_RESP_SEQ_STATE, PasswordPolicyResponseStates.PPOLICY_RESP_WARNING_TAG_STATE, 079 PasswordPolicyTags.PPOLICY_WARNING_TAG.getValue(), 080 new CheckNotNullLength<PasswordPolicyResponseContainer>() ); 081 082 // PasswordPolicyResponseValue ::= SEQUENCE { 083 // ... 084 // error [1] ENUMERATED { 085 super.transitions[PasswordPolicyResponseStates.PPOLICY_RESP_SEQ_STATE.ordinal()][PasswordPolicyTags.PPOLICY_ERROR_TAG 086 .getValue()] = new GrammarTransition<PasswordPolicyResponseContainer>( 087 PasswordPolicyResponseStates.PPOLICY_RESP_SEQ_STATE, PasswordPolicyResponseStates.PPOLICY_RESP_ERROR_TAG_STATE, 088 PasswordPolicyTags.PPOLICY_ERROR_TAG.getValue(), 089 new StoreError<PasswordPolicyResponseContainer>() ); 090 091 // PasswordPolicyResponseValue ::= SEQUENCE { 092 // warning [0] CHOICE { 093 // timeBeforeExpiration [0] INTEGER (0 .. maxInt), 094 super.transitions[PasswordPolicyResponseStates.PPOLICY_RESP_WARNING_TAG_STATE.ordinal()][PasswordPolicyTags.TIME_BEFORE_EXPIRATION_TAG 095 .getValue()] = new GrammarTransition<PasswordPolicyResponseContainer>( 096 PasswordPolicyResponseStates.PPOLICY_RESP_WARNING_TAG_STATE, PasswordPolicyResponseStates.PPOLICY_RESP_TIME_BEFORE_EXPIRATION_STATE, 097 PasswordPolicyTags.TIME_BEFORE_EXPIRATION_TAG.getValue(), 098 new StoreTimeBeforeExpiration() ); 099 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}