Search in sources :

Example 6 with User

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);
}
Also used : User(org.xdi.oxauth.model.common.User)

Example 7 with 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;
}
Also used : User(org.xdi.oxauth.model.common.User)

Example 8 with User

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;
    }
}
Also used : User(org.xdi.oxauth.model.common.User) CustomAttribute(org.xdi.ldap.model.CustomAttribute) ArrayList(java.util.ArrayList)

Example 9 with User

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();
}
Also used : User(org.xdi.oxauth.model.common.User)

Example 10 with User

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);
}
Also used : User(org.xdi.oxauth.model.common.User)

Aggregations

User (org.xdi.oxauth.model.common.User)25 SimpleUser (org.xdi.oxauth.model.common.SimpleUser)7 CustomAttribute (org.xdi.ldap.model.CustomAttribute)5 SessionState (org.xdi.oxauth.model.common.SessionState)5 ArrayList (java.util.ArrayList)4 Client (org.xdi.oxauth.model.registration.Client)4 Prompt (org.xdi.oxauth.model.common.Prompt)3 SignatureException (java.security.SignatureException)2 WebApplicationException (javax.ws.rs.WebApplicationException)2 ResponseBuilder (javax.ws.rs.core.Response.ResponseBuilder)2 EntryPersistenceException (org.gluu.site.ldap.persistence.exception.EntryPersistenceException)2 OAuth2AuditLog (org.xdi.oxauth.model.audit.OAuth2AuditLog)2 AccessToken (org.xdi.oxauth.model.common.AccessToken)2 AuthorizationGrant (org.xdi.oxauth.model.common.AuthorizationGrant)2 IdToken (org.xdi.oxauth.model.common.IdToken)2 AcrChangedException (org.xdi.oxauth.model.exception.AcrChangedException)2 InvalidJwtException (org.xdi.oxauth.model.exception.InvalidJwtException)2 ClientAuthorizations (org.xdi.oxauth.model.ldap.ClientAuthorizations)2 StringEncrypter (org.xdi.util.security.StringEncrypter)2 Filter (com.unboundid.ldap.sdk.Filter)1