Author: elecharny
Date: Mon May 2 14:19:52 2005
New Revision: 165696
URL: http://svn.apache.org/viewcvs?rev=165696&view=rev
Log:
Added sme actions, and fixed some.
Modified:
directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/spnego/codec/grammars/SpnegoGrammar.java
Modified:
directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/spnego/codec/grammars/SpnegoGrammar.java
URL:
http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/spnego/codec/grammars/SpnegoGrammar.java?rev=165696&r1=165695&r2=165696&view=diff
==============================================================================
---
directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/spnego/codec/grammars/SpnegoGrammar.java
(original)
+++
directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/spnego/codec/grammars/SpnegoGrammar.java
Mon May 2 14:19:52 2005
@@ -420,26 +420,14 @@
null );
//------------------------------------------------------------------------------------------
- // NegTokenInit ::= SEQUENCE { (Length)
+ // NegTokenInit ::= SEQUENCE {
// ...
- // mechToken [2] OCTET STRING OPTIONAL,
+ // mechToken [2] OCTET STRING OPTIONAL, (Tag)
// ...
- // We have to check the length
+ // Nothing to do
super.transitions[SpnegoStatesEnum.SPNEGO_REQ_FLAGS_FOLLOWING_TAG][0xA2] =
new GrammarTransition(
SpnegoStatesEnum.SPNEGO_REQ_FLAGS_FOLLOWING_TAG,
- SpnegoStatesEnum.SPNEGO_MECH_TOKEN_LENGTH, new GrammarAction(
"Mech Token Length" )
- {
- public void action( IAsn1Container container ) throws
DecoderException
- {
- SpnegoContainer spnegoContainer = ( SpnegoContainer )
container;
- SpnegoNegTokenInitPOJO spnego = ( SpnegoNegTokenInitPOJO
)spnegoContainer.getSpnego();
- TLV tlv
= spnegoContainer.getCurrentTLV();
-
- // Checks the length.
- checkLength(spnego, tlv);
- return;
- }
- } );
+ SpnegoStatesEnum.SPNEGO_MECH_TOKEN_LENGTH, null);
// NegTokenInit ::= SEQUENCE {
// ...
@@ -454,6 +442,7 @@
// ...
// mechToken [2] OCTET STRING OPTIONAL, (Tag)
// ...
+ // Nothing to do
super.transitions[SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INIT_SEQUENCE_FOLLOWING_TAG][0xA2]
=
new GrammarTransition(
SpnegoStatesEnum.SPNEGO_NEG_TOKEN_INIT_SEQUENCE_FOLLOWING_TAG,
SpnegoStatesEnum.SPNEGO_MECH_TOKEN_LENGTH, null );
@@ -464,7 +453,22 @@
// ...
super.transitions[SpnegoStatesEnum.SPNEGO_MECH_TOKEN_LENGTH][0xA2] =
new GrammarTransition( SpnegoStatesEnum.SPNEGO_MECH_TOKEN_LENGTH,
- SpnegoStatesEnum.SPNEGO_MECH_TOKEN_VALUE, null );
+ SpnegoStatesEnum.SPNEGO_MECH_TOKEN_VALUE, new GrammarAction(
"Mech Token Length" )
+ {
+ public void action( IAsn1Container container ) throws
DecoderException
+ {
+ SpnegoContainer spnegoContainer = ( SpnegoContainer
) container;
+ SpnegoNegTokenInitPOJO spnego = (
SpnegoNegTokenInitPOJO )spnegoContainer.getSpnego();
+ TLV tlv
= spnegoContainer.getCurrentTLV();
+
+ // Checks the length.
+ checkLength(spnego, tlv);
+
+ // Store the length in the mech token expected
length
+
spnego.setMechTokenExpectedLength(tlv.getLength().getLength());
+ return;
+ }
+ } );
// mechToken [2] OCTET STRING OPTIONAL, (Value)
// Nothing to do
@@ -478,10 +482,46 @@
null );
// mechToken [2] OCTET STRING OPTIONAL, (Length)
- // Checks the length
+ // Checks the length. If the length is 0, we will allocate an empty
OctetString.
super.transitions[SpnegoStatesEnum.SPNEGO_MECH_TOKEN_OCTET_STRING_LENGTH][0x04]
= new GrammarTransition(
SpnegoStatesEnum.SPNEGO_MECH_TOKEN_OCTET_STRING_LENGTH,
SpnegoStatesEnum.SPNEGO_MECH_TOKEN_OCTET_STRING_VALUE,
- null );
+ new GrammarAction( "Mech Token Length" )
+ {
+ public void action( IAsn1Container container ) throws
DecoderException
+ {
+ SpnegoContainer spnegoContainer = ( SpnegoContainer )
container;
+ SpnegoNegTokenInitPOJO spnego = (
SpnegoNegTokenInitPOJO )spnegoContainer.getSpnego();
+ TLV tlv
= spnegoContainer.getCurrentTLV();
+
+ int expectedLength =
spnego.getMechTokenExpectedLength();
+ int currentLength = tlv.getLength().getSize() +
tlv.getTag().getSize() + tlv.getLength().getLength();
+
+ if ( expectedLength != currentLength )
+ {
+ throw new DecoderException("The MechToken length
is different than the expected length");
+ }
+
+ if (tlv.getLength().getLength() == 0)
+ {
+ spnego.setMechToken(OctetString.EMPTY_STRING);
+ }
+ else
+ {
+ // Creates a new mechToken
+ try
+ {
+ OctetString mechToken =
(OctetString)(spnegoContainer.getPoolManager().allocate(PoolEnum.OCTET_STRING_POOL));
+
+ spnego.setMechToken(mechToken);
+ }
+ catch (PoolException pe)
+ {
+ throw new DecoderException("Cannot allocate an
OID");
+ }
+ }
+ return;
+ }
+ } );
// mechToken [2] OCTET STRING OPTIONAL, (Value)
// We will allocate a new Octet String.
@@ -495,19 +535,10 @@
SpnegoNegTokenInitPOJO spnego = (
SpnegoNegTokenInitPOJO )spnegoContainer.getSpnego();
TLV tlv
= spnegoContainer.getCurrentTLV();
- // Creates a new mechToken
- try
- {
- OctetString mechToken =
(OctetString)(spnegoContainer.getPoolManager().allocate(PoolEnum.OCTET_STRING_POOL));
+ // Stores the mechToken data
+ OctetString mechToken = spnego.getMechToken();
- mechToken.setData(tlv.getValue().getData());
-
- spnego.setMechToken(mechToken);
- }
- catch (PoolException pe)
- {
- throw new DecoderException("Cannot allocate an
OID");
- }
+ mechToken.setData(tlv.getValue().getData());
return;
}
} );