use of javax.naming.ldap.LdapName in project portfolio by buchen.
the class AboutDialog method addSignerInfo.
@SuppressWarnings("nls")
private void addSignerInfo(StringBuilder builder, Bundle b) {
Map<X509Certificate, List<X509Certificate>> certificates = b.getSignerCertificates(Bundle.SIGNERS_ALL);
if (certificates.isEmpty())
return;
builder.append(" [signed by ");
boolean isFirstCertificate = true;
for (X509Certificate cert : certificates.keySet()) {
try {
LdapName ldapDN = new LdapName(cert.getSubjectDN().getName());
for (Rdn rdn : ldapDN.getRdns()) {
if ("CN".equals(rdn.getType())) {
if (!isFirstCertificate)
builder.append(", ");
builder.append(rdn.getValue());
isFirstCertificate = false;
}
}
} catch (InvalidNameException ignore) {
// ignore
}
}
builder.append("]");
}
use of javax.naming.ldap.LdapName in project certmgr by hdecarne.
the class DNEditorController method validateAndGetDN.
private X500Principal validateAndGetDN() throws ValidationException {
LdapName ldapDN = new LdapName(this.ctlRdnEntries.getItems());
X500Principal x500DN;
try {
x500DN = X500Names.fromString(ldapDN.toString());
} catch (IllegalArgumentException e) {
throw new ValidationException(DNEditorI18N.formatSTR_MESSAGE_INVALID_DN(e.getLocalizedMessage()), e);
}
return x500DN;
}
use of javax.naming.ldap.LdapName in project jbosstools-openshift by jbosstools.
the class HumanReadableX509Certificate method getAllRDN.
private String getAllRDN(X500Principal principal) {
StringBuilder builder = new StringBuilder();
try {
LdapName ldapDN = new LdapName(principal.getName());
int i = 0;
for (Rdn rdn : ldapDN.getRdns()) {
String type = getTypeFullName(rdn.getType());
if (!StringUtils.isEmpty(type)) {
if (i++ > 0) {
builder.append(StringUtils.getLineSeparator());
}
builder.append(type).append(SEPARATOR_LABEL_VALUE).append(StringUtils.toStringOrNull(rdn.getValue()));
}
}
return builder.toString();
} catch (InvalidNameException e) {
return builder.toString();
}
}
use of javax.naming.ldap.LdapName in project activemq-artemis by apache.
the class LegacyLDAPSecuritySettingPlugin method processSearchResult.
private void processSearchResult(Map<String, Set<Role>> securityRoles, SearchResult searchResult) throws NamingException {
Attributes attrs = searchResult.getAttributes();
if (attrs == null || attrs.size() == 0) {
return;
}
LdapName searchResultLdapName = new LdapName(searchResult.getName());
logger.debug("LDAP search result : " + searchResultLdapName);
String permissionType = null;
String destination = null;
String destinationType = "unknown";
for (Rdn rdn : searchResultLdapName.getRdns()) {
if (rdn.getType().equals("cn")) {
logger.debug("\tPermission type: " + rdn.getValue());
permissionType = rdn.getValue().toString();
}
if (rdn.getType().equals("uid")) {
logger.debug("\tDestination name: " + rdn.getValue());
destination = rdn.getValue().toString();
}
if (rdn.getType().equals("ou")) {
String rawDestinationType = rdn.getValue().toString();
if (rawDestinationType.toLowerCase().contains("queue")) {
destinationType = "queue";
} else if (rawDestinationType.toLowerCase().contains("topic")) {
destinationType = "topic";
}
logger.debug("\tDestination type: " + destinationType);
}
}
logger.debug("\tAttributes: " + attrs);
Attribute attr = attrs.get(roleAttribute);
NamingEnumeration<?> e = attr.getAll();
Set<Role> roles = securityRoles.get(destination);
boolean exists = false;
if (roles == null) {
roles = new HashSet<>();
} else {
exists = true;
}
while (e.hasMore()) {
String value = (String) e.next();
LdapName ldapname = new LdapName(value);
Rdn rdn = ldapname.getRdn(ldapname.size() - 1);
String roleName = rdn.getValue().toString();
logger.debug("\tRole name: " + roleName);
Role role = new Role(roleName, // send
permissionType.equalsIgnoreCase(writePermissionValue), // consume
permissionType.equalsIgnoreCase(readPermissionValue), // createDurableQueue
permissionType.equalsIgnoreCase(adminPermissionValue), // deleteDurableQueue
permissionType.equalsIgnoreCase(adminPermissionValue), // createNonDurableQueue
permissionType.equalsIgnoreCase(adminPermissionValue), // deleteNonDurableQueue
permissionType.equalsIgnoreCase(adminPermissionValue), // manage - there is no permission from ActiveMQ 5.x that corresponds to this
false, // browse
permissionType.equalsIgnoreCase(readPermissionValue), // createAddress
permissionType.equalsIgnoreCase(adminPermissionValue), // deleteAddress
permissionType.equalsIgnoreCase(adminPermissionValue));
roles.add(role);
}
if (!exists) {
securityRoles.put(destination, roles);
}
}
use of javax.naming.ldap.LdapName in project spring-security by spring-projects.
the class FilterBasedLdapUserSearchWithSpacesTests method searchForUserWhenSpacesInBaseDnThenSuccess.
// gh-9742
@Test
public void searchForUserWhenSpacesInBaseDnThenSuccess() throws Exception {
FilterBasedLdapUserSearch locator = new FilterBasedLdapUserSearch("ou=space cadets", "(uid={0})", this.contextSource);
locator.setSearchSubtree(false);
locator.setSearchTimeLimit(0);
locator.setDerefLinkFlag(false);
DirContextOperations bob = locator.searchForUser("space cadet");
assertThat(bob.getStringAttribute("uid")).isEqualTo("space cadet");
assertThat(bob.getDn()).isEqualTo(new LdapName("uid=space cadet,ou=space cadets"));
}
Aggregations