Commit e24a78d1 authored by Sunil Kumar's avatar Sunil Kumar
Browse files

Added to Support Lburp Extension

parent 5158633a
/* **************************************************************************
* $OpenLDAP$
*
* Copyright (C) 2001 Novell, Inc. All Rights Reserved.
*
* THIS WORK IS SUBJECT TO U.S. AND INTERNATIONAL COPYRIGHT LAWS AND
* TREATIES. USE, MODIFICATION, AND REDISTRIBUTION OF THIS WORK IS SUBJECT
* TO VERSION 2.0.1 OF THE OPENLDAP PUBLIC LICENSE, A COPY OF WHICH IS
* AVAILABLE AT HTTP://WWW.OPENLDAP.ORG/LICENSE.HTML OR IN THE FILE "LICENSE"
* IN THE TOP-LEVEL DIRECTORY OF THE DISTRIBUTION. ANY USE OR EXPLOITATION
* OF THIS WORK OTHER THAN AS AUTHORIZED IN VERSION 2.0.1 OF THE OPENLDAP
* PUBLIC LICENSE, OR OTHER PRIOR WRITTEN CONSENT FROM NOVELL, COULD SUBJECT
* THE PERPETRATOR TO CRIMINAL AND CIVIL LIABILITY.
******************************************************************************/
package com.novell.ldap.extensions;
/*
* public class LburpConstants
*/
/**
* Contains a collection of constants used by the LBURP Classes
* in Novell LDAP extensions.
*/
public class LburpConstants {
/**
* A constant for the EndLBURPRequest OID
*/
public static final String LBURPEndReplReqOID =
"2.16.840.1.113719.1.142.100.4";
/**
* A constant for the EndLBURPResponse OID
*/
public static final String LBURPEndReplResOID =
"2.16.840.1.113719.1.142.100.5";
/**
* A constant for the LBURPOperationRequest OID
*/
public static final String LBURPOperationReqOID =
"2.16.840.1.113719.1.142.100.6";
/**
* A constant for the LBURPOperationResponse OID
*/
public static final String LBURPOperationResOID =
"2.16.840.1.113719.1.142.100.7";
/**
* A constant for the StartLBURPRequest OID
*/
public static final String LBURPStartReplReqOID =
"2.16.840.1.113719.1.142.100.1";
/**
* A constant for the StartLBURPResponse OID
*/
public static final String LBURPStartReplResOID =
"2.16.840.1.113719.1.142.100.2";
/**
* A constant for the LBURPFull Update Protocol OID
*/
public static final String LBURPFullUpdateOID =
"2.16.840.1.113719.1.142.1.4.2";
/**
* A constant for the LBURPIncremental Update Protocol OID
*/
public static final String LBURPIncUpdateOID =
"2.16.840.1.113719.1.142.1.4.1";
public LburpConstants() {}
}
/* **************************************************************************
* $OpenLDAP$
*
* Copyright (C) 1999, 2000, 2001 Novell, Inc. All Rights Reserved.
*
* THIS WORK IS SUBJECT TO U.S. AND INTERNATIONAL COPYRIGHT LAWS AND
* TREATIES. USE, MODIFICATION, AND REDISTRIBUTION OF THIS WORK IS SUBJECT
* TO VERSION 2.0.1 OF THE OPENLDAP PUBLIC LICENSE, A COPY OF WHICH IS
* AVAILABLE AT HTTP://WWW.OPENLDAP.ORG/LICENSE.HTML OR IN THE FILE "LICENSE"
* IN THE TOP-LEVEL DIRECTORY OF THE DISTRIBUTION. ANY USE OR EXPLOITATION
* OF THIS WORK OTHER THAN AS AUTHORIZED IN VERSION 2.0.1 OF THE OPENLDAP
* PUBLIC LICENSE, OR OTHER PRIOR WRITTEN CONSENT FROM NOVELL, COULD SUBJECT
* THE PERPETRATOR TO CRIMINAL AND CIVIL LIABILITY.
******************************************************************************/
package com.novell.ldap.extensions;
import com.novell.ldap.*;
import com.novell.ldap.asn1.*;
import com.novell.ldap.resources.*;
import java.io.IOException;
import java.io.ByteArrayOutputStream;
public class LburpEndRequest extends LDAPExtendedOperation {
static
{
/*
* Register the extendedresponse class which is returned by the
* server in response to a LburpEndRequest
*/
try {
LDAPExtendedResponse.register(
LburpConstants.LBURPEndReplResOID,
Class.forName(
"com.novell.ldap.extensions.LburpEndResponse"));
}catch (ClassNotFoundException e) {
System.err.println("Could not register Extended Response -" +
" Class not found");
}catch(Exception e){
e.printStackTrace();
}
}
public LburpEndRequest(int lastSeq)
throws LDAPException {
super(LburpConstants.LBURPEndReplReqOID, null);
try {
ByteArrayOutputStream encodedData = new ByteArrayOutputStream();
LBEREncoder encoder = new LBEREncoder();
ASN1Sequence asn1_lpSeq = new ASN1Sequence();
ASN1Integer asn1_lastSeq = new ASN1Integer(lastSeq);
asn1_lpSeq.add(asn1_lastSeq);
asn1_lpSeq.encode(encoder, encodedData);
setValue(encodedData.toByteArray());
}catch(IOException ioe) {
throw new LDAPException(ExceptionMessages.ENCODING_ERROR,
LDAPException.ENCODING_ERROR,(String)null);
}
}
}
/* **************************************************************************
* $OpenLDAP$
*
* Copyright (C) 1999, 2000, 2001 Novell, Inc. All Rights Reserved.
*
* THIS WORK IS SUBJECT TO U.S. AND INTERNATIONAL COPYRIGHT LAWS AND
* TREATIES. USE, MODIFICATION, AND REDISTRIBUTION OF THIS WORK IS SUBJECT
* TO VERSION 2.0.1 OF THE OPENLDAP PUBLIC LICENSE, A COPY OF WHICH IS
* AVAILABLE AT HTTP://WWW.OPENLDAP.ORG/LICENSE.HTML OR IN THE FILE "LICENSE"
* IN THE TOP-LEVEL DIRECTORY OF THE DISTRIBUTION. ANY USE OR EXPLOITATION
* OF THIS WORK OTHER THAN AS AUTHORIZED IN VERSION 2.0.1 OF THE OPENLDAP
* PUBLIC LICENSE, OR OTHER PRIOR WRITTEN CONSENT FROM NOVELL, COULD SUBJECT
* THE PERPETRATOR TO CRIMINAL AND CIVIL LIABILITY.
******************************************************************************/
package com.novell.ldap.extensions;
import com.novell.ldap.*;
import com.novell.ldap.asn1.*;
import com.novell.ldap.rfc2251.*;
import java.io.IOException;
import java.io.ByteArrayInputStream;
public class LburpEndResponse extends LDAPExtendedResponse {
public LburpEndResponse(RfcLDAPMessage rfcMessage)
throws IOException{
super(rfcMessage);
byte [] returnedValue = this.getValue();
if (returnedValue == null)
throw new IOException("No returned value");
// Create a decoder object
}
}
/* **************************************************************************
* $OpenLDAP$
*
* Copyright (C) 1999, 2000, 2001 Novell, Inc. All Rights Reserved.
*
* THIS WORK IS SUBJECT TO U.S. AND INTERNATIONAL COPYRIGHT LAWS AND
* TREATIES. USE, MODIFICATION, AND REDISTRIBUTION OF THIS WORK IS SUBJECT
* TO VERSION 2.0.1 OF THE OPENLDAP PUBLIC LICENSE, A COPY OF WHICH IS
* AVAILABLE AT HTTP://WWW.OPENLDAP.ORG/LICENSE.HTML OR IN THE FILE "LICENSE"
* IN THE TOP-LEVEL DIRECTORY OF THE DISTRIBUTION. ANY USE OR EXPLOITATION
* OF THIS WORK OTHER THAN AS AUTHORIZED IN VERSION 2.0.1 OF THE OPENLDAP
* PUBLIC LICENSE, OR OTHER PRIOR WRITTEN CONSENT FROM NOVELL, COULD SUBJECT
* THE PERPETRATOR TO CRIMINAL AND CIVIL LIABILITY.
******************************************************************************/
package com.novell.ldap.extensions;
import com.novell.ldap.*;
import com.novell.ldap.asn1.*;
import com.novell.ldap.rfc2251.*;
import com.novell.ldap.resources.*;
import java.io.IOException;
import java.io.ByteArrayOutputStream;
public class LburpOperationRequest extends LDAPExtendedOperation {
int currSize;
static
{
/*
* Register the extendedresponse class which is returned by the
* server in response to a LburpOperationResponse
*/
try {
LDAPExtendedResponse.register(
LburpConstants.LBURPOperationResOID,
Class.forName(
"com.novell.ldap.extensions.LburpOperationResponse"));
}catch (ClassNotFoundException e) {
System.err.println("Could not register Extended Response -" +
" Class not found");
}catch(Exception e){
e.printStackTrace();
}
}
public LburpOperationRequest(LDAPLburpRequest[] op,
int seqNumber)
throws LDAPException
{
super(LburpConstants.LBURPOperationReqOID, null);
try {
/* if ( (seqNumber < 1 ) )
throw new IllegalArgumentException(
ExceptionMessages.PARAM_ERROR);
*/
ByteArrayOutputStream encodedData = new ByteArrayOutputStream();
LBEREncoder encoder = new LBEREncoder();
ASN1Sequence asn1_lburpPack = new ASN1Sequence();
ASN1Integer asn1_seqNumber = new ASN1Integer(seqNumber);
asn1_lburpPack.add(asn1_seqNumber);
currSize=0;
// ASN1Sequence asn1_ldapOp = new ASN1Sequence();
ASN1Sequence asn1_ops;
ASN1OctetString asn1_dops;
ASN1SequenceOf asn1_ldapControl;
ASN1Choice asn1_ch;
ASN1Identifier asn1_tag;
ASN1Object iobj;
// while(true){
// System.out.println("op length is:" + op.length);
while((currSize < op.length) && (op[currSize]!=null) ){
ASN1Sequence asn1_ldapOp = new ASN1Sequence();
// System.out.println("\n" + currSize + "opType:" + op[currSize].opType);
switch(op[currSize].opType) {
case LDAPMessage.ADD_REQUEST:
case LDAPMessage.MODIFY_REQUEST:
case LDAPMessage.MODIFY_RDN_REQUEST:
asn1_ops = op[currSize].getRequestASN1Sequence();
asn1_ldapOp.add(asn1_ops);
break;
case LDAPMessage.DEL_REQUEST:
asn1_dops = op[currSize].getRequestASN1OcString();
asn1_tag = new ASN1Identifier(0,true,LDAPMessage.DEL_REQUEST);
asn1_ldapOp.add(asn1_dops);
break;
default:
break;
}
asn1_ldapControl=op[currSize].getControlsASN1Object();
if(asn1_ldapControl != null){
asn1_ldapOp.add(asn1_ldapControl);
}
++currSize;
asn1_lburpPack.add(asn1_ldapOp);
}
// System.out.println("\n currSize is :" + currSize);
// asn1_lburpPack.add(asn1_ldapOp);
// System.out.println("\n Now encoding..");
asn1_lburpPack.encode(encoder, encodedData);
setValue(encodedData.toByteArray());
}catch(IOException ioe) {
throw new LDAPException(ExceptionMessages.ENCODING_ERROR,
LDAPException.ENCODING_ERROR,(String)null);
}
}
}
/* **************************************************************************
* $OpenLDAP$
*
* Copyright (C) 1999, 2000, 2001 Novell, Inc. All Rights Reserved.
*
* THIS WORK IS SUBJECT TO U.S. AND INTERNATIONAL COPYRIGHT LAWS AND
* TREATIES. USE, MODIFICATION, AND REDISTRIBUTION OF THIS WORK IS SUBJECT
* TO VERSION 2.0.1 OF THE OPENLDAP PUBLIC LICENSE, A COPY OF WHICH IS
* AVAILABLE AT HTTP://WWW.OPENLDAP.ORG/LICENSE.HTML OR IN THE FILE "LICENSE"
* IN THE TOP-LEVEL DIRECTORY OF THE DISTRIBUTION. ANY USE OR EXPLOITATION
* OF THIS WORK OTHER THAN AS AUTHORIZED IN VERSION 2.0.1 OF THE OPENLDAP
* PUBLIC LICENSE, OR OTHER PRIOR WRITTEN CONSENT FROM NOVELL, COULD SUBJECT
* THE PERPETRATOR TO CRIMINAL AND CIVIL LIABILITY.
******************************************************************************/
package com.novell.ldap.extensions;
import com.novell.ldap.*;
import com.novell.ldap.asn1.*;
import com.novell.ldap.rfc2251.*;
import java.io.IOException;
import java.io.ByteArrayInputStream;
import java.io.EOFException;
import java.util.HashMap;
public class LburpOperationResponse extends LDAPExtendedResponse {
private HashMap response;
public LburpOperationResponse(RfcLDAPMessage rfcMessage)
throws IOException
{
super(rfcMessage);
int record;
String resp;
response = new HashMap(5);
byte [] returnedValue = this.getValue();
if (returnedValue == null)
throw new IOException("No returned value");
ASN1Identifier asn1ID = new ASN1Identifier();
ASN1Length asn1Len = new ASN1Length();
LBERDecoder dec = new LBERDecoder();
ASN1Object asn1 = null;
ByteArrayInputStream in = new ByteArrayInputStream(returnedValue);
try {
int[] len = new int[1];
while(true){
asn1ID.reset(in);
asn1Len.reset(in);
int length = asn1Len.getLength();
len[0] = asn1ID.getEncodedLength() +
asn1Len.getEncodedLength() +
length;
int TAG = 0x10;
ASN1Identifier ID =
new ASN1Identifier(ASN1Identifier.UNIVERSAL, true, TAG);
ASN1Object[] content;
int contentIndex = 0;
content = new ASN1Object[10];
int[] componentLen = new int[1]; // collects length of component
while(length > 0) {
content[contentIndex++] = dec.decode(in, componentLen);
length -= componentLen[0];
}
ASN1Object obj=content[0];
record = ((ASN1Integer)obj).intValue();
ASN1Tagged tval= (ASN1Tagged)content[1];
ASN1OctetString astr=(ASN1OctetString)tval.taggedValue();
byte[] bval=astr.byteValue();
ByteArrayInputStream ins = new ByteArrayInputStream(bval);
int[] compLen = new int[1];
ASN1Object asb=dec.decode(ins, compLen);
asn1ID.reset(ins);
asn1Len.reset(ins);
ASN1Object asn2=dec.decode(ins,len);
resp=((ASN1OctetString)asn2).stringValue();
if(resp.length() != 0){
response.put((Object)new Integer(record),(Object)new String(resp));
}
}
}catch(IOException ioe){
}
catch(Exception e){
e.printStackTrace();
}
}
public HashMap getResponse()
{
return response;
}
}
/* **************************************************************************
* $OpenLDAP$
*
* Copyright (C) 1999, 2000, 2001 Novell, Inc. All Rights Reserved.
*
* THIS WORK IS SUBJECT TO U.S. AND INTERNATIONAL COPYRIGHT LAWS AND
* TREATIES. USE, MODIFICATION, AND REDISTRIBUTION OF THIS WORK IS SUBJECT
* TO VERSION 2.0.1 OF THE OPENLDAP PUBLIC LICENSE, A COPY OF WHICH IS
* AVAILABLE AT HTTP://WWW.OPENLDAP.ORG/LICENSE.HTML OR IN THE FILE "LICENSE"
* IN THE TOP-LEVEL DIRECTORY OF THE DISTRIBUTION. ANY USE OR EXPLOITATION
* OF THIS WORK OTHER THAN AS AUTHORIZED IN VERSION 2.0.1 OF THE OPENLDAP
* PUBLIC LICENSE, OR OTHER PRIOR WRITTEN CONSENT FROM NOVELL, COULD SUBJECT
* THE PERPETRATOR TO CRIMINAL AND CIVIL LIABILITY.
******************************************************************************/
package com.novell.ldap.extensions;
import com.novell.ldap.*;
import com.novell.ldap.asn1.*;
import com.novell.ldap.resources.*;
import java.io.IOException;
import java.io.ByteArrayOutputStream;
public class LburpStartRequest extends LDAPExtendedOperation {
static
{
/*
* Register the extendedresponse class which is returned by the
* server in response to a LburpStartRequest
*/
try {
LDAPExtendedResponse.register(
LburpConstants.LBURPStartReplResOID,
Class.forName(
"com.novell.ldap.extensions.LburpStartResponse"));
}catch (ClassNotFoundException e) {
System.err.println("Could not register Extended Response -" +
" Class not found");
}catch(Exception e){
e.printStackTrace();
}
}
public LburpStartRequest(String lburpProtocolOID)
throws LDAPException {
super(LburpConstants.LBURPStartReplReqOID, null);
try {
if ( (lburpProtocolOID == null) )
throw new IllegalArgumentException(
ExceptionMessages.PARAM_ERROR);
ByteArrayOutputStream encodedData = new ByteArrayOutputStream();
LBEREncoder encoder = new LBEREncoder();
ASN1Sequence asn1_lpSeq = new ASN1Sequence();
ASN1OctetString asn1_lpOID = new ASN1OctetString(lburpProtocolOID);
asn1_lpSeq.add(asn1_lpOID);
asn1_lpSeq.encode(encoder, encodedData);
setValue(encodedData.toByteArray());
}catch(IOException ioe) {
throw new LDAPException(ExceptionMessages.ENCODING_ERROR,
LDAPException.ENCODING_ERROR,(String)null);
}
}
}
/* **************************************************************************
* $OpenLDAP$
*
* Copyright (C) 1999, 2000, 2001 Novell, Inc. All Rights Reserved.
*
* THIS WORK IS SUBJECT TO U.S. AND INTERNATIONAL COPYRIGHT LAWS AND
* TREATIES. USE, MODIFICATION, AND REDISTRIBUTION OF THIS WORK IS SUBJECT
* TO VERSION 2.0.1 OF THE OPENLDAP PUBLIC LICENSE, A COPY OF WHICH IS
* AVAILABLE AT HTTP://WWW.OPENLDAP.ORG/LICENSE.HTML OR IN THE FILE "LICENSE"
* IN THE TOP-LEVEL DIRECTORY OF THE DISTRIBUTION. ANY USE OR EXPLOITATION
* OF THIS WORK OTHER THAN AS AUTHORIZED IN VERSION 2.0.1 OF THE OPENLDAP
* PUBLIC LICENSE, OR OTHER PRIOR WRITTEN CONSENT FROM NOVELL, COULD SUBJECT
* THE PERPETRATOR TO CRIMINAL AND CIVIL LIABILITY.
******************************************************************************/
package com.novell.ldap.extensions;
import com.novell.ldap.*;
import com.novell.ldap.asn1.*;
import com.novell.ldap.rfc2251.*;
import java.io.IOException;
import java.io.ByteArrayInputStream;
public class LburpStartResponse extends LDAPExtendedResponse {
int tranSize;
public LburpStartResponse(RfcLDAPMessage rfcMessage)
throws IOException{
super(rfcMessage);
byte [] returnedValue = this.getValue();
if (returnedValue == null)
throw new IOException("No returned value");
// Create a decoder object
LBERDecoder decoder = new LBERDecoder();
if (decoder == null)
throw new IOException("Decoding error");
ASN1Sequence returnedSequence = (ASN1Sequence)
decoder.decode(returnedValue);
if (returnedSequence == null)
throw new IOException("Decoding error");
tranSize = ((ASN1Integer)returnedSequence.get(0)).intValue();
}
public int getTranSize()
{
return tranSize;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment