use of javax.naming.directory.BasicAttribute in project jmeter by apache.
the class LDAPSampler method getModificationItem.
/**
* This will create the Basic Attributes for the Inbuilt TestCase for Modify
* test.
*
* @return the BasicAttributes
*/
private ModificationItem[] getModificationItem() {
ModificationItem[] mods = new ModificationItem[2];
// replace (update) attribute
//$NON-NLS-1$ //$NON-NLS-2$
Attribute mod0 = new BasicAttribute("userpassword", "secret");
// add mobile phone number attribute
//$NON-NLS-1$ //$NON-NLS-2$
Attribute mod1 = new BasicAttribute("mobile", "123-456-1234");
mods[0] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, mod0);
mods[1] = new ModificationItem(DirContext.ADD_ATTRIBUTE, mod1);
return mods;
}
use of javax.naming.directory.BasicAttribute in project jmeter by apache.
the class LDAPSampler method getBasicAttributes.
/**
* This will create the Basic Attributes for the In build TestCase for Add
* Test.
*
* @return the BasicAttributes
*/
private BasicAttributes getBasicAttributes() {
BasicAttributes basicattributes = new BasicAttributes();
//$NON-NLS-1$
BasicAttribute basicattribute = new BasicAttribute("objectclass");
//$NON-NLS-1$
basicattribute.add("top");
//$NON-NLS-1$
basicattribute.add("person");
//$NON-NLS-1$
basicattribute.add("organizationalPerson");
//$NON-NLS-1$
basicattribute.add("inetOrgPerson");
basicattributes.put(basicattribute);
//$NON-NLS-1$
String s1 = "User";
//$NON-NLS-1$
String s3 = "Test";
//$NON-NLS-1$
String s5 = "user";
//$NON-NLS-1$
String s6 = "test";
COUNTER.incrementAndGet();
//$NON-NLS-1$
basicattributes.put(new BasicAttribute("givenname", s1));
//$NON-NLS-1$
basicattributes.put(new BasicAttribute("sn", s3));
//$NON-NLS-1$ //$NON-NLS-2$
basicattributes.put(new BasicAttribute("cn", "TestUser" + COUNTER.get()));
//$NON-NLS-1$
basicattributes.put(new BasicAttribute("uid", s5));
//$NON-NLS-1$
basicattributes.put(new BasicAttribute("userpassword", s6));
//$NON-NLS-1$
setProperty(new StringProperty(ADD, "cn=TestUser" + COUNTER.get()));
return basicattributes;
}
use of javax.naming.directory.BasicAttribute in project jmeter by apache.
the class LDAPExtSampler method getUserModAttributes.
/***************************************************************************
* Collect all the value from the table (Arguments), using this create the
* basicAttributes This will create the Basic Attributes for the User
* defined TestCase for Modify test
*
* @return The BasicAttributes
**************************************************************************/
private ModificationItem[] getUserModAttributes() {
ModificationItem[] mods = new ModificationItem[getLDAPArguments().getArguments().size()];
BasicAttribute attr;
PropertyIterator iter = getLDAPArguments().iterator();
int count = 0;
while (iter.hasNext()) {
LDAPArgument item = (LDAPArgument) iter.next().getObjectValue();
if ((item.getValue()).length() == 0) {
attr = new BasicAttribute(item.getName());
} else {
attr = getBasicAttribute(item.getName(), item.getValue());
}
final String opcode = item.getOpcode();
if ("add".equals(opcode)) {
// $NON-NLS-1$
mods[count++] = new ModificationItem(DirContext.ADD_ATTRIBUTE, attr);
} else if (// $NON-NLS-1$
"delete".equals(opcode) || "remove".equals(opcode)) {
// $NON-NLS-1$
mods[count++] = new ModificationItem(DirContext.REMOVE_ATTRIBUTE, attr);
} else if ("replace".equals(opcode)) {
// $NON-NLS-1$
mods[count++] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, attr);
} else {
log.warn("Invalid opCode: " + opcode);
}
}
return mods;
}
use of javax.naming.directory.BasicAttribute in project fess by codelibs.
the class FessProp method getLdapAdminRoleObjectClassAttribute.
public default default Attribute getLdapAdminRoleObjectClassAttribute() {
final Attribute oc = new BasicAttribute("objectClass");
split(getLdapAdminRoleObjectClasses(), ",").of(stream -> stream.filter(StringUtil::isNotBlank).forEach(s -> oc.add(s.trim())));
return oc;
}
use of javax.naming.directory.BasicAttribute in project cxf by apache.
the class LdapCertificateRepo method addConstantAttributes.
private void addConstantAttributes(String names, String values, Attributes attribs) {
String[] arrNames = names.split(",");
String[] arrValues = values.split(",");
if (arrNames.length != arrValues.length) {
throw new IllegalArgumentException(String.format("Inconsintent constant attributes: %s; %s", names, values));
}
for (int i = 0; i < arrNames.length; i++) {
attribs.put(new BasicAttribute(arrNames[i], arrValues[i]));
}
}
Aggregations