use of org.xdi.oxauth.model.common.User in project oxAuth by GluuFederation.
the class UserService method addUserAttributeByUserInum.
public User addUserAttributeByUserInum(String userInum, String attributeName, String attributeValue) {
log.debug("Add user attribute by user inum to LDAP: attributeName = '{}', attributeValue = '{}'", attributeName, attributeValue);
User user = getUserByInum(userInum);
if (user == null) {
return null;
}
boolean result = addUserAttribute(user, attributeName, attributeValue);
if (!result) {
// We uses this result in Person Authentication Scripts
addUserAttribute(user, attributeName, attributeValue);
}
return updateUser(user);
}
use of org.xdi.oxauth.model.common.User in project oxAuth by GluuFederation.
the class UserService method saveLongLivedToken.
// this method must be called only if app mode = MEMORY, in ldap case it's anyway persisted in ldap.
public boolean saveLongLivedToken(String userId, PersistentJwt longLivedToken) {
log.debug("Saving long-lived access token: userId = {}", userId);
boolean succeed = false;
User user = getUser(userId);
if (user != null) {
int nTokens = 0;
if (user.getOxAuthPersistentJwt() != null) {
nTokens = user.getOxAuthPersistentJwt().length;
}
nTokens++;
String[] persistentJwts = new String[nTokens];
if (user.getOxAuthPersistentJwt() != null) {
for (int i = 0; i < user.getOxAuthPersistentJwt().length; i++) {
persistentJwts[i] = user.getOxAuthPersistentJwt()[i];
}
}
persistentJwts[nTokens - 1] = longLivedToken.toString();
user.setOxAuthPersistentJwt(persistentJwts);
ldapEntryManager.merge(user);
succeed = true;
}
return succeed;
}
use of org.xdi.oxauth.model.common.User in project oxAuth by GluuFederation.
the class UserService method getUserByAttribute.
public User getUserByAttribute(String attributeName, String attributeValue) {
log.debug("Getting user information from LDAP: attributeName = '{}', attributeValue = '{}'", attributeName, attributeValue);
User user = new User();
user.setDn(staticConfiguration.getBaseDn().getPeople());
List<CustomAttribute> customAttributes = new ArrayList<CustomAttribute>();
customAttributes.add(new CustomAttribute(attributeName, attributeValue));
user.setCustomAttributes(customAttributes);
List<User> entries = ldapEntryManager.findEntries(user);
log.debug("Found '{}' entries", entries.size());
if (entries.size() > 0) {
return entries.get(0);
} else {
return null;
}
}
use of org.xdi.oxauth.model.common.User in project oxAuth by GluuFederation.
the class UserService method getUserNameByInum.
public String getUserNameByInum(String inum) {
if (StringHelper.isEmpty(inum)) {
return null;
}
String userDn = getDnForUser(inum);
User user = getUserByDn(userDn, "uid");
if (user == null) {
return null;
}
return user.getUserId();
}
use of org.xdi.oxauth.model.common.User in project oxAuth by GluuFederation.
the class UserService method addUserAttribute.
public User addUserAttribute(String userId, String attributeName, String attributeValue) {
log.debug("Add user attribute to LDAP: attributeName = '{}', attributeValue = '{}'", attributeName, attributeValue);
User user = getUser(userId);
if (user == null) {
// We uses this result in Person Authentication Scripts
return null;
}
boolean result = addUserAttribute(user, attributeName, attributeValue);
if (!result) {
// We uses this result in Person Authentication Scripts
return null;
}
return updateUser(user);
}
Aggregations