Search in sources :

Example 1 with SimpleProperty

use of org.xdi.model.SimpleProperty in project oxAuth by GluuFederation.

the class AuthenticationService method authenticate.

/*
     * Utility method which can be used in custom scripts
     */
public boolean authenticate(GluuLdapConfiguration ldapAuthConfig, LdapEntryManager ldapAuthEntryManager, String keyValue, String password, String primaryKey, String localPrimaryKey) {
    log.debug("Attempting to find userDN by primary key: '{}' and key value: '{}', credentials: '{}'", primaryKey, keyValue, System.identityHashCode(credentials));
    List<?> baseDNs;
    if (ldapAuthConfig == null) {
        baseDNs = Arrays.asList(userService.getDnForUser(null));
    } else {
        baseDNs = ldapAuthConfig.getBaseDNs();
    }
    if (baseDNs != null && !baseDNs.isEmpty()) {
        for (Object baseDnProperty : baseDNs) {
            String baseDn;
            if (baseDnProperty instanceof SimpleProperty) {
                baseDn = ((SimpleProperty) baseDnProperty).getValue();
            } else {
                baseDn = baseDnProperty.toString();
            }
            User user = getUserByAttribute(ldapAuthEntryManager, baseDn, primaryKey, keyValue);
            if (user != null) {
                String userDn = user.getDn();
                log.debug("Attempting to authenticate userDN: {}", userDn);
                if (ldapAuthEntryManager.authenticate(userDn, password)) {
                    log.debug("User authenticated: {}", userDn);
                    log.debug("Attempting to find userDN by local primary key: {}", localPrimaryKey);
                    User localUser = userService.getUserByAttribute(localPrimaryKey, keyValue);
                    if (localUser != null) {
                        if (!checkUserStatus(localUser)) {
                            return false;
                        }
                        configureAuthenticatedUser(localUser);
                        updateLastLogonUserTime(localUser);
                        log.trace("authenticate_external: credentials: '{}', credentials.userName: '{}', authenticatedUser.userId: '{}'", System.identityHashCode(credentials), credentials.getUsername(), getAuthenticatedUserId());
                        return true;
                    }
                }
            }
        }
    } else {
        log.error("There are no baseDns specified in authentication configuration.");
    }
    return false;
}
Also used : User(org.xdi.oxauth.model.common.User) SimpleUser(org.xdi.oxauth.model.common.SimpleUser) SimpleProperty(org.xdi.model.SimpleProperty)

Example 2 with SimpleProperty

use of org.xdi.model.SimpleProperty in project oxTrust by GluuFederation.

the class ConfigureCacheRefreshAction method checkDuplicateKetattribute.

public boolean checkDuplicateKetattribute() {
    System.out.println("inside validate method");
    for (SimpleProperty keyAttribute1 : keyAttributes) {
        String checkValue = keyAttribute1.getValue();
        int i = 0;
        for (SimpleProperty keyAttribute : keyAttributes) {
            String value = keyAttribute.getValue();
            if (checkValue.equals(value)) {
                i = i + 1;
                if (i == 2) {
                    FacesContext context = FacesContext.getCurrentInstance();
                    context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Key Attribute already Exist!", "Key Attribute already Exist!"));
                    return false;
                }
            }
        }
    }
    return true;
}
Also used : FacesContext(javax.faces.context.FacesContext) SimpleProperty(org.xdi.model.SimpleProperty) FacesMessage(javax.faces.application.FacesMessage)

Example 3 with SimpleProperty

use of org.xdi.model.SimpleProperty in project oxTrust by GluuFederation.

the class ManagePersonAuthenticationAction method buildServersString.

private String buildServersString(List<SimpleProperty> servers) {
    StringBuilder sb = new StringBuilder();
    if (servers == null) {
        return sb.toString();
    }
    boolean first = true;
    for (SimpleProperty server : servers) {
        if (first) {
            first = false;
        } else {
            sb.append(",");
        }
        sb.append(server.getValue());
    }
    return sb.toString();
}
Also used : SimpleProperty(org.xdi.model.SimpleProperty)

Example 4 with SimpleProperty

use of org.xdi.model.SimpleProperty in project oxTrust by GluuFederation.

the class ConfigureCacheRefreshAction method validateProperty.

public void validateProperty(FacesContext context, UIComponent comp, Object value) {
    System.out.println("inside validate method");
    String newkeyAttr = (String) value;
    int size = keyAttributes.size();
    for (SimpleProperty keyAttribute : keyAttributes) {
        int i = 0;
        if (newkeyAttr.equalsIgnoreCase(keyAttribute.getValue())) {
            i = i + 1;
            if (i == 2) {
                ((UIInput) comp).setValid(false);
                FacesMessage message = new FacesMessage("key attribute already Exist! ");
                // message.setSeverity(Severity.ERROR);
                context.addMessage(comp.getClientId(context), message);
            }
        }
    }
}
Also used : SimpleProperty(org.xdi.model.SimpleProperty) UIInput(javax.faces.component.UIInput) FacesMessage(javax.faces.application.FacesMessage)

Aggregations

SimpleProperty (org.xdi.model.SimpleProperty)4 FacesMessage (javax.faces.application.FacesMessage)2 UIInput (javax.faces.component.UIInput)1 FacesContext (javax.faces.context.FacesContext)1 SimpleUser (org.xdi.oxauth.model.common.SimpleUser)1 User (org.xdi.oxauth.model.common.User)1