本文整理汇总了Java中org.apache.directory.api.ldap.model.ldif.LdifAttributesReader.parseAttributes方法的典型用法代码示例。如果您正苦于以下问题:Java LdifAttributesReader.parseAttributes方法的具体用法?Java LdifAttributesReader.parseAttributes怎么用?Java LdifAttributesReader.parseAttributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.directory.api.ldap.model.ldif.LdifAttributesReader
的用法示例。
在下文中一共展示了LdifAttributesReader.parseAttributes方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testLdifParserRFC2849Sample3
import org.apache.directory.api.ldap.model.ldif.LdifAttributesReader; //导入方法依赖的package包/类
@Test
public void testLdifParserRFC2849Sample3() throws LdapLdifException, Exception
{
String ldif =
"objectclass: top\n"
+ "objectclass: person\n"
+ "objectclass: organizationalPerson\n"
+ "cn: Gern Jensen\n"
+ "cn: Gern O Jensen\n"
+ "sn: Jensen\n"
+ "uid: gernj\n"
+ "telephonenumber: +1 408 555 1212\n"
+ "description:: V2hhdCBhIGNhcmVmdWwgcmVhZGVyIHlvdSBhcmUhICBUaGlzIHZhbHVl\n"
+ " IGlzIGJhc2UtNjQtZW5jb2RlZCBiZWNhdXNlIGl0IGhhcyBhIGNvbnRyb2wgY2hhcmFjdG\n"
+ " VyIGluIGl0IChhIENSKS4NICBCeSB0aGUgd2F5LCB5b3Ugc2hvdWxkIHJlYWxseSBnZXQg\n"
+ " b3V0IG1vcmUu";
LdifAttributesReader reader = new LdifAttributesReader();
Attributes attributes = reader.parseAttributes( ldif );
javax.naming.directory.Attribute attr = attributes.get( "objectclass" );
assertTrue( attr.contains( "top" ) );
assertTrue( attr.contains( "person" ) );
assertTrue( attr.contains( "organizationalPerson" ) );
attr = attributes.get( "cn" );
assertTrue( attr.contains( "Gern Jensen" ) );
assertTrue( attr.contains( "Gern O Jensen" ) );
attr = attributes.get( "sn" );
assertTrue( attr.contains( "Jensen" ) );
attr = attributes.get( "uid" );
assertTrue( attr.contains( "gernj" ) );
attr = attributes.get( "telephonenumber" );
assertTrue( attr.contains( "+1 408 555 1212" ) );
attr = attributes.get( "description" );
assertTrue( attr
.contains( "What a careful reader you are! This value is base-64-encoded because it has a control character in it (a CR).\r By the way, you should really get out more."
.getBytes( StandardCharsets.UTF_8 ) ) );
reader.close();
}
示例2: testLdifParserRFC2849Sample3VariousSpacing
import org.apache.directory.api.ldap.model.ldif.LdifAttributesReader; //导入方法依赖的package包/类
@Test
public void testLdifParserRFC2849Sample3VariousSpacing() throws LdapLdifException, Exception
{
String ldif =
"objectclass:top\n"
+ "objectclass: person \n"
+ "objectclass:organizationalPerson\n"
+ "cn:Gern Jensen\n"
+ "cn:Gern O Jensen\n"
+ "sn:Jensen\n"
+ "uid:gernj\n"
+ "telephonenumber:+1 408 555 1212 \n"
+ "description:: V2hhdCBhIGNhcmVmdWwgcmVhZGVyIHlvdSBhcmUhICBUaGlzIHZhbHVl\n"
+ " IGlzIGJhc2UtNjQtZW5jb2RlZCBiZWNhdXNlIGl0IGhhcyBhIGNvbnRyb2wgY2hhcmFjdG\n"
+ " VyIGluIGl0IChhIENSKS4NICBCeSB0aGUgd2F5LCB5b3Ugc2hvdWxkIHJlYWxseSBnZXQg\n"
+ " b3V0IG1vcmUu ";
LdifAttributesReader reader = new LdifAttributesReader();
Attributes attributes = reader.parseAttributes( ldif );
javax.naming.directory.Attribute attr = attributes.get( "objectclass" );
assertTrue( attr.contains( "top" ) );
assertTrue( attr.contains( "person" ) );
assertTrue( attr.contains( "organizationalPerson" ) );
attr = attributes.get( "cn" );
assertTrue( attr.contains( "Gern Jensen" ) );
assertTrue( attr.contains( "Gern O Jensen" ) );
attr = attributes.get( "sn" );
assertTrue( attr.contains( "Jensen" ) );
attr = attributes.get( "uid" );
assertTrue( attr.contains( "gernj" ) );
attr = attributes.get( "telephonenumber" );
assertTrue( attr.contains( "+1 408 555 1212" ) );
attr = attributes.get( "description" );
assertTrue( attr
.contains( "What a careful reader you are! This value is base-64-encoded because it has a control character in it (a CR).\r By the way, you should really get out more."
.getBytes( StandardCharsets.UTF_8 ) ) );
reader.close();
}
示例3: testLdifParserRFC2849Sample4
import org.apache.directory.api.ldap.model.ldif.LdifAttributesReader; //导入方法依赖的package包/类
@Test
public void testLdifParserRFC2849Sample4() throws NamingException, Exception
{
String ldif =
"# dn:: ou=���������,o=Airius\n"
+ "objectclass: top\n"
+ "objectclass: organizationalUnit\n"
+ "ou:: 5Za25qWt6YOo\n"
+ "# ou:: ���������\n"
+ "ou;lang-ja:: 5Za25qWt6YOo\n"
+ "# ou;lang-ja:: ���������\n"
+ "ou;lang-ja;phonetic:: 44GI44GE44GO44KH44GG44G2\n"
+ "# ou;lang-ja:: ������������������\n"
+ "ou;lang-en: Sales\n"
+ "description: Japanese office\n";
LdifAttributesReader reader = new LdifAttributesReader();
Attributes attributes = reader.parseAttributes( ldif );
String[][] values =
{
{ "objectclass", "top" },
{ "objectclass", "organizationalUnit" },
{ "ou", "\u55b6\u696d\u90e8" },
{ "ou;lang-ja", "\u55b6\u696d\u90e8" },
{ "ou;lang-ja;phonetic", "\u3048\u3044\u304e\u3087\u3046\u3076" }, // 3048 = ���, 3044 = ���, 304e = ���
// 3087 = ���, 3046 = ���, 3076 = ���
{ "ou;lang-en", "Sales" },
{ "description", "Japanese office" } };
for ( int j = 0; j < values.length; j++ )
{
javax.naming.directory.Attribute attr = attributes.get( values[j][0] );
if ( attr.contains( values[j][1] ) )
{
assertTrue( true );
}
else
{
assertTrue( attr.contains( values[j][1].getBytes( StandardCharsets.UTF_8 ) ) );
}
}
reader.close();
}
示例4: testLdifAttributesReaderDirServer
import org.apache.directory.api.ldap.model.ldif.LdifAttributesReader; //导入方法依赖的package包/类
@Test
public void testLdifAttributesReaderDirServer() throws NamingException, Exception
{
String ldif =
"# -------------------------------------------------------------------\n"
+ "#\n"
+ "# Licensed to the Apache Software Foundation (ASF) under one\n"
+ "# or more contributor license agreements. See the NOTICE file\n"
+ "# distributed with this work for additional information\n"
+ "# regarding copyright ownership. The ASF licenses this file\n"
+ "# to you under the Apache License, Version 2.0 (the\n"
+ "# \"License\"); you may not use this file except in compliance\n"
+ "# with the License. You may obtain a copy of the License at\n"
+ "# \n"
+ "# http://www.apache.org/licenses/LICENSE-2.0\n"
+ "# \n"
+ "# Unless required by applicable law or agreed to in writing,\n"
+ "# software distributed under the License is distributed on an\n"
+ "# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n"
+ "# KIND, either express or implied. See the License for the\n"
+ "# specific language governing permissions and limitations\n"
+ "# under the License. \n"
+ "# \n"
+ "#\n"
+ "# EXAMPLE.COM is freely and reserved for testing according to this RFC:\n"
+ "#\n"
+ "# http://www.rfc-editor.org/rfc/rfc2606.txt\n"
+ "#\n"
+ "# -------------------------------------------------------------------\n"
+ "\n"
+ "objectclass: top\n"
+ "objectclass: organizationalunit\n"
+ "ou: Users";
LdifAttributesReader reader = new LdifAttributesReader();
Attributes attributes = reader.parseAttributes( ldif );
javax.naming.directory.Attribute attr = attributes.get( "objectclass" );
assertTrue( attr.contains( "top" ) );
assertTrue( attr.contains( "organizationalunit" ) );
attr = attributes.get( "ou" );
assertTrue( attr.contains( "Users" ) );
reader.close();
}
示例5: testLdifParserCommentsEmptyLines
import org.apache.directory.api.ldap.model.ldif.LdifAttributesReader; //导入方法依赖的package包/类
@Test
public void testLdifParserCommentsEmptyLines() throws NamingException, Exception
{
String ldif = "#\n"
+ "# Licensed to the Apache Software Foundation (ASF) under one\n"
+ "# or more contributor license agreements. See the NOTICE file\n"
+ "# distributed with this work for additional information\n"
+ "# regarding copyright ownership. The ASF licenses this file\n"
+ "# to you under the Apache License, Version 2.0 (the\n"
+ "# \"License\"); you may not use this file except in compliance\n"
+ "# with the License. You may obtain a copy of the License at\n"
+ "# \n"
+ "# http://www.apache.org/licenses/LICENSE-2.0\n"
+ "# \n"
+ "# Unless required by applicable law or agreed to in writing,\n"
+ "# software distributed under the License is distributed on an\n"
+ "# \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n"
+ "# KIND, either express or implied. See the License for the\n"
+ "# specific language governing permissions and limitations\n"
+ "# under the License. \n"
+ "# \n"
+ "#\n"
+ "#\n"
+ "# EXAMPLE.COM is freely and reserved for testing according to this RFC:\n"
+ "#\n"
+ "# http://www.rfc-editor.org/rfc/rfc2606.txt\n"
+ "#\n"
+ "#\n"
+ "\n"
+ "#\n"
+ "# This ACI allows brouse access to the root suffix and one level below that to anyone.\n"
+ "# At this level there is nothing critical exposed. Everything that matters is one or\n"
+ "# more levels below this.\n"
+ "#\n"
+ "\n"
+ "objectClass: top\n"
+ "objectClass: subentry\n"
+ "objectClass: accessControlSubentry\n"
+ "subtreeSpecification: { maximum 1 }\n"
+ "prescriptiveACI: { identificationTag \"browseRoot\", precedence 100, authenticationLevel none, itemOrUserFirst userFirst: { userClasses { allUsers }, userPermissions { { protectedItems {entry}, grantsAndDenials { grantReturnDN, grantBrowse } } } } }\n";
LdifAttributesReader reader = new LdifAttributesReader();
Attributes attributes = reader.parseAttributes( ldif );
javax.naming.directory.Attribute attr = attributes.get( "objectClass" );
assertTrue( attr.contains( "top" ) );
assertTrue( attr.contains( SchemaConstants.SUBENTRY_OC ) );
assertTrue( attr.contains( "accessControlSubentry" ) );
attr = attributes.get( "subtreeSpecification" );
assertTrue( attr.contains( "{ maximum 1 }" ) );
attr = attributes.get( "prescriptiveACI" );
assertTrue( attr
.contains( "{ identificationTag \"browseRoot\", precedence 100, authenticationLevel none, itemOrUserFirst userFirst: { userClasses { allUsers }, userPermissions { { protectedItems {entry}, grantsAndDenials { grantReturnDN, grantBrowse } } } } }" ) );
reader.close();
}