Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 71095 invoked from network); 25 Apr 2005 22:33:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 25 Apr 2005 22:33:24 -0000 Received: (qmail 13700 invoked by uid 500); 25 Apr 2005 22:33:57 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 13645 invoked by uid 500); 25 Apr 2005 22:33:57 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 13631 invoked by uid 99); 25 Apr 2005 22:33:57 -0000 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Mon, 25 Apr 2005 15:33:57 -0700 Received: (qmail 71064 invoked by uid 65534); 25 Apr 2005 22:33:21 -0000 Message-ID: <20050425223321.71063.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: svn commit: r164676 - /directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/spnego/codec/grammars/SpnegoGrammar.java Date: Mon, 25 Apr 2005 22:33:21 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.0-dev X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: elecharny Date: Mon Apr 25 15:33:20 2005 New Revision: 164676 URL: http://svn.apache.org/viewcvs?rev=3D164676&view=3Drev Log: Added the first part of the SPNEGO Grammar, even if is not finished. (so I = can't check it out from office;) Added: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/spnego/= codec/grammars/SpnegoGrammar.java Added: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/spne= go/codec/grammars/SpnegoGrammar.java URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/s= rc/java/org/apache/asn1/spnego/codec/grammars/SpnegoGrammar.java?rev=3D1646= 76&view=3Dauto =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/spnego/= codec/grammars/SpnegoGrammar.java (added) +++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/spnego/= codec/grammars/SpnegoGrammar.java Mon Apr 25 15:33:20 2005 @@ -0,0 +1,155 @@ +/* + * Copyright 2005 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or impli= ed. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.asn1.spnego.codec.grammars; + +import org.apache.asn1.DecoderException; +import org.apache.asn1.ber.containers.IAsn1Container; +import org.apache.asn1.ber.grammar.AbstractGrammar; +import org.apache.asn1.ber.grammar.GrammarAction; +import org.apache.asn1.ber.grammar.GrammarTransition; +import org.apache.asn1.ber.grammar.IGrammar; +import org.apache.asn1.ldap.codec.grammars.LdapStatesEnum; +import org.apache.asn1.spnego.codec.SpnegoContainer; +import org.apache.asn1.spnego.codec.SpnegoPoolEnum; +import org.apache.asn1.spnego.pojo.SpnegoNegTokenInitPOJO; +import org.apache.asn1.spnego.pojo.SpnegoPOJO; +import org.apache.asn1.util.pools.PoolException; + +import org.apache.log4j.Logger; + + +/** + * This class implements the LdapMessage. All the actions are declared in = this + * class. As it is a singleton, these declaration are only done once. + *=20 + * If an action is to be added or modified, this is where the work is to b= e done ! + *=20 + * @author Apache Directory Pr= oject + */ +public class SpnegoGrammar extends AbstractGrammar implements IGrammar +{ + //~ Static fields/initializers ---------------------------------------= -------------------------- + + /** The logger */ + private static final Logger log =3D Logger.getLogger( SpnegoGrammar.cl= ass ); + + /** Logging speed up */ + private static final boolean DEBUG =3D log.isDebugEnabled(); + + /** The instance of grammar. LdapMessageGrammar is a singleton */ + private static IGrammar instance =3D new SpnegoGrammar(); + + /** + * Get the instance of this grammar + * + * @return An instance on the LdapMessage Grammar + */ + public static IGrammar getInstance() + { + return instance; + } + =20 + //~ Constructors -----------------------------------------------------= -------------------------- + /** + * Creates a new LdapMessageGrammar object. + */ + private SpnegoGrammar() + { + + name =3D SpnegoGrammar.class.getName(); + + statesEnum =3D SpnegoStatesEnum.getInstance(); + + // We have=20 + super.transitions =3D new GrammarTransition[SpnegoStatesEnum.LAST_= SPNEGO_STATE][256]; + + //=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + // SPNEGO=20 + //=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + // SPNEGO --> CHOICE { + // negTokenInit [0] NegTokenInit, (Tag) + // We have a negTokenInit, and the tag must be 0xA0 + super.transitions[SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INIT_TAG][0xA0= ] =3D new GrammarTransition( SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INIT_TAG, + SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INIT_LENGTH, new Grammar= Action( "Spnego neg token init tag" ) + { + public void action( IAsn1Container container ) throws = DecoderException + { + try { + SpnegoContainer spnegoContainer =3D (SpnegoContainer= )container; +=09 + // First, create a empty Spnego POJO + SpnegoPOJO spnegoPOJO =3D ( SpnegoNegTokenInitPOJO) = spnegoContainer.getPoolManager().allocate(SpnegoPoolEnum.SPNEGO_NEG_TOKEN_I= NIT_POJO_POOL); +=09 + // Then stores it into the container + spnegoContainer.setSpnego(spnegoPOJO); + =20 + return; + } + catch ( PoolException pe ) + { + throw new DecoderException( + "Cannot allocate a spnego Pojo : " + pe.getMe= ssage() ); + } + } + } ); + + // SPNEGO --> CHOICE { ...=20 + // negTokenInit [0] NegTokenInit, (Length) + // We have a negTokenInit, and the tag must be 0xA0 + // Ok, get the negTokenInit length + super.transitions[SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INIT_LENGTH][0= xA0] =3D new GrammarTransition( SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INIT_LENG= TH, + SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INIT_VALUE, new GrammarA= ction( "Spnego neg token init Length" ) + { + public void action( IAsn1Container container ) throws = DecoderException + { + // We have to store the expected Length of the PDU + SpnegoContainer spnegoContainer =3D (SpnegoContain= er)container; + SpnegoPOJO spnego =3D spnegoContainer.getSpnego(); + + spnego.setExpectedLength(spnegoContainer.getCurren= tTLV().getLength().getLength()); + spnego.setCurrentLength(0); + + return; + } + } ); + =20 + // SPNEGO --> CHOICE { ...=20 + // negTokenInit [0] NegTokenInit, (Value) + // We will have a SEQUENCE. There is no value, so this is just a p= hantom transition. + super.transitions[SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INIT_VALUE][0x= A0] =3D new GrammarTransition( SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INIT_VALUE= , SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INIT_SEQUENCE_TAG, null); + + // NegTokenInit ::=3D SEQUENCE { (Tag) + // Nothing to do, but setting the parent link. + super.transitions[SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INIT_SEQUENCE_= TAG][0x30] =3D new GrammarTransition( SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INI= T_SEQUENCE_TAG, SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INIT_SEQUENCE_LENGTH, nul= l); + + // NegTokenInit ::=3D SEQUENCE { (Length) + // We have to check the length + super.transitions[SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INIT_SEQUENCE_= LENGTH][0x30] =3D new GrammarTransition( SpnegoStatesEnum.SPNEGO_NEG_TOKEN_= INIT_SEQUENCE_LENGTH, + SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INIT_SEQUENCE_VALUE, new= GrammarAction( "Spnego neg token init sequence Length" ) + { + public void action( IAsn1Container container ) throws = DecoderException + { + // We have to store the expected Length of the PDU + SpnegoContainer spnegoContainer =3D (SpnegoContain= er)container; + SpnegoPOJO spnego =3D spnegoContainer.getSpnego(); + checkLength(spnego, spnegoContainer.getCurrentTLV(= )); + return; + } + } ); + =20 + } +}