List of usage examples for javax.naming.ldap LdapName LdapName
public LdapName(List<Rdn> rdns)
From source file:example.springdata.ldap.PersonRepositoryIntegrationTests.java
/** * Find a {@link Person} by its Id that is a full DN. * * @throws InvalidNameException/*w w w .j av a 2s . c o m*/ */ @Test public void findOneByName() throws InvalidNameException { Optional<Person> person = personRepository .findById(new LdapName("uid=bob,ou=people,dc=springframework,dc=org")); assertThat(person).hasValueSatisfying(it -> { assertThat(it.getFullName()).isEqualTo("Bob Hamilton"); assertThat(it.getLastname()).isEqualTo("Hamilton"); assertThat(it.getUid()).isEqualTo("bob"); }); }
From source file:ldap.Entry.java
public Entry(SearchResult result) throws InvalidNameException { this(new LdapName(result.getNameInNamespace()), result.getAttributes()); }
From source file:com.evolveum.midpoint.prism.match.DistinguishedNameMatchingRule.java
@Override public boolean match(String a, String b) throws SchemaException { if (StringUtils.isBlank(a) && StringUtils.isBlank(b)) { return true; }//from w ww .j a v a 2s.co m if (StringUtils.isBlank(a) || StringUtils.isBlank(b)) { return false; } LdapName dnA; try { dnA = new LdapName(a); } catch (InvalidNameException e) { throw new SchemaException("String '" + a + "' is not a DN: " + e.getMessage(), e); } LdapName dnB; try { dnB = new LdapName(b); } catch (InvalidNameException e) { throw new SchemaException("String '" + b + "' is not a DN: " + e.getMessage(), e); } return dnA.equals(dnB); }
From source file:fr.mtlx.odm.ClassAssistant.java
public LdapName getIdentifier(Object object) { String identifier = metadata.getIdentifierPropertyName(); try {/*from w w w . j a va 2 s . com*/ return new LdapName(getProperty(object, identifier)); } catch (InvalidNameException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { throw new RuntimeException(e); } }
From source file:ldap.Entry.java
public Entry(Name name, Attribute[] atts) throws InvalidNameException { this(new LdapName(name.toString()), makeAtts(atts)); }
From source file:fr.mtlx.odm.it.TestIT.java
@Test public void test() throws InvalidNameException { Person person = new Person(); person.setCommonName("foo"); person.setSurname("bar"); person.setDn(new LdapName("cn=foo")); session.getOperations(Person.class).bind(person); }
From source file:fi.laverca.util.X509Util.java
/** * Parse the given RND type from the given certificate's subject * @param cert Certificate// w w w . j av a 2s .com * @param rdnType RND type * @return parsed value as String */ public static String parseSubjectName(final X509Certificate cert, final String rdnType) { String dn = cert.getSubjectX500Principal().getName(); String name = null; try { LdapName ldapDn = new LdapName(dn); List<Rdn> rdns = ldapDn.getRdns(); for (Rdn r : rdns) { if (rdnType.equals(r.getType())) { name = r.getValue().toString(); } } } catch (InvalidNameException e) { log.error(e); } return name; }
From source file:org.apache.syncope.core.sync.LDAPDomainSyncActions.java
@Override public <T extends AbstractAttributableTO> SyncDelta beforeCreate(SyncResultsHandler srh, SyncDelta sd, T t) throws JobExecutionException { if (!ObjectClass.ACCOUNT_NAME.equals(sd.getObject().getObjectClass().toString())) { if (t != null) { LOG.debug("CREATION OF A NEW USER"); String rdn = "/"; ConnectorObject conn = sd.getObject(); try { LdapName dn = new LdapName(conn.getAttributeByName(Name.NAME).getValue().toString() .replace("[", "").replace("]", "")); if (dn.size() == 4) { rdn = dn.getRdn(2).getValue().toString(); } else { rdn = "/"; }/*from www. j a v a2s . co m*/ } catch (InvalidNameException ex) { LOG.error("ERROR CONSTRUCTING LDAP DN FROM NAME ATTRIBUTE: ".concat(ex.getMessage())); } //Creation of new attribute to assign to new user in Syncope AttributeTO domain = new AttributeTO(); domain.setSchema("domain"); domain.addValue(rdn); t.addAttribute(domain); } else { LOG.error("SUBJECT OF SYNCHRONIZATION IS NULL"); } } return sd; }
From source file:ldap.Entry.java
public Entry(Name name, Attributes atts) throws InvalidNameException { this(new LdapName(name.toString()), atts); }
From source file:com.evolveum.midpoint.prism.match.DistinguishedNameMatchingRule.java
@Override public String normalize(String original) throws SchemaException { if (StringUtils.isBlank(original)) { return null; }/*from w ww . j a v a 2s. com*/ LdapName dn; try { dn = new LdapName(original); } catch (InvalidNameException e) { throw new SchemaException("String '" + original + "' is not a DN: " + e.getMessage(), e); } return StringUtils.lowerCase(dn.toString()); }