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


Java BasicControl类代码示例

本文整理汇总了Java中javax.naming.ldap.BasicControl的典型用法代码示例。如果您正苦于以下问题:Java BasicControl类的具体用法?Java BasicControl怎么用?Java BasicControl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BasicControl类属于javax.naming.ldap包,在下文中一共展示了BasicControl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convertControls

import javax.naming.ldap.BasicControl; //导入依赖的package包/类
protected static BasicControl[] convertControls( final ChaiRequestControl[] controls )
{
    if ( controls == null )
    {
        return null;
    }

    final BasicControl[] newControls = new BasicControl[controls.length];
    for ( int i = 0; i < controls.length; i++ )
    {
        newControls[i] = new BasicControl(
                controls[i].getId(),
                controls[i].isCritical(),
                controls[i].getValue()
        );
    }
    return newControls;
}
 
开发者ID:ldapchai,项目名称:ldapchai,代码行数:19,代码来源:JNDIProviderImpl.java

示例2: toJndiControl

import javax.naming.ldap.BasicControl; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public javax.naming.ldap.Control toJndiControl( Control control ) throws EncoderException
{
    CodecControl<? extends Control> decorator = newControl( control );
    ByteBuffer bb = ByteBuffer.allocate( decorator.computeLength() );
    decorator.encode( bb );
    bb.flip();

    return new BasicControl( control.getOid(), control.isCritical(), bb.array() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:14,代码来源:DefaultLdapCodecService.java

示例3: testBasicControl

import javax.naming.ldap.BasicControl; //导入依赖的package包/类
/**
 * <p>
 * Test method for 'javax.naming.ldap.BasicControl.BasicControl'
 * </p>
 */
public void testBasicControl() {
    // no exceptions expected
    new BasicControl(null);
    new BasicControl("");
    new BasicControl("1.2.3.333");
    new BasicControl("", true, null);
    new BasicControl("", false, new byte[0]);
    new BasicControl(null, false, null);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:15,代码来源:BasicControlTest.java

示例4: testGetID

import javax.naming.ldap.BasicControl; //导入依赖的package包/类
/**
 * @tests javax.naming.ldap.BasicControl#getID()
 */
public void testGetID() {
    String ID = "somestring";
    assertSame(ID, new BasicControl(ID).getID());

    assertNull(new BasicControl(null).getID());

    assertNull(new BasicControl(null, false, new byte[1]).getID());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:12,代码来源:BasicControlTest.java

示例5: LdapControl

import javax.naming.ldap.BasicControl; //导入依赖的package包/类
public void test_encodeValues_$LObject() {
    LdapControl control = new LdapControl(new BasicControl("id", true,
            new byte[10]));
    ASN1TestUtils.checkEncode(control, LdapASN1Constant.Control);
    
    //controlValue is optional, so it could be null
    control = new LdapControl(new BasicControl("id2", false, null));
    ASN1TestUtils.checkEncode(control, LdapASN1Constant.Control);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:10,代码来源:LdapControlTest.java

示例6: writeStringAttributes

import javax.naming.ldap.BasicControl; //导入依赖的package包/类
public final void writeStringAttributes(
        final String entryDN,
        final Map<String, String> attributeValueProps,
        final boolean overwrite,
        final BasicControl[] controls
)
        throws ChaiUnavailableException, ChaiOperationException
{
    activityPreCheck();
    getInputValidator().writeStringAttributes( entryDN, attributeValueProps, overwrite );

    // Determine the modification type, if replace, only replace on the first attribute, the rest just get added.
    final int modType = overwrite ? DirContext.REPLACE_ATTRIBUTE : DirContext.ADD_ATTRIBUTE;

    // Create the ModificationItem
    final List<ModificationItem> modificationItems = new ArrayList<>();
    for ( final Map.Entry<String, String> entry : attributeValueProps.entrySet() )
    {
        // Create a BasicAttribute for the object.
        final BasicAttribute attributeToReplace = new BasicAttribute( entry.getKey(), entry.getValue() );

        // Populate the ModificationItem object with the flag & the attribute to replace.
        modificationItems.add( new ModificationItem( modType, attributeToReplace ) );
    }

    // convert to array
    final ModificationItem[] modificationItemArray = modificationItems.toArray( new ModificationItem[modificationItems.size()] );

    // get ldap connection
    final LdapContext ldapConnection = getLdapConnection();

    // Modify the Attributes.
    try
    {
        ldapConnection.modifyAttributes( addJndiEscape( entryDN ), modificationItemArray );
    }
    catch ( NamingException e )
    {
        convertNamingException( e );
    }
}
 
开发者ID:ldapchai,项目名称:ldapchai,代码行数:42,代码来源:JNDIProviderImpl.java

示例7: decodeValues

import javax.naming.ldap.BasicControl; //导入依赖的package包/类
public void decodeValues(Object[] values) {
    String id = Utils.getString((byte[]) values[0]);
    boolean isCritical = ((Boolean) values[1]).booleanValue();
    byte[] encoded = (byte[]) values[2];
    control = new BasicControl(id, isCritical, encoded);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:7,代码来源:LdapControl.java

示例8: test_setRequestControls

import javax.naming.ldap.BasicControl; //导入依赖的package包/类
public void test_setRequestControls() throws Exception {
    MockLdapClient client = new MockLdapClient();
    Hashtable<Object, Object> env = new Hashtable<Object, Object>();
    env.put(Context.REFERRAL, "follow");
    context = new LdapContextImpl(client, env, "cn=test");

    context.setRequestControls(null);
    assertNull(context.getRequestControls());

    Control[] controls = new Control[] { new BasicControl("0"),
            new BasicControl("1"), new BasicControl("2"),
            new BasicControl("3") };

    context.setRequestControls(controls);

    Control[] actual = context.getRequestControls();

    assertEquals(controls.length, actual.length);
    assertNotSame(controls, actual);

    // Context.REFERRAL is 'ignore' add ManageDsaIT Control
    env.put(Context.REFERRAL, "ignore");
    context = new LdapContextImpl(client, env, "cn=test");
    context.setRequestControls(null);
    actual = context.getRequestControls();
    assertEquals(1, actual.length);
    assertEquals("2.16.840.1.113730.3.4.2", actual[0].getID());
    assertNull(actual[0].getEncodedValue());
    assertFalse(actual[0].isCritical());

    context.setRequestControls(controls);
    actual = context.getRequestControls();
    assertEquals(controls.length + 1, actual.length);

    // Context.REFERRAL is 'ignore', add ManageDsaIT Control
    context = new LdapContextImpl(client, new Hashtable<Object, Object>(),
            "cn=test");
    context.setRequestControls(null);
    actual = context.getRequestControls();
    assertEquals(1, actual.length);
    assertEquals("2.16.840.1.113730.3.4.2", actual[0].getID());
    assertNull(actual[0].getEncodedValue());
    assertFalse(actual[0].isCritical());

    context.setRequestControls(controls);
    actual = context.getRequestControls();
    assertEquals(controls.length + 1, actual.length);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:49,代码来源:LdapContextImplTest.java

示例9: testRdnStringObject007

import javax.naming.ldap.BasicControl; //导入依赖的package包/类
/**
 * <p>
 * Test method for 'javax.naming.ldap.Rdn.Rdn(String, Object)'
 * </p>
 * <p>
 * This is a test for the constructor of the class Rdn. Here we are testing
 * with a non-null String and a non-null object but the type here has a
 * special character like "+", which should be permited.
 * </p>
 * <p>
 * The expected result is an instance not null of Rdn.
 * </p>
 */
public void testRdnStringObject007() throws Exception {
    new Rdn("y=asd+t=test", "a=asd");
    new Rdn("y=asd", "a=asd+t=test");
    new Rdn("t", new ArrayList());
    new Rdn("t=t=t", new Object());
    new Rdn("t=t=t", "test");
    new Rdn("t", new BasicControl("test"));
}
 
开发者ID:shannah,项目名称:cn1,代码行数:22,代码来源:RdnTest.java

示例10: testGetEncodedValue

import javax.naming.ldap.BasicControl; //导入依赖的package包/类
/**
 * <p>
 * Test method for 'javax.naming.ldap.BasicControl.getEncodedValue()'
 * </p>
 * <p>
 * Here we are testing the return method of the encoded value of
 * BasicControl. In this case we send an encoded value null.
 * </p>
 * <p>
 * The expected result is a null encoded value.
 * </p>
 */
public void testGetEncodedValue() {
    assertNull(new BasicControl("control", true, null).getEncodedValue());

    // spec says the byte[] is NOT copied
    byte[] test = new byte[15];
    BasicControl bc = new BasicControl("control", true, test);
    assertSame(test, bc.getEncodedValue());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:21,代码来源:BasicControlTest.java

示例11: testRdnStringObject007

import javax.naming.ldap.BasicControl; //导入依赖的package包/类
/**
 * <p>
 * Test method for 'javax.naming.ldap.Rdn.Rdn(String, Object)'
 * </p>
 * <p>
 * This is the test method for the constructor of the class Rdn, in this
 * case we are testing to construct an Rdn from the given String and Object.
 * Here we are testing if we send a non null String with a non null object
 * but the type here has a special character like "+" this must be permited.
 * </p>
 * <p>
 * The expected result is an instance not null of Rdn.
 * </p>
 */
public void testRdnStringObject007() throws Exception {
    new Rdn("y=asd+t=test", "a=asd");
    new Rdn("y=asd", "a=asd+t=test");
    new Rdn("t", new ArrayList());
    new Rdn("t=t=t", new Object());
    new Rdn("t=t=t", "test");
    new Rdn("t", new BasicControl("test"));
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:23,代码来源:RdnTest.java

示例12: testRdnStringObject018

import javax.naming.ldap.BasicControl; //导入依赖的package包/类
/**
 * <p>
 * Test method for 'javax.naming.ldap.Rdn.Rdn(String, Object)'
 * </p>
 * <p>
 * This is a test for the constructor of the class Rdn. Here we are testing
 * with a non-empty String and different objects.
 * </p>
 * <p>
 * The expected result is an instance of the class with the different
 * arguments because the arguments are not parsed.
 * </p>
 */
public void testRdnStringObject018() throws Exception {
    new Rdn(new String("t===T"), new ArrayList());
    new Rdn(new String("t=+=T"), new Object());
    new Rdn(new String("t=,33,=T"), new BasicControl("test"));
}
 
开发者ID:shannah,项目名称:cn1,代码行数:19,代码来源:RdnTest.java

示例13: testRdnStringObject019

import javax.naming.ldap.BasicControl; //导入依赖的package包/类
/**
 * <p>
 * Test method for 'javax.naming.ldap.Rdn.Rdn(String, Object)'
 * </p>
 * <p>
 * This is a test for the constructor of the class Rdn. Here we are testing
 * with a non-empty String and different objects.
 * </p>
 * <p>
 * The expected result is an instance of the class with the different
 * arguments because the arguments are not parsed.
 * </p>
 */
public void testRdnStringObject019() throws Exception {
    new Rdn(new String("t===T"), new char[] { 'a', 'v' });
    new Rdn(new String("t=+=T"), new int[] { 1, 2, 3 });
    new Rdn(new String("t=,33,=T"), new BasicControl("test"));
}
 
开发者ID:shannah,项目名称:cn1,代码行数:19,代码来源:RdnTest.java

示例14: testRdnStringObject018

import javax.naming.ldap.BasicControl; //导入依赖的package包/类
/**
 * <p>
 * Test method for 'javax.naming.ldap.Rdn.Rdn(String, Object)'
 * </p>
 * <p>
 * This is the test method for the constructor of the class Rdn, in this
 * case we are testing to construct an Rdn from the given String and Object.
 * Here we are testing if we send a non empty String and this one not ok
 * with diferents objects.
 * </p>
 * <p>
 * The expected result is an instance of the class with the diferents
 * arguments because the arguments are not parsed.
 * </p>
 */
public void testRdnStringObject018() throws Exception {
    new Rdn(new String("t===T"), new ArrayList());
    new Rdn(new String("t=+=T"), new Object());
    new Rdn(new String("t=,33,=T"), new BasicControl("test"));
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:21,代码来源:RdnTest.java

示例15: testRdnStringObject019

import javax.naming.ldap.BasicControl; //导入依赖的package包/类
/**
 * <p>
 * Test method for 'javax.naming.ldap.Rdn.Rdn(String, Object)'
 * </p>
 * <p>
 * This is the test method for the constructor of the class Rdn, in this
 * case we are testing to construct an Rdn from the given String and Object.
 * Here we are testing if we send a non empty String and this one not ok
 * with diferents objects.
 * </p>
 * <p>
 * The expected result is an instance of the class with the diferents
 * arguments because the arguments are not parsed.
 * </p>
 */
public void testRdnStringObject019() throws Exception {
    new Rdn(new String("t===T"), new char[] { 'a', 'v' });
    new Rdn(new String("t=+=T"), new int[] { 1, 2, 3 });
    new Rdn(new String("t=,33,=T"), new BasicControl("test"));
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:21,代码来源:RdnTest.java


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