Skip to content

Commit

Permalink
fix: fix schema and update ldap samples (#6024)
Browse files Browse the repository at this point in the history
* fix: failed to search session by deviceSecret if DB is PostgreSQL #6012

* feat: update LDAP samples

---------

Co-authored-by: Yuriy Movchan <Yuriy.Movchan@gmail.com>
  • Loading branch information
yuremm and yurem authored Sep 13, 2023
1 parent d2a0b56 commit beabaef
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import io.jans.orm.ldap.model.SimpleClient;
import io.jans.orm.ldap.model.SimpleSession;
import io.jans.orm.ldap.model.SimpleTokenLdap;
import io.jans.orm.ldap.persistence.LdapEntryManagerSample;
import io.jans.orm.model.BatchOperation;
import io.jans.orm.model.DefaultBatchOperation;
import io.jans.orm.model.ProcessBatchOperation;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.status.StatusLogger;
import io.jans.orm.ldap.impl.LdapEntryManager;
import io.jans.orm.ldap.persistence.LdapEntryManagerSample;
import io.jans.orm.model.base.DeletableEntity;
import io.jans.orm.search.filter.Filter;

Expand Down
31 changes: 19 additions & 12 deletions jans-orm/ldap-sample/src/main/java/io/jans/orm/ldap/LdapSample.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,30 @@

package io.jans.orm.ldap;

import java.util.Arrays;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import io.jans.orm.ldap.impl.LdapEntryManager;
import io.jans.orm.ldap.model.SimpleAttribute;
import io.jans.orm.ldap.model.SimpleGrant;
import io.jans.orm.ldap.model.SimpleSession;
import io.jans.orm.ldap.model.SimpleUser;
import io.jans.orm.ldap.persistence.LdapEntryManagerSample;
import io.jans.orm.model.PagedResult;
import io.jans.orm.model.SearchScope;
import io.jans.orm.model.SortOrder;
import io.jans.orm.model.base.CustomObjectAttribute;
import io.jans.orm.search.filter.Filter;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.status.StatusLogger;

import java.util.List;

/**
* @author Yuriy Movchan Date: 11/03/2016
*/
public final class LdapSample {

private static final Logger LOG;

static {
StatusLogger.getLogger().setLevel(Level.OFF);
LoggingHelper.configureConsoleAppender();
LOG = Logger.getLogger(LdapSample.class);
}
private static final Logger LOG = LoggerFactory.getLogger(LdapSample.class);

private LdapSample() {
}
Expand All @@ -45,6 +41,17 @@ public static void main(String[] args) {
// Create LDAP entry manager
LdapEntryManager ldapEntryManager = ldapEntryManagerSample.createLdapEntryManager();

SimpleUser newUser = new SimpleUser();
newUser.setDn(String.format("inum=%s,ou=people,o=jans", System.currentTimeMillis()));
newUser.setUserId("sample_user_" + System.currentTimeMillis());
newUser.setUserPassword("pwd");
newUser.getCustomAttributes().add(new CustomObjectAttribute("address", Arrays.asList("London", "Texas", "Kiev")));
newUser.getCustomAttributes().add(new CustomObjectAttribute("transientId", "transientId"));
ldapEntryManager.persist(newUser);

SimpleUser dummyUser = ldapEntryManager.find(SimpleUser.class, newUser.getDn());
LOG.info("Dummy User '{}'", dummyUser);

// Find all users which have specified object classes defined in SimpleUser
List<SimpleUser> users = ldapEntryManager.findEntries("o=jans", SimpleUser.class, null);
for (SimpleUser user : users) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.apache.logging.log4j.status.StatusLogger;
import io.jans.orm.ldap.impl.LdapEntryManager;
import io.jans.orm.ldap.model.SimpleSessionState;
import io.jans.orm.ldap.persistence.LdapEntryManagerSample;

/**
* @author Yuriy Movchan Date: 01/25/2016
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import io.jans.orm.exception.EntryPersistenceException;
import io.jans.orm.ldap.impl.LdapEntryManager;
import io.jans.orm.ldap.model.SimpleSessionState;
import io.jans.orm.ldap.persistence.LdapEntryManagerSample;

/**
* @author Yuriy Movchan Date: 03/09/2020
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.jans.orm.ldap.impl.LdapEntryManager;
import io.jans.orm.ldap.model.SimpleUser;
import io.jans.orm.ldap.persistence.LdapEntryManagerSample;
import io.jans.orm.search.filter.Filter;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.Level;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.apache.logging.log4j.status.StatusLogger;
import io.jans.orm.ldap.impl.LdapEntryManager;
import io.jans.orm.ldap.model.MailUniquenessConfiguration;
import io.jans.orm.ldap.persistence.LdapEntryManagerSample;

/**
* @author Yuriy Movchan Date: 11/03/2016
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Copyright (c) 2020, Janssen Project
*/

package io.jans.orm.ldap;
package io.jans.orm.ldap.persistence;

import java.util.Properties;

Expand All @@ -24,7 +24,7 @@ private Properties getSampleConnectionProperties() {
Properties connectionProperties = new Properties();

connectionProperties.put("ldap#bindDN", "cn=Directory Manager");
connectionProperties.put("ldap#bindPassword", "secret");
connectionProperties.put("ldap#bindPassword", "Secret1!");
connectionProperties.put("ldap#servers", "localhost:1636");
connectionProperties.put("ldap#useSSL", "true");
connectionProperties.put("ldap#maxconnections", "3");
Expand Down

0 comments on commit beabaef

Please sign in to comment.