本文整理汇总了Java中com.sun.jndi.ldap.Ber类的典型用法代码示例。如果您正苦于以下问题:Java Ber类的具体用法?Java Ber怎么用?Java Ber使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Ber类属于com.sun.jndi.ldap包,在下文中一共展示了Ber类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setEncodedValue
import com.sun.jndi.ldap.Ber; //导入依赖的package包/类
private byte[] setEncodedValue(SortKey[] sortKeys) throws IOException {
// build the ASN.1 BER encoding
BerEncoder ber = new BerEncoder(30 * sortKeys.length + 10);
String matchingRule;
ber.beginSeq(Ber.ASN_SEQUENCE | Ber.ASN_CONSTRUCTOR);
for (int i = 0; i < sortKeys.length; i++) {
ber.beginSeq(Ber.ASN_SEQUENCE | Ber.ASN_CONSTRUCTOR);
ber.encodeString(sortKeys[i].getAttributeID(), true); // v3
if ((matchingRule = sortKeys[i].getMatchingRuleID()) != null) {
ber.encodeString(matchingRule, (Ber.ASN_CONTEXT | 0), true);
}
if (! sortKeys[i].isAscending()) {
ber.encodeBoolean(true, (Ber.ASN_CONTEXT | 1));
}
ber.endSeq();
}
ber.endSeq();
return ber.getTrimmedBuf();
}
示例2: encodeResponseValue
import com.sun.jndi.ldap.Ber; //导入依赖的package包/类
private byte[] encodeResponseValue(int targetPosition, int contentCount,
int virtualListViewResult) throws IOException {
// build the ASN.1 encoding
BerEncoder ber = new BerEncoder(10);
ber.beginSeq(Ber.ASN_SEQUENCE | Ber.ASN_CONSTRUCTOR);
ber.encodeInt(targetPosition); // list offset for the target entry
ber.encodeInt(contentCount); // server's estimate of the current
// number of entries in the list
ber.encodeInt(virtualListViewResult, Ber.ASN_ENUMERATED);
ber.encodeOctetString(new byte[0], Ber.ASN_OCTET_STR);
ber.endSeq();
return ber.getTrimmedBuf();
}
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:17,代码来源:VirtualListViewControlDirContextProcessorTest.java
示例3: assertEncodedResponse
import com.sun.jndi.ldap.Ber; //导入依赖的package包/类
private void assertEncodedResponse(byte[] encodedValue,
int expectedEncodingLength, int expectedTargetPosition,
int expectedContentCount, int expectedVirtualListViewResult,
byte[] expectedContextId) throws Exception {
dumpEncodedValue("VirtualListViewResponse\n", encodedValue);
assertThat(encodedValue.length).isEqualTo(expectedEncodingLength);
BerDecoder ber = new BerDecoder(encodedValue, 0, encodedValue.length);
ber.parseSeq(null);
int actualTargetPosition = ber.parseInt();
int actualContentCount = ber.parseInt();
int actualVirtualListViewResult = ber.parseEnumeration();
assertThat(actualTargetPosition).isEqualTo(expectedTargetPosition);
assertThat(actualContentCount).as("contentCount,").isEqualTo(expectedContentCount);
assertThat(actualVirtualListViewResult).isEqualTo(expectedVirtualListViewResult);
byte[] bs = ber.parseOctetString(Ber.ASN_OCTET_STR, null);
assertContextId(expectedContextId, bs);
}
开发者ID:spring-projects,项目名称:spring-ldap,代码行数:19,代码来源:VirtualListViewControlDirContextProcessorTest.java
示例4: testBerDecoding
import com.sun.jndi.ldap.Ber; //导入依赖的package包/类
@Test
public void testBerDecoding() throws Exception {
byte[] value = new byte[1];
value[0] = 8;
int pageSize = 20;
byte[] cookie = encodeValue(pageSize, value);
BerDecoder ber = new BerDecoder(cookie, 0, cookie.length);
ber.parseSeq(null);
int actualPageSize = ber.parseInt();
byte[] actualValue = ber.parseOctetString(Ber.ASN_OCTET_STR, null);
assertThat(actualPageSize).as("pageSize,").isEqualTo(20);
assertThat(actualValue.length).as("value length").isEqualTo(value.length);
for (int i = 0; i < value.length; i++) {
assertThat(actualValue[i]).as("value (index " + i + "),").isEqualTo(value[i]);
}
}
示例5: PagedResultsResponseControl
import com.sun.jndi.ldap.Ber; //导入依赖的package包/类
/**
* Constructs a paged-results response control.
*
* @param id The control's object identifier string.
* @param criticality The control's criticality.
* @param value The control's ASN.1 BER encoded value.
* It is not cloned - any changes to value
* will affect the contents of the control.
* @exception IOException If an error was encountered while decoding
* the control's value.
*/
public PagedResultsResponseControl(String id, boolean criticality,
byte[] value) throws IOException {
super(id, criticality, value);
// decode value
BerDecoder ber = new BerDecoder(value, 0, value.length);
ber.parseSeq(null);
resultSize = ber.parseInt();
cookie = ber.parseOctetString(Ber.ASN_OCTET_STR, null);
}
示例6: setEncodedValue
import com.sun.jndi.ldap.Ber; //导入依赖的package包/类
private byte[] setEncodedValue(int pageSize, byte[] cookie)
throws IOException {
// build the ASN.1 encoding
BerEncoder ber = new BerEncoder(10 + cookie.length);
ber.beginSeq(Ber.ASN_SEQUENCE | Ber.ASN_CONSTRUCTOR);
ber.encodeInt(pageSize);
ber.encodeOctetString(cookie, Ber.ASN_OCTET_STR);
ber.endSeq();
return ber.getTrimmedBuf();
}
示例7: SortResponseControl
import com.sun.jndi.ldap.Ber; //导入依赖的package包/类
/**
* Constructs a control to indicate the outcome of a sort request.
*
* @param id The control's object identifier string.
* @param criticality The control's criticality.
* @param value The control's ASN.1 BER encoded value.
* It is not cloned - any changes to value
* will affect the contents of the control.
* @exception IOException if an error is encountered
* while decoding the control's value.
*/
public SortResponseControl(String id, boolean criticality, byte[] value)
throws IOException {
super(id, criticality, value);
// decode value
BerDecoder ber = new BerDecoder(value, 0, value.length);
ber.parseSeq(null);
resultCode = ber.parseEnumeration();
if ((ber.bytesLeft() > 0) && (ber.peekByte() == Ber.ASN_CONTEXT)) {
badAttrId = ber.parseStringWithTag(Ber.ASN_CONTEXT, true, null);
}
}