当前位置: 首页>>代码示例>>Java>>正文


Java Utils类代码示例

本文整理汇总了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;
    }
 
开发者ID:shannah,项目名称:cn1,代码行数:20,代码来源:ExtendedOp.java

示例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;

}
 
开发者ID:shannah,项目名称:cn1,代码行数:22,代码来源:SearchOp.java

示例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;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:18,代码来源:LdapContextImpl.java

示例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);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:20,代码来源:Filter.java

示例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);
            }
        }
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:18,代码来源:LdapResult.java

示例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());

}
 
开发者ID:shannah,项目名称:cn1,代码行数:20,代码来源:LdapAttributeTest.java

示例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));
}
 
开发者ID:shannah,项目名称:cn1,代码行数:21,代码来源:LdapAttributeTest.java

示例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);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:24,代码来源:ExtendedOpTest.java

示例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);
}
 
开发者ID:nextopio,项目名称:nextop-client,代码行数:20,代码来源:Filter.java

示例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;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:9,代码来源:CompareOp.java

示例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]);
        }
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:29,代码来源:DefaultCallbackHandler.java

示例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];
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:11,代码来源:UnsolicitedNotificationImpl.java

示例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);
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:10,代码来源:LdapAttribute.java

示例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;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:16,代码来源:LdapAttribute.java

示例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;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:16,代码来源:LdapAttribute.java


注:本文中的org.apache.harmony.jndi.provider.ldap.asn1.Utils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。