Example usage for org.apache.commons.lang3 StringUtils substringBefore

List of usage examples for org.apache.commons.lang3 StringUtils substringBefore

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils substringBefore.

Prototype

public static String substringBefore(final String str, final String separator) 

Source Link

Document

Gets the substring before the first occurrence of a separator.

Usage

From source file:org.apache.syncope.core.logic.scim.SearchCondVisitor.java

private SearchCond transform(final String operator, final String left, final String right) {
    SearchCond result = null;//from w  w w.  j av a  2  s  .  c  o m

    if (MULTIVALUE.contains(StringUtils.substringBefore(left, "."))) {
        if (conf.getUserConf() == null) {
            throw new IllegalArgumentException(
                    "No " + SCIMUserConf.class.getName() + " provided, cannot continue");
        }

        switch (StringUtils.substringBefore(left, ".")) {
        case "emails":
            result = complex(operator, left, right, conf.getUserConf().getEmails());
            break;

        case "phoneNumbers":
            result = complex(operator, left, right, conf.getUserConf().getPhoneNumbers());
            break;

        case "ims":
            result = complex(operator, left, right, conf.getUserConf().getIms());
            break;

        case "photos":
            result = complex(operator, left, right, conf.getUserConf().getPhotos());
            break;

        case "addresses":
            result = addresses(operator, left, right, conf.getUserConf().getAddresses());
            break;

        default:
        }
    }

    if (result == null) {
        AttributeCond attributeCond = createAttributeCond(left);
        attributeCond.setExpression(StringUtils.strip(right, "\""));
        result = setOperator(attributeCond, operator);
    }

    if (result == null) {
        throw new IllegalArgumentException(
                "Could not handle (" + left + " " + operator + " " + right + ") for " + resource);
    }
    return result;
}

From source file:org.apache.syncope.core.logic.SCIMDataBinder.java

public SCIMUser toSCIMUser(final UserTO userTO, final String location, final List<String> attributes,
        final List<String> excludedAttributes) {

    SCIMConf conf = confManager.get();//ww w .j a  va 2s.c  o  m

    List<String> schemas = new ArrayList<>();
    schemas.add(Resource.User.schema());
    if (conf.getEnterpriseUserConf() != null) {
        schemas.add(Resource.EnterpriseUser.schema());
    }

    SCIMUser user = new SCIMUser(userTO.getKey(), schemas,
            new Meta(Resource.User, userTO.getCreationDate(),
                    userTO.getLastChangeDate() == null ? userTO.getCreationDate() : userTO.getLastChangeDate(),
                    userTO.getETagValue(), location),
            output(attributes, excludedAttributes, "userName", userTO.getUsername()), !userTO.isSuspended());

    Map<String, AttrTO> attrs = new HashMap<>();
    attrs.putAll(EntityTOUtils.buildAttrMap(userTO.getPlainAttrs()));
    attrs.putAll(EntityTOUtils.buildAttrMap(userTO.getDerAttrs()));
    attrs.putAll(EntityTOUtils.buildAttrMap(userTO.getVirAttrs()));

    if (conf.getUserConf() != null) {
        if (output(attributes, excludedAttributes, "name") && conf.getUserConf().getName() != null) {
            SCIMUserName name = new SCIMUserName();

            if (conf.getUserConf().getName().getFamilyName() != null
                    && attrs.containsKey(conf.getUserConf().getName().getFamilyName())) {

                name.setFamilyName(attrs.get(conf.getUserConf().getName().getFamilyName()).getValues().get(0));
            }
            if (conf.getUserConf().getName().getFormatted() != null
                    && attrs.containsKey(conf.getUserConf().getName().getFormatted())) {

                name.setFormatted(attrs.get(conf.getUserConf().getName().getFormatted()).getValues().get(0));
            }
            if (conf.getUserConf().getName().getGivenName() != null
                    && attrs.containsKey(conf.getUserConf().getName().getGivenName())) {

                name.setGivenName(attrs.get(conf.getUserConf().getName().getGivenName()).getValues().get(0));
            }
            if (conf.getUserConf().getName().getHonorificPrefix() != null
                    && attrs.containsKey(conf.getUserConf().getName().getHonorificPrefix())) {

                name.setHonorificPrefix(
                        attrs.get(conf.getUserConf().getName().getHonorificPrefix()).getValues().get(0));
            }
            if (conf.getUserConf().getName().getHonorificSuffix() != null
                    && attrs.containsKey(conf.getUserConf().getName().getHonorificSuffix())) {

                name.setHonorificSuffix(
                        attrs.get(conf.getUserConf().getName().getHonorificSuffix()).getValues().get(0));
            }
            if (conf.getUserConf().getName().getMiddleName() != null
                    && attrs.containsKey(conf.getUserConf().getName().getMiddleName())) {

                name.setMiddleName(attrs.get(conf.getUserConf().getName().getMiddleName()).getValues().get(0));
            }

            if (!name.isEmpty()) {
                user.setName(name);
            }
        }

        if (output(attributes, excludedAttributes, "displayName") && conf.getUserConf().getDisplayName() != null
                && attrs.containsKey(conf.getUserConf().getDisplayName())) {

            user.setDisplayName(attrs.get(conf.getUserConf().getDisplayName()).getValues().get(0));
        }
        if (output(attributes, excludedAttributes, "nickName") && conf.getUserConf().getNickName() != null
                && attrs.containsKey(conf.getUserConf().getNickName())) {

            user.setNickName(attrs.get(conf.getUserConf().getNickName()).getValues().get(0));
        }
        if (output(attributes, excludedAttributes, "profileUrl") && conf.getUserConf().getProfileUrl() != null
                && attrs.containsKey(conf.getUserConf().getProfileUrl())) {

            user.setProfileUrl(attrs.get(conf.getUserConf().getProfileUrl()).getValues().get(0));
        }
        if (output(attributes, excludedAttributes, "title") && conf.getUserConf().getTitle() != null
                && attrs.containsKey(conf.getUserConf().getTitle())) {

            user.setTitle(attrs.get(conf.getUserConf().getTitle()).getValues().get(0));
        }
        if (output(attributes, excludedAttributes, "userType") && conf.getUserConf().getUserType() != null
                && attrs.containsKey(conf.getUserConf().getUserType())) {

            user.setUserType(attrs.get(conf.getUserConf().getUserType()).getValues().get(0));
        }
        if (output(attributes, excludedAttributes, "preferredLanguage")
                && conf.getUserConf().getPreferredLanguage() != null
                && attrs.containsKey(conf.getUserConf().getPreferredLanguage())) {

            user.setPreferredLanguage(attrs.get(conf.getUserConf().getPreferredLanguage()).getValues().get(0));
        }
        if (output(attributes, excludedAttributes, "locale") && conf.getUserConf().getLocale() != null
                && attrs.containsKey(conf.getUserConf().getLocale())) {

            user.setLocale(attrs.get(conf.getUserConf().getLocale()).getValues().get(0));
        }
        if (output(attributes, excludedAttributes, "timezone") && conf.getUserConf().getTimezone() != null
                && attrs.containsKey(conf.getUserConf().getTimezone())) {

            user.setTimezone(attrs.get(conf.getUserConf().getTimezone()).getValues().get(0));
        }

        if (output(attributes, excludedAttributes, "emails")) {
            fill(attrs, conf.getUserConf().getEmails(), user.getEmails());
        }
        if (output(attributes, excludedAttributes, "phoneNumbers")) {
            fill(attrs, conf.getUserConf().getPhoneNumbers(), user.getPhoneNumbers());
        }
        if (output(attributes, excludedAttributes, "ims")) {
            fill(attrs, conf.getUserConf().getIms(), user.getIms());
        }
        if (output(attributes, excludedAttributes, "photos")) {
            fill(attrs, conf.getUserConf().getPhotos(), user.getPhotos());
        }
        if (output(attributes, excludedAttributes, "addresses")) {
            conf.getUserConf().getAddresses().forEach(addressConf -> {
                SCIMUserAddress address = new SCIMUserAddress();

                if (addressConf.getFormatted() != null && attrs.containsKey(addressConf.getFormatted())) {
                    address.setFormatted(attrs.get(addressConf.getFormatted()).getValues().get(0));
                }
                if (addressConf.getStreetAddress() != null
                        && attrs.containsKey(addressConf.getStreetAddress())) {
                    address.setStreetAddress(attrs.get(addressConf.getStreetAddress()).getValues().get(0));
                }
                if (addressConf.getLocality() != null && attrs.containsKey(addressConf.getLocality())) {
                    address.setLocality(attrs.get(addressConf.getLocality()).getValues().get(0));
                }
                if (addressConf.getRegion() != null && attrs.containsKey(addressConf.getRegion())) {
                    address.setRegion(attrs.get(addressConf.getRegion()).getValues().get(0));
                }
                if (addressConf.getCountry() != null && attrs.containsKey(addressConf.getCountry())) {
                    address.setCountry(attrs.get(addressConf.getCountry()).getValues().get(0));
                }
                if (addressConf.getType() != null) {
                    address.setType(addressConf.getType().name());
                }
                if (addressConf.isPrimary()) {
                    address.setPrimary(true);
                }

                if (!address.isEmpty()) {
                    user.getAddresses().add(address);
                }
            });
        }
        if (output(attributes, excludedAttributes, "x509Certificates")) {
            conf.getUserConf().getX509Certificates().stream()
                    .filter(certificate -> attrs.containsKey(certificate)).forEachOrdered(certificate -> {
                        user.getX509Certificates().add(new Value(attrs.get(certificate).getValues().get(0)));
                    });
        }

        if (conf.getEnterpriseUserConf() != null) {
            SCIMEnterpriseInfo enterpriseInfo = new SCIMEnterpriseInfo();

            if (output(attributes, excludedAttributes, "employeeNumber")
                    && conf.getEnterpriseUserConf().getEmployeeNumber() != null
                    && attrs.containsKey(conf.getEnterpriseUserConf().getEmployeeNumber())) {

                enterpriseInfo.setEmployeeNumber(
                        attrs.get(conf.getEnterpriseUserConf().getEmployeeNumber()).getValues().get(0));
            }
            if (output(attributes, excludedAttributes, "costCenter")
                    && conf.getEnterpriseUserConf().getCostCenter() != null
                    && attrs.containsKey(conf.getEnterpriseUserConf().getCostCenter())) {

                enterpriseInfo.setCostCenter(
                        attrs.get(conf.getEnterpriseUserConf().getCostCenter()).getValues().get(0));
            }
            if (output(attributes, excludedAttributes, "organization")
                    && conf.getEnterpriseUserConf().getOrganization() != null
                    && attrs.containsKey(conf.getEnterpriseUserConf().getOrganization())) {

                enterpriseInfo.setOrganization(
                        attrs.get(conf.getEnterpriseUserConf().getOrganization()).getValues().get(0));
            }
            if (output(attributes, excludedAttributes, "division")
                    && conf.getEnterpriseUserConf().getDivision() != null
                    && attrs.containsKey(conf.getEnterpriseUserConf().getDivision())) {

                enterpriseInfo
                        .setDivision(attrs.get(conf.getEnterpriseUserConf().getDivision()).getValues().get(0));
            }
            if (output(attributes, excludedAttributes, "department")
                    && conf.getEnterpriseUserConf().getDepartment() != null
                    && attrs.containsKey(conf.getEnterpriseUserConf().getDepartment())) {

                enterpriseInfo.setDepartment(
                        attrs.get(conf.getEnterpriseUserConf().getDepartment()).getValues().get(0));
            }
            if (output(attributes, excludedAttributes, "manager")
                    && conf.getEnterpriseUserConf().getManager() != null) {

                SCIMUserManager manager = new SCIMUserManager();

                if (conf.getEnterpriseUserConf().getManager().getKey() != null
                        && attrs.containsKey(conf.getEnterpriseUserConf().getManager().getKey())) {

                    try {
                        UserTO userManager = userLogic.read(attrs
                                .get(conf.getEnterpriseUserConf().getManager().getKey()).getValues().get(0));
                        manager.setValue(userManager.getKey());
                        manager.setRef(StringUtils.substringBefore(location, "/Users") + "/Users/"
                                + userManager.getKey());

                        if (conf.getEnterpriseUserConf().getManager().getDisplayName() != null) {
                            AttrTO displayName = userManager
                                    .getPlainAttr(conf.getEnterpriseUserConf().getManager().getDisplayName())
                                    .orElse(null);
                            if (displayName == null) {
                                displayName = userManager
                                        .getDerAttr(conf.getEnterpriseUserConf().getManager().getDisplayName())
                                        .orElse(null);
                            }
                            if (displayName == null) {
                                displayName = userManager
                                        .getVirAttr(conf.getEnterpriseUserConf().getManager().getDisplayName())
                                        .orElse(null);
                            }
                            if (displayName != null) {
                                manager.setDisplayName(displayName.getValues().get(0));
                            }
                        }
                    } catch (Exception e) {
                        LOG.error("Could not read user {}", conf.getEnterpriseUserConf().getManager().getKey(),
                                e);
                    }
                }

                if (!manager.isEmpty()) {
                    enterpriseInfo.setManager(manager);
                }
            }

            if (!enterpriseInfo.isEmpty()) {
                user.setEnterpriseInfo(enterpriseInfo);
            }
        }

        if (output(attributes, excludedAttributes, "groups")) {
            userTO.getMemberships().forEach(membership -> {
                user.getGroups()
                        .add(new Group(membership.getGroupKey(),
                                StringUtils.substringBefore(location, "/Users") + "/Groups/"
                                        + membership.getGroupKey(),
                                membership.getGroupName(), Function.direct));
            });
            userTO.getDynMemberships().forEach(membership -> {
                user.getGroups()
                        .add(new Group(membership.getGroupKey(),
                                StringUtils.substringBefore(location, "/Users") + "/Groups/"
                                        + membership.getGroupKey(),
                                membership.getGroupName(), Function.indirect));
            });
        }

        if (output(attributes, excludedAttributes, "entitlements")) {
            authDataAccessor.getAuthorities(userTO.getUsername()).forEach(authority -> {
                user.getEntitlements()
                        .add(new Value(authority.getAuthority() + " on Realm(s) " + authority.getRealms()));
            });
        }

        if (output(attributes, excludedAttributes, "roles")) {
            userTO.getRoles().forEach(role -> {
                user.getRoles().add(new Value(role));
            });
        }
    }

    return user;
}

From source file:org.apache.syncope.core.logic.SCIMDataBinder.java

public SCIMGroup toSCIMGroup(final GroupTO groupTO, final String location, final List<String> attributes,
        final List<String> excludedAttributes) {

    SCIMGroup group = new SCIMGroup(groupTO.getKey(),
            new Meta(Resource.Group, groupTO.getCreationDate(),
                    groupTO.getLastChangeDate() == null ? groupTO.getCreationDate()
                            : groupTO.getLastChangeDate(),
                    groupTO.getETagValue(), location),
            output(attributes, excludedAttributes, "displayName", groupTO.getName()));

    MembershipCond membCond = new MembershipCond();
    membCond.setGroup(groupTO.getKey());
    SearchCond searchCond = SearchCond.getLeafCond(membCond);

    if (output(attributes, excludedAttributes, "members")) {
        int count = userLogic.search(searchCond, 1, 1, Collections.<OrderByClause>emptyList(),
                SyncopeConstants.ROOT_REALM, false).getLeft();

        for (int page = 1; page <= (count / AnyDAO.DEFAULT_PAGE_SIZE) + 1; page++) {
            List<UserTO> users = userLogic.search(searchCond, page, AnyDAO.DEFAULT_PAGE_SIZE,
                    Collections.<OrderByClause>emptyList(), SyncopeConstants.ROOT_REALM, false).getRight();
            users.forEach(userTO -> {
                group.getMembers()/*  www . j a va2s. c o m*/
                        .add(new Member(userTO.getKey(),
                                StringUtils.substringBefore(location, "/Groups") + "/Users/" + userTO.getKey(),
                                userTO.getUsername()));
            });
        }
    }

    return group;
}

From source file:org.apache.syncope.core.persistence.jpa.dao.AbstractAnyDAO.java

@Transactional(readOnly = true)
@Override/*  ww w  .  jav  a  2  s.co  m*/
public A authFind(final String key) {
    if (key == null) {
        throw new NotFoundException("Null key");
    }

    A any = find(key);
    if (any == null) {
        throw new NotFoundException(StringUtils.substringBefore(
                StringUtils.substringAfter(getClass().getSimpleName(), "JPA"), "DAO") + " " + key);
    }

    securityChecks(any);

    return any;
}

From source file:org.apache.syncope.core.persistence.jpa.spring.CommonEntityManagerFactoryConf.java

@Override
public void afterPropertiesSet() {
    for (Map.Entry<String, DataSource> entry : ctx.getBeansOfType(DataSource.class).entrySet()) {
        if (!entry.getKey().startsWith("local")) {
            this.domains.put(StringUtils.substringBefore(entry.getKey(), DataSource.class.getSimpleName()),
                    entry.getValue());//from  www .j  a va  2 s .co  m
        }
    }
}

From source file:org.apache.syncope.core.workflow.activiti.spring.DomainProcessEngineFactoryBean.java

@Override
public DomainProcessEngine getObject() throws Exception {
    if (engine == null) {
        Map<String, ProcessEngine> engines = new HashMap<>();

        for (Map.Entry<String, DataSource> entry : ctx.getBeansOfType(DataSource.class).entrySet()) {
            if (!entry.getKey().startsWith("local")) {
                String domain = StringUtils.substringBefore(entry.getKey(), DataSource.class.getSimpleName());
                DataSource dataSource = entry.getValue();
                PlatformTransactionManager transactionManager = ctx.getBean(domain + "TransactionManager",
                        PlatformTransactionManager.class);
                Object entityManagerFactory = ctx.getBean(domain + "EntityManagerFactory");

                SpringProcessEngineConfiguration conf = ctx.getBean(SpringProcessEngineConfiguration.class);
                conf.setDataSource(dataSource);
                conf.setTransactionManager(transactionManager);
                conf.setTransactionsExternallyManaged(true);
                conf.setJpaEntityManagerFactory(entityManagerFactory);
                if (conf.getBeans() == null) {
                    conf.setBeans(new SpringBeanFactoryProxyMap(ctx));
                }/*from www.  j  a  v  a 2s  . co m*/
                if (conf.getExpressionManager() == null) {
                    conf.setExpressionManager(new SpringExpressionManager(ctx, conf.getBeans()));
                }

                engines.put(domain, conf.buildProcessEngine());
            }
        }

        engine = new DomainProcessEngine(engines);
    }

    return engine;
}

From source file:org.apache.syncope.core.workflow.flowable.spring.DomainProcessEngineFactoryBean.java

@Override
public DomainProcessEngine getObject() throws Exception {
    if (engine == null) {
        Map<String, ProcessEngine> engines = new HashMap<>();

        ctx.getBeansOfType(DataSource.class).entrySet().stream()
                .filter(entry -> (!entry.getKey().startsWith("local"))).forEachOrdered(entry -> {
                    String domain = StringUtils.substringBefore(entry.getKey(),
                            DataSource.class.getSimpleName());
                    DataSource dataSource = entry.getValue();
                    PlatformTransactionManager transactionManager = ctx.getBean(domain + "TransactionManager",
                            PlatformTransactionManager.class);
                    Object entityManagerFactory = ctx.getBean(domain + "EntityManagerFactory");

                    SpringProcessEngineConfiguration conf = ctx.getBean(SpringProcessEngineConfiguration.class);
                    conf.setDataSource(dataSource);
                    conf.setTransactionManager(transactionManager);
                    conf.setTransactionsExternallyManaged(true);
                    conf.setJpaEntityManagerFactory(entityManagerFactory);
                    if (conf.getBeans() == null) {
                        conf.setBeans(new SpringBeanFactoryProxyMap(ctx));
                    }/*  w w  w . j  a  v a 2 s  .  c  o m*/
                    if (conf.getExpressionManager() == null) {
                        conf.setExpressionManager(new SpringExpressionManager(ctx, conf.getBeans()));
                    }
                    if (EngineServiceUtil.getIdmEngineConfiguration(conf) == null) {
                        conf.addEngineConfiguration(EngineConfigurationConstants.KEY_IDM_ENGINE_CONFIG,
                                ctx.getBean(SpringIdmEngineConfiguration.class));
                    }

                    engines.put(domain, conf.buildProcessEngine());
                });

        engine = new DomainProcessEngine(engines);
    }

    return engine;
}

From source file:org.apache.syncope.ext.saml2lsp.agent.AssertionConsumer.java

@Override
protected void doPost(final HttpServletRequest request, final HttpServletResponse response)
        throws ServletException, IOException {

    SyncopeClient anonymous = (SyncopeClient) request.getServletContext()
            .getAttribute(Constants.SYNCOPE_ANONYMOUS_CLIENT);
    try {//w  w  w .  ja  va  2  s. c  o  m
        SAML2LoginResponseTO responseTO = anonymous.getService(SAML2SPService.class).validateLoginResponse(
                extract(StringUtils.substringBefore(request.getRequestURL().toString(), "/saml2sp"), "saml2sp",
                        request.getRemoteAddr(), request.getInputStream()));

        request.getSession(true).setAttribute(Constants.SAML2SPJWT, responseTO.getAccessToken());
        request.getSession(true).setAttribute(Constants.SAML2SPJWT_EXPIRE,
                responseTO.getAccessTokenExpiryTime());

        String successURL = getServletContext().getInitParameter(Constants.CONTEXT_PARAM_LOGIN_SUCCESS_URL);
        if (successURL == null) {
            request.setAttribute("responseTO", responseTO);
            request.getRequestDispatcher("loginSuccess.jsp").forward(request, response);
        } else {
            response.sendRedirect(successURL + "?sloSupported=" + responseTO.isSloSupported());
        }
    } catch (Exception e) {
        LOG.error("While processing authentication response from IdP", e);

        String errorURL = getServletContext().getInitParameter(Constants.CONTEXT_PARAM_LOGIN_ERROR_URL);
        if (errorURL == null) {
            request.setAttribute("exception", e);
            request.getRequestDispatcher("loginError.jsp").forward(request, response);

            e.printStackTrace(response.getWriter());
        } else {
            response.sendRedirect(errorURL + "?errorMessage="
                    + URLEncoder.encode(e.getMessage(), StandardCharsets.UTF_8.name()));
        }
    }
}

From source file:org.apache.syncope.ext.saml2lsp.agent.Login.java

@Override
protected void doGet(final HttpServletRequest request, final HttpServletResponse response)
        throws ServletException, IOException {

    String idp = request.getParameter(Constants.PARAM_IDP);

    SyncopeClient anonymous = (SyncopeClient) request.getServletContext()
            .getAttribute(Constants.SYNCOPE_ANONYMOUS_CLIENT);
    try {/*from   ww w.j  ava2s.  co  m*/
        SAML2RequestTO requestTO = anonymous.getService(SAML2SPService.class).createLoginRequest(
                StringUtils.substringBefore(request.getRequestURL().toString(), "/saml2sp"), idp);

        prepare(response, requestTO);
    } catch (Exception e) {
        LOG.error("While preparing authentication request to IdP", e);

        String errorURL = getServletContext().getInitParameter(Constants.CONTEXT_PARAM_LOGIN_ERROR_URL);
        if (errorURL == null) {
            request.setAttribute("exception", e);
            request.getRequestDispatcher("loginError.jsp").forward(request, response);

            e.printStackTrace(response.getWriter());
        } else {
            response.sendRedirect(errorURL + "?errorMessage="
                    + URLEncoder.encode(e.getMessage(), StandardCharsets.UTF_8.name()));
        }
    }
}

From source file:org.apache.syncope.ext.saml2lsp.agent.Logout.java

@Override
protected void doGet(final HttpServletRequest request, final HttpServletResponse response)
        throws ServletException, IOException {

    String samlResponse = request.getParameter(SSOConstants.SAML_RESPONSE);
    String relayState = request.getParameter(SSOConstants.RELAY_STATE);
    if (samlResponse == null) { // prepare logout response
        SyncopeClientFactoryBean clientFactory = (SyncopeClientFactoryBean) request.getServletContext()
                .getAttribute(Constants.SYNCOPE_CLIENT_FACTORY);
        try {/*from  w  w w .  ja  va 2 s .c  o  m*/
            String accessToken = (String) request.getSession().getAttribute(Constants.SAML2SPJWT);
            if (StringUtils.isBlank(accessToken)) {
                throw new IllegalArgumentException("No access token found ");
            }

            SyncopeClient client = clientFactory.create(accessToken);
            SAML2RequestTO requestTO = client.getService(SAML2SPService.class).createLogoutRequest(
                    StringUtils.substringBefore(request.getRequestURL().toString(), "/saml2sp"));

            prepare(response, requestTO);
        } catch (Exception e) {
            LOG.error("While preparing logout request to IdP", e);

            String errorURL = getServletContext().getInitParameter(Constants.CONTEXT_PARAM_LOGOUT_ERROR_URL);
            if (errorURL == null) {
                request.setAttribute("exception", e);
                request.getRequestDispatcher("logoutError.jsp").forward(request, response);

                e.printStackTrace(response.getWriter());
            } else {
                response.sendRedirect(errorURL + "?errorMessage="
                        + URLEncoder.encode(e.getMessage(), StandardCharsets.UTF_8.name()));
            }
        }
    } else { // process REDIRECT binding logout response
        SAML2ReceivedResponseTO receivedResponse = new SAML2ReceivedResponseTO();
        receivedResponse.setSamlResponse(samlResponse);
        receivedResponse.setRelayState(relayState);

        doLogout(receivedResponse, request, response);
    }
}