diff --git a/jans-orm/couchbase-sample/src/main/java/io/jans/orm/couchbase/CouchbaseAuthenticationSample.java b/jans-orm/couchbase-sample/src/main/java/io/jans/orm/couchbase/CouchbaseAuthenticationSample.java new file mode 100644 index 00000000000..726cc650458 --- /dev/null +++ b/jans-orm/couchbase-sample/src/main/java/io/jans/orm/couchbase/CouchbaseAuthenticationSample.java @@ -0,0 +1,52 @@ +/* + * Janssen Project software is available under the Apache License (2004). See http://www.apache.org/licenses/ for full text. + * + * Copyright (c) 2020, Janssen Project + */ + +package io.jans.orm.couchbase; + +import java.util.List; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import io.jans.orm.couchbase.impl.CouchbaseEntryManager; +import io.jans.orm.couchbase.operation.impl.CouchbaseConnectionProvider; +import io.jans.orm.model.base.SimpleUser; +import io.jans.orm.search.filter.Filter; + +/** + * @author Yuriy Movchan Date: 11/03/2016 + */ +public final class CouchbaseAuthenticationSample { + + private static final Logger LOG = LoggerFactory.getLogger(CouchbaseConnectionProvider.class); + + private CouchbaseAuthenticationSample() { + } + + public static void main(String[] args) { + // Prepare sample connection details + CouchbaseEntryManagerSample couchbaseEntryManagerSample = new CouchbaseEntryManagerSample(); + + // Create Couchbase entry manager + CouchbaseEntryManager couchbaseEntryManager = couchbaseEntryManagerSample.createCouchbaseEntryManager(); + + List users = couchbaseEntryManager.findEntries("ou=people,o=gluu", SimpleUser.class, null); + for (SimpleUser user : users) { + LOG.info("User with uid: '{}' with DN: '{}'", user.getUserId(), user.getDn()); + } + + boolean authenticated = couchbaseEntryManager.authenticate("ou=people,o=gluu", SimpleUser.class, "test_user", "test_user_password"); + LOG.info("User with uid: '{}' with DN: '{}'", "test_user", authenticated); + + Filter userUidFilter = Filter.createEqualityFilter(Filter.createLowercaseFilter("uid"), "test_user"); + List foundUsers = couchbaseEntryManager.findEntries("ou=people,o=gluu", SimpleUser.class, userUidFilter); + if (foundUsers.size() > 0) { + SimpleUser user = foundUsers.get(0); + LOG.info("Found uid: '{}' with custom attributes: '{}'", user.getUserId(), user.getCustomAttributes()); + } + } + +} \ No newline at end of file diff --git a/jans-orm/couchbase/src/main/java/io/jans/orm/couchbase/impl/CouchbaseEntryManager.java b/jans-orm/couchbase/src/main/java/io/jans/orm/couchbase/impl/CouchbaseEntryManager.java index 69c9d1a6581..186af2cd01a 100644 --- a/jans-orm/couchbase/src/main/java/io/jans/orm/couchbase/impl/CouchbaseEntryManager.java +++ b/jans-orm/couchbase/src/main/java/io/jans/orm/couchbase/impl/CouchbaseEntryManager.java @@ -88,12 +88,6 @@ protected CouchbaseEntryManager(CouchbaseOperationService operationService) { protected Integer getExpirationValue(Object entry, Class entryClass, boolean merge) { Integer value = super.getExpirationValue(entry, entryClass, merge); - // if expiration is more then 30 days we must convert it to absolute Unit time stamp to avoid immediate expiration https://docs.couchbase.com/java-sdk/current/concept-docs/documents.html#setting-document-expiration - if (value != null && value >= EXPIRATION_30_DAYS) { - final int now = (int) (System.currentTimeMillis() / 1000); - value = now + value; - } - return value; } diff --git a/jans-orm/sql-sample/src/main/java/io/jans/orm/sql/SqlCheckGroupSample.java b/jans-orm/sql-sample/src/main/java/io/jans/orm/sql/SqlCheckGroupSample.java new file mode 100644 index 00000000000..72d530c67ce --- /dev/null +++ b/jans-orm/sql-sample/src/main/java/io/jans/orm/sql/SqlCheckGroupSample.java @@ -0,0 +1,42 @@ +/* + * Janssen Project software is available under the Apache License (2004). See http://www.apache.org/licenses/ for full text. + * + * Copyright (c) 2020, Janssen Project + */ + +package io.jans.orm.sql; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import io.jans.orm.search.filter.Filter; +import io.jans.orm.sql.impl.SqlEntryManager; +import io.jans.orm.sql.model.SimpleGroup; +import io.jans.orm.sql.operation.impl.SqlConnectionProvider; +import io.jans.orm.sql.persistence.SqlEntryManagerSample; + +/** + * @author Yuriy Movchan Date: 01/15/2020 + */ +public final class SqlCheckGroupSample { + + private static final Logger LOG = LoggerFactory.getLogger(SqlConnectionProvider.class); + + private SqlCheckGroupSample() { + } + + public static void main(String[] args) { + // Prepare sample connection details + SqlEntryManagerSample sqlEntryManagerSample = new SqlEntryManagerSample(); + + // Create SQL entry manager + SqlEntryManager sqlEntryManager = sqlEntryManagerSample.createSqlEntryManager(); + + // EQ -- String + Filter searchFilter = Filter.create("(&(dn=inum=60B7,ou=groups,o=gluu)(|(owner=inum=78c0ea07-d9db-4ccd-9039-4911a6426a0c,ou=people,o=gluu)(member=inum=78c0ea07-d9db-4ccd-9039-4911a6426a0c,ou=people,o=gluu)))"); + + boolean isMemberOrOwner = sqlEntryManager.findEntries("inum=60B7,ou=groups,o=gluu", SimpleGroup.class, searchFilter, 1).size() > 0; + System.out.println(isMemberOrOwner); + } + +} \ No newline at end of file diff --git a/jans-orm/sql/src/main/java/io/jans/orm/sql/model/JsonString.java b/jans-orm/sql/src/main/java/io/jans/orm/sql/model/JsonString.java index cdf51abd1f8..f28e2eecd89 100644 --- a/jans-orm/sql/src/main/java/io/jans/orm/sql/model/JsonString.java +++ b/jans-orm/sql/src/main/java/io/jans/orm/sql/model/JsonString.java @@ -1,3 +1,9 @@ +/* + * Janssen Project software is available under the Apache License (2004). See http://www.apache.org/licenses/ for full text. + * + * Copyright (c) 2020, Janssen Project + */ + package io.jans.orm.sql.model; /** diff --git a/jans-orm/sql/src/main/java/io/jans/orm/sql/operation/SupportedDbType.java b/jans-orm/sql/src/main/java/io/jans/orm/sql/operation/SupportedDbType.java index 67326872e99..5a1e55bef75 100644 --- a/jans-orm/sql/src/main/java/io/jans/orm/sql/operation/SupportedDbType.java +++ b/jans-orm/sql/src/main/java/io/jans/orm/sql/operation/SupportedDbType.java @@ -1,3 +1,9 @@ +/* + * Janssen Project software is available under the Apache License (2004). See http://www.apache.org/licenses/ for full text. + * + * Copyright (c) 2020, Janssen Project + */ + package io.jans.orm.sql.operation; import java.util.HashMap;