本文整理汇总了Java中org.apache.harmony.jndi.provider.ldap.asn1.Utils类的典型用法代码示例。如果您正苦于以下问题:Java Utils类的具体用法?Java Utils怎么用?Java Utils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Utils类属于org.apache.harmony.jndi.provider.ldap.asn1包,在下文中一共展示了Utils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getExtendedResponse
import org.apache.harmony.jndi.provider.ldap.asn1.Utils; //导入依赖的package包/类
public ExtendedResponse getExtendedResponse() throws NamingException {
if (result != null && result.getResultCode() == 0
&& responseValues != null) {
String id = null;
if (responseValues[4] != null) {
id = Utils.getString((byte[]) responseValues[4]);
}
byte[] value = (byte[]) responseValues[5];
int length = 0;
if (value != null) {
length = value.length;
}
response = request.createExtendedResponse(id, value, 0, length);
}
return response;
}
示例2: encodeValues
import org.apache.harmony.jndi.provider.ldap.asn1.Utils; //导入依赖的package包/类
public void encodeValues(Object[] values) {
values[0] = Utils.getBytes(baseObject);
values[1] = ASN1Integer.fromIntValue(controls.getSearchScope());
values[2] = ASN1Integer.fromIntValue(derefAliases);
values[3] = ASN1Integer.fromIntValue((int) controls.getCountLimit());
values[4] = ASN1Integer.fromIntValue(controls.getTimeLimit());
values[5] = Boolean.valueOf(typesOnly);
values[6] = filter;
String[] attributes = controls.getReturningAttributes();
// if null, return all attributes
if (attributes == null) {
attributes = new String[0];
}
List<byte[]> list = new ArrayList<byte[]>(attributes.length);
for (String attribute : attributes) {
list.add(Utils.getBytes(attribute));
}
values[7] = list;
}
示例3: hasAttribute
import org.apache.harmony.jndi.provider.ldap.asn1.Utils; //导入依赖的package包/类
private boolean hasAttribute(Attributes attributes, String type,
String value) throws NamingException {
Attribute attr = attributes.get(type);
if (attr == null) {
return false;
}
NamingEnumeration<?> enu = attr.getAll();
while (enu.hasMore()) {
Object o = enu.next();
if (value.equalsIgnoreCase(Utils.getString(o))) {
return true;
}
}
return false;
}
示例4: encodeValues
import org.apache.harmony.jndi.provider.ldap.asn1.Utils; //导入依赖的package包/类
public void encodeValues(Object[] values) {
Object encoded;
if (value instanceof String) {
encoded = Utils.getBytes((String) value);
} else if (value instanceof AttributeTypeAndValuePair) {
AttributeTypeAndValuePair pair = (AttributeTypeAndValuePair) value;
Object[] objs = new Object[2];
objs[0] = Utils.getBytes(pair.getType());
objs[1] = pair.getValue();
if (objs[1] instanceof String) {
objs[1] = Utils.getBytes((String) objs[1]);
}
encoded = objs;
} else {
encoded = value;
}
values[0] = new ASN1ChoiceWrap.ChosenValue(index, encoded);
}
示例5: decodeValues
import org.apache.harmony.jndi.provider.ldap.asn1.Utils; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void decodeValues(Object[] values) {
resultCode = ASN1Integer.toIntValue(values[0]);
machedDN = Utils.getString((byte[]) values[1]);
errorMessage = Utils.getString((byte[]) values[2]);
if (values[3] != null) {
Collection<byte[]> list = (Collection<byte[]>) values[3];
if (list.size() != 0) {
referrals = new String[list.size()];
int index = 0;
for (byte[] bytes : list) {
referrals[index++] = Utils.getString(bytes);
}
}
}
}
示例6: test_encode_decode
import org.apache.harmony.jndi.provider.ldap.asn1.Utils; //导入依赖的package包/类
public void test_encode_decode() throws NamingException {
String id = "test";
byte[] v1 = Utils.getBytes("value1");
byte[] v2 = Utils.getBytes("value2");
byte[] v3 = Utils.getBytes("value3");
LdapAttribute attr = new LdapAttribute(id, null);
attr.add(v1);
attr.add(v2);
attr.add(v3);
ASN1TestUtils.checkEncode(attr, LdapASN1Constant.Attribute);
Object[] encoded = new Object[2];
attr.encodeValues(encoded);
LdapAttribute decoded = new LdapAttribute("", null);
decoded.decodeValues(encoded);
assertEquals(attr.getID(), decoded.getID());
}
示例7: test_convertValueToString
import org.apache.harmony.jndi.provider.ldap.asn1.Utils; //导入依赖的package包/类
public void test_convertValueToString() throws Exception {
LdapAttribute attr = new LdapAttribute();
// do nothing
attr.convertValueToString();
BasicAttribute basicAttribute = new BasicAttribute("cn");
attr = new LdapAttribute(basicAttribute, null);
// do nothing
attr.convertValueToString();
attr.add(Utils.getBytes("test"));
attr.add(Utils.getBytes("binary"));
attr.convertValueToString();
assertEquals(2, attr.size());
assertEquals("test", attr.get(0));
assertEquals("binary", attr.get(1));
}
示例8: test_getExtendedResponse
import org.apache.harmony.jndi.provider.ldap.asn1.Utils; //导入依赖的package包/类
public void test_getExtendedResponse() throws Exception {
MockExtendedRequest mockRequest = new MockExtendedRequest();
ExtendedOp op = new ExtendedOp(mockRequest);
assertSame(mockRequest, op.getExtendedRequest());
assertNull(op.getExtendedResponse());
Object[] values = new Object[] { ASN1Integer.fromIntValue(0),
Utils.getBytes(""), Utils.getBytes(""), null,
Utils.getBytes("hello"), Utils.getBytes("world") };
op.decodeValues(values);
LdapResult result = op.getResult();
assertNotNull(result);
assertEquals(0, result.getResultCode());
assertEquals("", result.getMachedDN());
assertEquals("", result.getErrorMessage());
assertNull(result.getReferrals());
ExtendedResponse response = op.getExtendedResponse();
assertTrue(response instanceof MockExtendedResponse);
}
示例9: encodeValues
import org.apache.harmony.jndi.provider.ldap.asn1.Utils; //导入依赖的package包/类
public void encodeValues(Object[] values) {
Object encoded;
if (value instanceof String) {
encoded = Utils.getBytes((String) value);
} else if (value instanceof AttributeTypeAndValuePair) {
AttributeTypeAndValuePair pair = (AttributeTypeAndValuePair) value;
Object[] objs = new Object[2];
objs[0] = Utils.getBytes(pair.getType());
objs[1] = pair.getValue();
if (objs[1] instanceof String) {
objs[1] = Utils.getBytes((String) objs[1]);
}
encoded = objs;
} else {
encoded = value;
}
values[0] = new ChosenValue(index, encoded);
}
示例10: encodeValues
import org.apache.harmony.jndi.provider.ldap.asn1.Utils; //导入依赖的package包/类
public void encodeValues(Object[] values) {
values[0] = Utils.getBytes(entry);
Object[] objs = new Object[2];
objs[0] = Utils.getBytes(ava.getType());
objs[1] = ava.getValue();
// FIXME: convert according to schema
values[1] = objs;
}
示例11: handle
import org.apache.harmony.jndi.provider.ldap.asn1.Utils; //导入依赖的package包/类
public void handle(Callback[] callbacks) throws java.io.IOException,
UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
if (callbacks[i] instanceof RealmChoiceCallback) {
// TODO what to do here?
// RealmChoiceCallback rcc = (RealmChoiceCallback) callbacks[i];
} else if (callbacks[i] instanceof RealmCallback) {
RealmCallback rc = (RealmCallback) callbacks[i];
if (env.get(JAVA_NAMING_SECURITY_SASL_REALM) != null) {
realm = (String) env.get(JAVA_NAMING_SECURITY_SASL_REALM);
rc.setText(realm);
} else {
rc.setText(realm);
}
} else if (callbacks[i] instanceof PasswordCallback) {
PasswordCallback pc = (PasswordCallback) callbacks[i];
pc.setPassword(Utils.getCharArray(env
.get(Context.SECURITY_CREDENTIALS)));
} else if (callbacks[i] instanceof NameCallback) {
//authentication Id
NameCallback nc = (NameCallback) callbacks[i];
nc.setName((String) env.get(Context.SECURITY_PRINCIPAL));
} else {
throw new UnsupportedCallbackException(callbacks[i]);
}
}
}
示例12: decodeValues
import org.apache.harmony.jndi.provider.ldap.asn1.Utils; //导入依赖的package包/类
public void decodeValues(Object[] values) {
result = new LdapResult();
result.decodeValues(values);
if (values[4] != null) {
oid = Utils.getString(values[4]);
}
if (values[5] != null) {
encodedValue = (byte[]) values[5];
}
}
示例13: decodeValues
import org.apache.harmony.jndi.provider.ldap.asn1.Utils; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void decodeValues(Object[] vs) {
byte[] type = (byte[]) vs[0];
attrID = Utils.getString(type);
Collection<byte[]> list = (Collection<byte[]>) vs[1];
for (byte[] bs : list) {
add(bs);
}
}
示例14: encodeValues
import org.apache.harmony.jndi.provider.ldap.asn1.Utils; //导入依赖的package包/类
public void encodeValues(Object[] vs) {
vs[0] = Utils.getBytes(attrID);
List<Object> list = new ArrayList<Object>(this.values.size());
for (Object object : this.values) {
if (object instanceof String) {
String str = (String) object;
object = Utils.getBytes(str);
}
list.add(object);
}
vs[1] = list;
}
示例15: convertValueToString
import org.apache.harmony.jndi.provider.ldap.asn1.Utils; //导入依赖的package包/类
public void convertValueToString() {
// values can't be null
if (values.size() == 0) {
return;
}
Vector<Object> newValues = new Vector<Object>(values.size());
for (Iterator<Object> iter = values.iterator(); iter.hasNext();) {
Object value = iter.next();
newValues.add(Utils.getString(value));
}
values.clear();
values = newValues;
}