in ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/extended/ads_impl/certGeneration/CertGenerationRequestGrammar.java [69:267]
public CertGenerationRequestGrammar()
{
setName( CertGenerationRequestGrammar.class.getName() );
// Create the transitions table
super.transitions = new GrammarTransition[CertGenerationRequestStatesEnum.LAST_CERT_GENERATION_STATE.ordinal()][256];
/**
* Transition from init state to certificate generation
*
* CertGenerationObject ::= SEQUENCE {
* ...
*
* Creates the CertGenerationObject object
*/
super.transitions[CertGenerationRequestStatesEnum.START_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] =
new GrammarTransition<CertGenerationRequestContainer>(
CertGenerationRequestStatesEnum.START_STATE,
CertGenerationRequestStatesEnum.CERT_GENERATION_REQUEST_SEQUENCE_STATE,
UniversalTag.SEQUENCE.getValue(),
null,
FollowUp.MANDATORY );
/**
* Transition from certificate generation request to targetDN
*
* CertGenerationObject ::= SEQUENCE {
* targetDN IA5String,
* ...
*
* Set the targetDN value into the CertGenerationObject instance.
*/
super.transitions[CertGenerationRequestStatesEnum.CERT_GENERATION_REQUEST_SEQUENCE_STATE.ordinal()][UniversalTag.OCTET_STRING
.getValue()] =
new GrammarTransition<CertGenerationRequestContainer>(
CertGenerationRequestStatesEnum.CERT_GENERATION_REQUEST_SEQUENCE_STATE,
CertGenerationRequestStatesEnum.TARGETDN_STATE, UniversalTag.OCTET_STRING.getValue(),
new GrammarAction<CertGenerationRequestContainer>( "Set Cert Generation target Dn value" )
{
public void action( CertGenerationRequestContainer container ) throws DecoderException
{
BerValue value = container.getCurrentTLV().getValue();
String targetDN = Strings.utf8ToString( value.getData() );
if ( LOG.isDebugEnabled() )
{
LOG.debug( I18n.msg( I18n.MSG_08215_TARGET_DN, targetDN ) );
}
if ( ( targetDN != null ) && ( targetDN.trim().length() > 0 ) )
{
if ( !Dn.isValid( targetDN ) )
{
String msg = I18n.err( I18n.ERR_08201_INVALID_TARGET_DN, targetDN );
LOG.error( msg );
throw new DecoderException( msg );
}
container.getCertGenerationRequest().setTargetDN( targetDN );
}
else
{
String msg = I18n.err( I18n.ERR_08202_NULL_TARGET_DN_DECODING_FAILED, Strings.dumpBytes( value.getData() ) );
LOG.error( msg );
throw new DecoderException( msg );
}
}
},
FollowUp.MANDATORY );
/**
* Transition from targetDN state to issuerDN
*
* CertGenerationObject ::= SEQUENCE {
* ...
* issuerDN IA5String,
* ...
*
* Set the issuerDN value into the CertGenerationObject instance.
*/
super.transitions[CertGenerationRequestStatesEnum.TARGETDN_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] =
new GrammarTransition<CertGenerationRequestContainer>(
CertGenerationRequestStatesEnum.TARGETDN_STATE,
CertGenerationRequestStatesEnum.ISSUER_STATE, UniversalTag.OCTET_STRING.getValue(),
new GrammarAction<CertGenerationRequestContainer>( "Set Cert Generation issuer Dn value" )
{
public void action( CertGenerationRequestContainer container ) throws DecoderException
{
BerValue value = container.getCurrentTLV().getValue();
String issuerDN = Strings.utf8ToString( value.getData() );
if ( LOG.isDebugEnabled() )
{
LOG.debug( I18n.msg( I18n.MSG_08207_ISSUER_DN, issuerDN ) );
}
if ( ( issuerDN != null ) && ( issuerDN.trim().length() > 0 ) )
{
if ( !Dn.isValid( issuerDN ) )
{
String msg = I18n.err( I18n.ERR_08203_INVALID_ISSUER_DN, issuerDN );
LOG.error( msg );
throw new DecoderException( msg );
}
container.getCertGenerationRequest().setIssuerDN( issuerDN );
}
}
},
FollowUp.MANDATORY );
/**
* Transition from issuerDN state to subjectDN
*
* CertGenerationObject ::= SEQUENCE {
* ...
* subjectDN IA5String,
* ...
*
* Set the subjectDN value into the CertGenerationObject instance.
*/
super.transitions[CertGenerationRequestStatesEnum.ISSUER_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] =
new GrammarTransition<CertGenerationRequestContainer>(
CertGenerationRequestStatesEnum.ISSUER_STATE,
CertGenerationRequestStatesEnum.SUBJECT_STATE, UniversalTag.OCTET_STRING.getValue(),
new GrammarAction<CertGenerationRequestContainer>( "Set Cert Generation subject Dn value" )
{
public void action( CertGenerationRequestContainer container ) throws DecoderException
{
BerValue value = container.getCurrentTLV().getValue();
String subjectDN = Strings.utf8ToString( value.getData() );
if ( LOG.isDebugEnabled() )
{
LOG.debug( I18n.msg( I18n.MSG_08219_SUBJECT_DN, subjectDN ) );
}
if ( ( subjectDN != null ) && ( subjectDN.trim().length() > 0 ) )
{
if ( !Dn.isValid( subjectDN ) )
{
String msg = I18n.err( I18n.ERR_08204_INVALID_SUBJECT_DN, subjectDN );
LOG.error( msg );
throw new DecoderException( msg );
}
container.getCertGenerationRequest().setSubjectDN( subjectDN );
}
else
{
String msg = I18n.err( I18n.ERR_08202_NULL_TARGET_DN_DECODING_FAILED, Strings.dumpBytes( value.getData() ) );
LOG.error( msg );
throw new DecoderException( msg );
}
}
},
FollowUp.MANDATORY );
/**
* Transition from subjectDN state to keyAlgo
*
* CertGenerationObject ::= SEQUENCE {
* ...
* keyAlgorithm IA5String
*
* Set the key algorithm value into the CertGenerationObject instance.
*/
super.transitions[CertGenerationRequestStatesEnum.SUBJECT_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] =
new GrammarTransition<CertGenerationRequestContainer>(
CertGenerationRequestStatesEnum.SUBJECT_STATE,
CertGenerationRequestStatesEnum.KEY_ALGORITHM_STATE,
UniversalTag.OCTET_STRING.getValue(),
new GrammarAction<CertGenerationRequestContainer>( "Set Cert Generation key algorithm value" )
{
public void action( CertGenerationRequestContainer container )
{
BerValue value = container.getCurrentTLV().getValue();
String keyAlgorithm = Strings.utf8ToString( value.getData() );
if ( LOG.isDebugEnabled() )
{
LOG.debug( I18n.msg( I18n.MSG_08218_KEY_ALGORITHM, keyAlgorithm ) );
}
if ( keyAlgorithm != null && ( keyAlgorithm.trim().length() > 0 ) )
{
container.getCertGenerationRequest().setKeyAlgorithm( keyAlgorithm );
}
container.setGrammarEndAllowed( true );
}
},
FollowUp.OPTIONAL );
}