Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: cb ttl update sdk 3 #2434

Merged
merged 2 commits into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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<SimpleUser> 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<SimpleUser> 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());
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,6 @@ protected CouchbaseEntryManager(CouchbaseOperationService operationService) {
protected <T> Integer getExpirationValue(Object entry, Class<T> 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;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}

}
Original file line number Diff line number Diff line change
@@ -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;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down