You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ka...@apache.org on 2010/11/23 13:16:26 UTC
svn commit: r1038079 - in /directory:
apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/ppolicy/
shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/
shared/trunk/ldap/src/main/java/org/a...
Author: kayyagari
Date: Tue Nov 23 12:16:26 2010
New Revision: 1038079
URL: http://svn.apache.org/viewvc?rev=1038079&view=rev
Log:
o fixed some actions where grammar can end
o fixed control's length calculation when no data is present
o fixed all @Ignored tests
Modified:
directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/ppolicy/PasswordPolicyTest.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseControl.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/actions/PPolicyInit.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/actions/StoreTimeBeforeExpiration.java
directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseControlTest.java
Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/ppolicy/PasswordPolicyTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/ppolicy/PasswordPolicyTest.java?rev=1038079&r1=1038078&r2=1038079&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/ppolicy/PasswordPolicyTest.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/authn/ppolicy/PasswordPolicyTest.java Tue Nov 23 12:16:26 2010
@@ -64,7 +64,6 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.name.DN;
import org.junit.After;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -123,7 +122,6 @@ public class PasswordPolicyTest extends
@Test
- @Ignore
public void testAddUserWithClearTextPwd() throws Exception
{
LdapConnection connection = getAdminNetworkConnection( ldapServer );
@@ -159,7 +157,6 @@ public class PasswordPolicyTest extends
@Test
- @Ignore
public void testAddUserWithHashedPwd() throws Exception
{
LdapConnection connection = getAdminNetworkConnection( ldapServer );
@@ -201,7 +198,6 @@ public class PasswordPolicyTest extends
@Test
- @Ignore
public void testPwdMinAge() throws Exception
{
policyConfig.setPwdMinAge( 5 );
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseControl.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseControl.java?rev=1038079&r1=1038078&r2=1038079&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseControl.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseControl.java Tue Nov 23 12:16:26 2010
@@ -69,9 +69,7 @@ public class PasswordPolicyResponseContr
timeBeforeExpirationTagLength = TLV.getNbBytes( timeBeforeExpiration );
warningLength = 1 + TLV.getNbBytes( timeBeforeExpirationTagLength ) + timeBeforeExpirationTagLength;
}
-
-
- if ( graceAuthNsRemaining >= 0 )
+ else if ( graceAuthNsRemaining >= 0 )
{
graceAuthNsRemainingTagLength = TLV.getNbBytes( graceAuthNsRemaining );
warningLength = 1 + TLV.getNbBytes( graceAuthNsRemainingTagLength ) + graceAuthNsRemainingTagLength;
@@ -87,7 +85,10 @@ public class PasswordPolicyResponseContr
ppolicySeqLength += 1 + 1 + 1;
}
- valueLength = 1 + TLV.getNbBytes( ppolicySeqLength ) + ppolicySeqLength;
+ if ( ppolicySeqLength > 0 )
+ {
+ valueLength = 1 + TLV.getNbBytes( ppolicySeqLength ) + ppolicySeqLength;
+ }
return super.computeLength( valueLength );
}
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/actions/PPolicyInit.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/actions/PPolicyInit.java?rev=1038079&r1=1038078&r2=1038079&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/actions/PPolicyInit.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/actions/PPolicyInit.java Tue Nov 23 12:16:26 2010
@@ -22,10 +22,7 @@ package org.apache.directory.shared.ldap
import org.apache.directory.shared.asn1.ber.Asn1Container;
import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
-import org.apache.directory.shared.asn1.ber.tlv.TLV;
import org.apache.directory.shared.asn1.codec.DecoderException;
-import org.apache.directory.shared.i18n.I18n;
-import org.apache.directory.shared.ldap.codec.controls.ppolicy.PasswordPolicyResponseControlContainer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -58,21 +55,8 @@ public class PPolicyInit extends Grammar
*/
public void action( Asn1Container container ) throws DecoderException
{
- PasswordPolicyResponseControlContainer ppolicyRespContainer = ( PasswordPolicyResponseControlContainer ) container;
-
- TLV tlv = ppolicyRespContainer.getCurrentTLV();
-
- // The Length should not be null
- if ( tlv.getLength() == 0 )
- {
- LOG.error( I18n.err( I18n.ERR_04066 ) );
-
- // This will generate a PROTOCOL_ERROR
- throw new DecoderException( I18n.err( I18n.ERR_04067 ) );
- }
-
// As all the values are optional or defaulted, we can end here
- ppolicyRespContainer.setGrammarEndAllowed( true );
+ container.setGrammarEndAllowed( true );
if ( IS_DEBUG )
{
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/actions/StoreTimeBeforeExpiration.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/actions/StoreTimeBeforeExpiration.java?rev=1038079&r1=1038078&r2=1038079&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/actions/StoreTimeBeforeExpiration.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/actions/StoreTimeBeforeExpiration.java Tue Nov 23 12:16:26 2010
@@ -50,5 +50,7 @@ public class StoreTimeBeforeExpiration e
PasswordPolicyResponseControlContainer ppolicyContainer = ( PasswordPolicyResponseControlContainer ) container;
ppolicyContainer.getPasswordPolicyResponseControl().setTimeBeforeExpiration( value );
+
+ container.setGrammarEndAllowed( true );
}
}
Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseControlTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseControlTest.java?rev=1038079&r1=1038078&r2=1038079&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseControlTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/codec/controls/ppolicy/PasswordPolicyResponseControlTest.java Tue Nov 23 12:16:26 2010
@@ -41,18 +41,18 @@ public class PasswordPolicyResponseContr
{
@Test
- @Ignore
public void testDecodeRespWithExpiryWarningAndError() throws Exception
{
Asn1Decoder decoder = new PasswordPolicyResponseControlDecoder();
+
ByteBuffer bb = ByteBuffer.allocate( 0xA );
bb.put( new byte[]
{
0x30, 0x08,
(byte)0xA0, 0x03, // timeBeforeExpiration
- 0x02, 0x01, 0x01,
- 0x0A, 0x01, 0x01 // ppolicyError
+ (byte)0x80, 0x01, 0x01,
+ (byte)0x81, 0x01, 0x01 // ppolicyError
} );
bb.flip();
@@ -66,18 +66,19 @@ public class PasswordPolicyResponseContr
assertEquals( 1, control.getTimeBeforeExpiration() );
assertEquals( 1, control.getPasswordPolicyError().getValue() );
- ByteBuffer buffer = ByteBuffer.allocate( 0x27 );
+ ByteBuffer buffer = ByteBuffer.allocate( 0x29 );
buffer.put( new byte[]
{
- 0x30, 0x25,
+ 0x30, 0x27,
0x04, 0x19,
'1','.', '3', '.', '6', '.', '1', '.', '4',
'.', '1', '.', '4', '2', '.', '2', '.', '2',
'7', '.', '8', '.', '5', '.', '1',
- 0x04, 0x08,
- (byte)0xA0, 0x03, // timeBeforeExpiration
- 0x02, 0x01, 0x01,
- 0x0A, 0x01, 0x01 // error
+ 0x04, 0x0A,
+ 0x30, 0x08,
+ (byte)0xA0, 0x03, // timeBeforeExpiration
+ (byte)0x80, 0x01, 0x01,
+ (byte)0x81, 0x01, 0x01 // ppolicyError
} );
buffer.flip();
@@ -90,13 +91,12 @@ public class PasswordPolicyResponseContr
public void testDecodeRespWithGraceAuthWarningAndError() throws Exception
{
Asn1Decoder decoder = new PasswordPolicyResponseControlDecoder();
- ByteBuffer bb = ByteBuffer.allocate( 0xD );
+ ByteBuffer bb = ByteBuffer.allocate( 0xA );
bb.put( new byte[]
{
- 0x30, 0x0B,
- (byte)0xA0, 0x06, // warning
- (byte)0x80, 0x01, 0x01, // timeBeforeExpiration
+ 0x30, 0x08,
+ (byte)0xA0, 0x03, // warning
(byte)0x81, 0x01, 0x01, // graceAuthNsRemaining
(byte)0x81, 0x01, 0x01 // error
} );
@@ -112,18 +112,17 @@ public class PasswordPolicyResponseContr
assertEquals( 1, control.getGraceAuthNsRemaining() );
assertEquals( 1, control.getPasswordPolicyError().getValue() );
- ByteBuffer buffer = ByteBuffer.allocate( 0x2C );
+ ByteBuffer buffer = ByteBuffer.allocate( 0x29 );
buffer.put( new byte[]
{
- 0x30, 0x2A,
+ 0x30, 0x27,
0x04, 0x19,
'1','.', '3', '.', '6', '.', '1', '.', '4',
'.', '1', '.', '4', '2', '.', '2', '.', '2',
'7', '.', '8', '.', '5', '.', '1',
- 0x04, 0x0D,
- 0x30, 0x0B,
- (byte)0xA0, 0x06, // warning
- (byte)0x80, 0x01, 0x01, // timeBeforeExpiration
+ 0x04, 0x0A,
+ 0x30, 0x08,
+ (byte)0xA0, 0x03, // warning
(byte)0x81, 0x01, 0x01, // graceAuthNsRemaining
(byte)0x81, 0x01, 0x01 // error
} );
@@ -135,7 +134,6 @@ public class PasswordPolicyResponseContr
@Test
- @Ignore
public void testDecodeRespWithTimeBeforeExpiryWarningOnly() throws Exception
{
Asn1Decoder decoder = new PasswordPolicyResponseControlDecoder();
@@ -145,7 +143,7 @@ public class PasswordPolicyResponseContr
{
0x30, 0x05,
(byte)0xA0, 0x03,
- 0x02, 0x01, 0x01 // timeBeforeExpiration
+ (byte)0x80, 0x01, 0x01 // timeBeforeExpiration
} );
bb.flip();
@@ -158,17 +156,18 @@ public class PasswordPolicyResponseContr
PasswordPolicyResponseControl control = container.getPasswordPolicyResponseControl();
assertEquals( 1, control.getTimeBeforeExpiration() );
- ByteBuffer buffer = ByteBuffer.allocate( 0x24 );
+ ByteBuffer buffer = ByteBuffer.allocate( 0x26 );
buffer.put( new byte[]
{
- 0x30, 0x22,
+ 0x30, 0x24,
0x04, 0x19,
'1','.', '3', '.', '6', '.', '1', '.', '4',
'.', '1', '.', '4', '2', '.', '2', '.', '2',
'7', '.', '8', '.', '5', '.', '1',
- 0x04, 0x05,
- (byte)0xA0, 0x03,
- 0x02, 0x01, 0x01 // timeBeforeExpiration
+ 0x04, 0x07,
+ 0x30, 0x05,
+ (byte)0xA0, 0x03,
+ (byte)0x80, 0x01, 0x01 // timeBeforeExpiration
} );
buffer.flip();
@@ -178,7 +177,6 @@ public class PasswordPolicyResponseContr
@Test
- @Ignore
public void testDecodeRespWithGraceAuthWarningOnly() throws Exception
{
Asn1Decoder decoder = new PasswordPolicyResponseControlDecoder();
@@ -187,8 +185,8 @@ public class PasswordPolicyResponseContr
bb.put( new byte[]
{
0x30, 0x05,
- (byte)0xA1, 0x03,
- 0x02, 0x01, 0x01 // graceAuthNsRemaining
+ (byte)0xA0, 0x03,
+ (byte)0x81, 0x01, 0x01 // graceAuthNsRemaining
} );
bb.flip();
@@ -201,17 +199,18 @@ public class PasswordPolicyResponseContr
PasswordPolicyResponseControl control = container.getPasswordPolicyResponseControl();
assertEquals( 1, control.getGraceAuthNsRemaining() );
- ByteBuffer buffer = ByteBuffer.allocate( 0x24 );
+ ByteBuffer buffer = ByteBuffer.allocate( 0x26 );
buffer.put( new byte[]
{
- 0x30, 0x22,
+ 0x30, 0x24,
0x04, 0x19,
'1','.', '3', '.', '6', '.', '1', '.', '4',
'.', '1', '.', '4', '2', '.', '2', '.', '2',
'7', '.', '8', '.', '5', '.', '1',
- 0x04, 0x05,
- (byte)0xA1, 0x03,
- 0x02, 0x01, 0x01 // graceAuthNsRemaining
+ 0x04, 0x07,
+ 0x30, 0x05,
+ (byte)0xA0, 0x03,
+ (byte)0x81, 0x01, 0x01 // graceAuthNsRemaining
} );
buffer.flip();
@@ -262,7 +261,6 @@ public class PasswordPolicyResponseContr
@Test
- @Ignore
public void testDecodeRespWithoutWarningAndError() throws Exception
{
Asn1Decoder decoder = new PasswordPolicyResponseControlDecoder();
@@ -290,8 +288,7 @@ public class PasswordPolicyResponseContr
0x04, 0x19,
'1','.', '3', '.', '6', '.', '1', '.', '4',
'.', '1', '.', '4', '2', '.', '2', '.', '2',
- '7', '.', '8', '.', '5', '.', '1'
- //0x30, 0x00
+ '7', '.', '8', '.', '5', '.', '1',
} );
buffer.flip();