Example usage for javax.servlet.http HttpServletRequest getScheme

List of usage examples for javax.servlet.http HttpServletRequest getScheme

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest getScheme.

Prototype

public String getScheme();

Source Link

Document

Returns the name of the scheme used to make this request, for example, <code>http</code>, <code>https</code>, or <code>ftp</code>.

Usage

From source file:com.fuseim.webapp.ProxyServlet.java

private void setXForwardedForHeader(HttpServletRequest servletRequest, HttpRequest proxyRequest) {
    if (doForwardIP) {
        String forHeaderName = "X-Forwarded-For";
        String forHeader = servletRequest.getRemoteAddr();
        String existingForHeader = servletRequest.getHeader(forHeaderName);
        if (existingForHeader != null) {
            forHeader = existingForHeader + ", " + forHeader;
        }/* w w  w.ja v a2s .com*/
        proxyRequest.setHeader(forHeaderName, forHeader);

        String protoHeaderName = "X-Forwarded-Proto";
        String protoHeader = servletRequest.getScheme();
        proxyRequest.setHeader(protoHeaderName, protoHeader);
    }
}

From source file:org.kuali.ole.sys.web.struts.KualiAccountingDocumentActionBase.java

/**
 * This method handles preparing all of the accounting line data so that it can be pushed up to the balance inquiries for
 * populating the search criteria of each.
 * /*from   ww  w. ja v  a2s .c  o m*/
 * @param mapping
 * @param form
 * @param request
 * @param line
 * @return ActionForward
 */
protected ActionForward performBalanceInquiryForAccountingLine(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, AccountingLine line) {
    // build out base path for return location
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + request.getContextPath();

    // build out the actual form key that will be used to retrieve the form on refresh
    String callerDocFormKey = GlobalVariables.getUserSession().addObjectWithGeneratedKey(form);

    // now add required parameters
    Properties parameters = new Properties();
    parameters.put(OLEConstants.DISPATCH_REQUEST_PARAMETER, OLEConstants.START_METHOD);
    // need this next param b/c the lookup's return back will overwrite
    // the original doc form key
    parameters.put(OLEConstants.BALANCE_INQUIRY_REPORT_MENU_CALLER_DOC_FORM_KEY, callerDocFormKey);
    parameters.put(OLEConstants.DOC_FORM_KEY, callerDocFormKey);
    parameters.put(OLEConstants.BACK_LOCATION, basePath + mapping.getPath() + ".do");

    if (line.getPostingYear() != null) {
        parameters.put(OLEPropertyConstants.UNIVERSITY_FISCAL_YEAR, line.getPostingYear().toString());
    }
    if (StringUtils.isNotBlank(line.getReferenceOriginCode())) {
        parameters.put("referenceOriginCode", line.getReferenceOriginCode());
    }
    if (StringUtils.isNotBlank(line.getReferenceNumber())) {
        parameters.put("referenceNumber", line.getReferenceNumber());
    }
    if (StringUtils.isNotBlank(line.getReferenceTypeCode())) {
        parameters.put("referenceTypeCode", line.getReferenceTypeCode());
    }
    if (StringUtils.isNotBlank(line.getDebitCreditCode())) {
        parameters.put("debitCreditCode", line.getDebitCreditCode());
    }
    if (StringUtils.isNotBlank(line.getChartOfAccountsCode())) {
        parameters.put("chartOfAccountsCode", line.getChartOfAccountsCode());
    }
    if (StringUtils.isNotBlank(line.getAccountNumber())) {
        parameters.put("accountNumber", line.getAccountNumber());
    }
    if (StringUtils.isNotBlank(line.getFinancialObjectCode())) {
        parameters.put("financialObjectCode", line.getFinancialObjectCode());
    }
    if (StringUtils.isNotBlank(line.getSubAccountNumber())) {
        parameters.put("subAccountNumber", line.getSubAccountNumber());
    }
    if (StringUtils.isNotBlank(line.getFinancialSubObjectCode())) {
        parameters.put("financialSubObjectCode", line.getFinancialSubObjectCode());
    }
    if (StringUtils.isNotBlank(line.getProjectCode())) {
        parameters.put("projectCode", line.getProjectCode());
    }
    if (StringUtils.isNotBlank(getObjectTypeCodeFromLine(line))) {
        if (!StringUtils.isBlank(line.getObjectTypeCode())) {
            parameters.put("objectTypeCode", line.getObjectTypeCode());
        } else {
            line.refreshReferenceObject("objectCode");
            parameters.put("objectTypeCode", line.getObjectCode().getFinancialObjectTypeCode());
        }
    }

    String lookupUrl = UrlFactory
            .parameterizeUrl(basePath + "/" + OLEConstants.BALANCE_INQUIRY_REPORT_MENU_ACTION, parameters);

    // register that we're going to come back w/ to this form w/ a refresh methodToCall
    ((KualiAccountingDocumentFormBase) form).registerEditableProperty(KRADConstants.DISPATCH_REQUEST_PARAMETER);

    return new ActionForward(lookupUrl, true);
}

From source file:org.kuali.kfs.sys.web.struts.KualiAccountingDocumentActionBase.java

/**
 * This method handles preparing all of the accounting line data so that it can be pushed up to the balance inquiries for
 * populating the search criteria of each.
 * /*  w  w w. j  a  va  2 s.  c  om*/
 * @param mapping
 * @param form
 * @param request
 * @param line
 * @return ActionForward
 */
protected ActionForward performBalanceInquiryForAccountingLine(ActionMapping mapping, ActionForm form,
        HttpServletRequest request, AccountingLine line) {
    // build out base path for return location
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + request.getContextPath();

    // build out the actual form key that will be used to retrieve the form on refresh
    String callerDocFormKey = GlobalVariables.getUserSession().addObjectWithGeneratedKey(form);

    // now add required parameters
    Properties parameters = new Properties();
    parameters.put(KFSConstants.DISPATCH_REQUEST_PARAMETER, KFSConstants.START_METHOD);
    // need this next param b/c the lookup's return back will overwrite
    // the original doc form key
    parameters.put(KFSConstants.BALANCE_INQUIRY_REPORT_MENU_CALLER_DOC_FORM_KEY, callerDocFormKey);
    parameters.put(KFSConstants.DOC_FORM_KEY, callerDocFormKey);
    parameters.put(KFSConstants.BACK_LOCATION, basePath + mapping.getPath() + ".do");

    if (line.getPostingYear() != null) {
        parameters.put(KFSPropertyConstants.UNIVERSITY_FISCAL_YEAR, line.getPostingYear().toString());
    }
    if (StringUtils.isNotBlank(line.getReferenceOriginCode())) {
        parameters.put("referenceOriginCode", line.getReferenceOriginCode());
    }
    if (StringUtils.isNotBlank(line.getReferenceNumber())) {
        parameters.put("referenceNumber", line.getReferenceNumber());
    }
    if (StringUtils.isNotBlank(line.getReferenceTypeCode())) {
        parameters.put("referenceTypeCode", line.getReferenceTypeCode());
    }
    if (StringUtils.isNotBlank(line.getDebitCreditCode())) {
        parameters.put("debitCreditCode", line.getDebitCreditCode());
    }
    if (StringUtils.isNotBlank(line.getChartOfAccountsCode())) {
        parameters.put("chartOfAccountsCode", line.getChartOfAccountsCode());
    }
    if (StringUtils.isNotBlank(line.getAccountNumber())) {
        parameters.put("accountNumber", line.getAccountNumber());
    }
    if (StringUtils.isNotBlank(line.getFinancialObjectCode())) {
        parameters.put("financialObjectCode", line.getFinancialObjectCode());
    }
    if (StringUtils.isNotBlank(line.getSubAccountNumber())) {
        parameters.put("subAccountNumber", line.getSubAccountNumber());
    }
    if (StringUtils.isNotBlank(line.getFinancialSubObjectCode())) {
        parameters.put("financialSubObjectCode", line.getFinancialSubObjectCode());
    }
    if (StringUtils.isNotBlank(line.getProjectCode())) {
        parameters.put("projectCode", line.getProjectCode());
    }
    if (StringUtils.isNotBlank(getObjectTypeCodeFromLine(line))) {
        if (!StringUtils.isBlank(line.getObjectTypeCode())) {
            parameters.put("objectTypeCode", line.getObjectTypeCode());
        } else {
            line.refreshReferenceObject("objectCode");
            parameters.put("objectTypeCode", line.getObjectCode().getFinancialObjectTypeCode());
        }
    }

    String lookupUrl = UrlFactory
            .parameterizeUrl(basePath + "/" + KFSConstants.BALANCE_INQUIRY_REPORT_MENU_ACTION, parameters);

    // register that we're going to come back w/ to this form w/ a refresh methodToCall
    ((KualiAccountingDocumentFormBase) form).registerEditableProperty(KRADConstants.DISPATCH_REQUEST_PARAMETER);

    return new ActionForward(lookupUrl, true);
}

From source file:org.apereo.portal.portlets.account.UserAccountHelper.java

public void sendLoginToken(HttpServletRequest request, ILocalAccountPerson account,
        IPasswordResetNotification notification) {

    Locale locale = getCurrentUserLocale(request);

    IPortalUrlBuilder builder = urlProvider.getPortalUrlBuilderByPortletFName(request, PORTLET_FNAME_LOGIN,
            UrlType.RENDER);/*from   w w w.  j a va  2s .  c  om*/
    IPortletUrlBuilder portletUrlBuilder = builder.getTargetedPortletUrlBuilder();
    portletUrlBuilder.addParameter("username", account.getName());
    portletUrlBuilder.addParameter("loginToken", (String) account.getAttributeValue("loginToken"));
    portletUrlBuilder.setPortletMode(PortletMode.VIEW);
    portletUrlBuilder.setWindowState(WindowState.MAXIMIZED);

    try {
        String path = fixPortletPath(request, builder);

        URL url = new URL(request.getScheme(), request.getServerName(), request.getServerPort(), path);

        notification.sendNotification(url, account, locale);
    } catch (MalformedURLException e) {
        log.error(e);
    }
}

From source file:org.cyk.ui.web.api.WebNavigationManager.java

public String getPath(String outcome, Boolean actionOutcome, Boolean partial) {
    FacesContext facesContext = FacesContext.getCurrentInstance();
    StringBuilder path = new StringBuilder();
    NavigationCase navigationCase = ((ConfigurableNavigationHandler) facesContext.getApplication()
            .getNavigationHandler()).getNavigationCase(facesContext, null, outcome);
    if (navigationCase == null) {
        log.severe("No Navigation Case found for " + outcome);
        return url(OUTCOME_NOT_FOUND, new Object[] { "oc", outcome }, Boolean.FALSE, Boolean.FALSE);
    }/*w  w  w  . ja v  a2s . c om*/
    String s = navigationCase.getToViewId(facesContext);
    if (Boolean.TRUE.equals(actionOutcome))
        path.append(s);
    else
        path.append(StringUtils.replace(s, FILE_STATIC_EXTENSION, FILE_PROCESSING_EXTENSION));

    if (Boolean.TRUE.equals(partial))
        ;
    else {
        HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext()
                .getRequest();
        path = new StringBuilder(StringUtils.removeStartIgnoreCase(//TODO might not work always
                FacesContext.getCurrentInstance().getExternalContext().encodeResourceURL(path.toString()),
                request.getContextPath()));
        path.insert(0, request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
                + request.getContextPath());
    }

    return path.toString();
}

From source file:axiom.servlet.AbstractServletClient.java

void sendRedirect(HttpServletRequest req, HttpServletResponse res, String url) {
    String location = url;//from   w  w  w .j av a2s  . c om

    if (url.indexOf("://") == -1) {
        // need to transform a relative URL into an absolute one
        String scheme = req.getScheme();
        StringBuffer loc = new StringBuffer(scheme);

        loc.append("://");
        String hostname = req.getServerName();
        boolean forwarded = false;
        if (req.getHeader("X-Forwarded-Host") != null) {
            hostname = req.getHeader("X-Forwarded-Host");
            forwarded = true;
        }
        loc.append(hostname);

        int p = (!forwarded) ? req.getServerPort() : 80;

        // check if we need to include server port
        if ((p > 0) && (("http".equals(scheme) && (p != 80)) || ("https".equals(scheme) && (p != 443)))) {
            loc.append(":");
            loc.append(p);
        }

        if (!url.startsWith("/")) {
            String requri = req.getRequestURI();
            int lastSlash = requri.lastIndexOf("/");

            if (lastSlash == (requri.length() - 1)) {
                loc.append(requri);
            } else if (lastSlash > -1) {
                loc.append(requri.substring(0, lastSlash + 1));
            } else {
                loc.append("/");
            }
        }

        loc.append(url);
        location = loc.toString();
    }

    // send status code 303 for HTTP 1.1, 302 otherwise
    if (isOneDotOne(req.getProtocol())) {
        res.setStatus(HttpServletResponse.SC_SEE_OTHER);
    } else {
        res.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
    }

    res.setContentType("text/html");
    res.setHeader("Location", location);
}

From source file:org.josso.selfservices.password.LostPasswordAction.java

@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    // We need the seccurity domain !!!
    prepareContext(request);//  w  w w.j  av  a 2 s .  co m

    String josso_cmd = getSSOCmd(request);

    SSOContext ctx = SSOContext.getCurrent();
    PasswordManagementService pwdService = ctx.getSecurityDomain().getPasswordManager();

    HttpSession session = request.getSession();

    // ProcessResponse previousProcessResponse = null;

    try {

        String processId = null;

        // We are starting a new lost password process.
        if (josso_cmd != null && josso_cmd.equals(JOSSO_CMD_LOST_PASSWORD)) {

            log.debug("Initializing lost password process");
            ProcessResponse pr = pwdService.startProcess("josso-simple-lostpassword");
            processId = pr.getProcessId();

            // Register a new url provider for this process
            final String pid = pr.getProcessId();
            final String baseUrl = request.getScheme() + "://" + request.getHeader("Host")
                    + request.getContextPath() + mapping.findForward("requestConfirmPassword").getPath()
                    + "?josso_cmd=" + JOSSO_CMD_CONFIRM_PASSWORD;

            // This will create a URL that will 
            LostPasswordUrlProvider lostPaswordUrlProvider = new LostPasswordUrlProvider() {
                public String provideResetUrl(String passwordAssertionId) {
                    return baseUrl + "&" + PARAM_JOSSO_PROCESS_ID + "=" + pid + "&" + "josso_"
                            + Constants.CHALLENGE_PWD_ASSERTION_ID + "=" + passwordAssertionId;
                }
            };

            pwdService.register(processId, Constants.EXT_URL_PROVIDER, lostPaswordUrlProvider);

            // Store process state and render view
            log.debug("Process First Step (forward) : " + pr.getNextStep());
            session.setAttribute(ATTR_LAST_PROCESS_RESPONSE, pr);

            return mapping.findForward(pr.getNextStep());

        }

        // We are processing a request for a running process.
        ProcessResponse pr = (ProcessResponse) session.getAttribute(ATTR_LAST_PROCESS_RESPONSE);
        if (pr == null) {
            processId = request.getParameter(PARAM_JOSSO_PROCESS_ID);
            if (log.isDebugEnabled())
                log.debug("Using process id [" + processId + "] from session");

        } else {

            processId = pr.getProcessId();

            if (log.isDebugEnabled())
                log.debug("Using process id [" + processId + "] from request");
        }

        // Move the process to the next step !

        ProcessRequest processRequest = pwdService.createRequest(processId);
        ChallengeResponseCredential[] challenges = fillChallengeResponses(
                (LostPasswordProcessState) pwdService.getProcessState(processId), form, request);
        processRequest.setAttribute(Constants.ATTR_CHALLENGES, challenges);

        ProcessResponse processResponse = pwdService.handleRequest(processRequest);
        session.setAttribute(ATTR_LAST_PROCESS_RESPONSE, processResponse);

        log.debug("Process Next Step (forward) : " + processResponse.getNextStep() + ". Final "
                + processResponse.isNextStepFinal());

        if (processResponse.getNextStep().equals(Constants.STEP_FATAL_ERROR)
                && processResponse.getAttribute("error") != null) {
            ActionErrors errors = new ActionErrors();
            errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("sso.error",
                    ((Exception) processResponse.getAttribute("error")).getMessage()));
            saveErrors(request, errors);

        }

        return mapping.findForward(processResponse.getNextStep());

    } catch (Exception e) {

        log.error("Error recovering password : " + e.getMessage(), e);
        request.setAttribute("error", e);

        // logs the error
        ActionErrors errors = new ActionErrors();
        errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("sso.error", e.getMessage()));
        saveErrors(request, errors);

        return mapping.findForward("fatalError");
    }

}

From source file:com.boyuanitsm.fort.web.rest.AccountResource.java

/**
 * POST  /register : register the user./*from  w  w  w.  j ava  2  s.c  o m*/
 *
 * @param managedUserDTO the managed user DTO
 * @param request the HTTP request
 * @return the ResponseEntity with status 201 (Created) if the user is registred or 400 (Bad Request) if the login or e-mail is already in use
 */
@RequestMapping(value = "/register", method = RequestMethod.POST, produces = { MediaType.APPLICATION_JSON_VALUE,
        MediaType.TEXT_PLAIN_VALUE })
@Timed
public ResponseEntity<?> registerAccount(@Valid @RequestBody ManagedUserDTO managedUserDTO,
        HttpServletRequest request) {

    HttpHeaders textPlainHeaders = new HttpHeaders();
    textPlainHeaders.setContentType(MediaType.TEXT_PLAIN);

    return userRepository.findOneByLogin(managedUserDTO.getLogin().toLowerCase())
            .map(user -> new ResponseEntity<>("login already in use", textPlainHeaders, HttpStatus.BAD_REQUEST))
            .orElseGet(() -> userRepository.findOneByEmail(managedUserDTO.getEmail())
                    .map(user -> new ResponseEntity<>("e-mail address already in use", textPlainHeaders,
                            HttpStatus.BAD_REQUEST))
                    .orElseGet(() -> {
                        User user = userService.createUserInformation(managedUserDTO.getLogin(),
                                managedUserDTO.getPassword(), managedUserDTO.getFirstName(),
                                managedUserDTO.getLastName(), managedUserDTO.getEmail().toLowerCase(),
                                managedUserDTO.getLangKey());
                        String baseUrl = request.getScheme() + // "http"
                        "://" + // "://"
                        request.getServerName() + // "myhost"
                        ":" + // ":"
                        request.getServerPort() + // "80"
                        request.getContextPath(); // "/myContextPath" or "" if deployed in root context

                        mailService.sendActivationEmail(user, baseUrl);
                        return new ResponseEntity<>(HttpStatus.CREATED);
                    }));
}

From source file:org.apache.struts2.views.util.DefaultUrlHelper.java

public String buildUrl(String action, HttpServletRequest request, HttpServletResponse response,
        Map<String, Object> params, String scheme, boolean includeContext, boolean encodeResult,
        boolean forceAddSchemeHostAndPort, boolean escapeAmp) {
    StringBuilder link = new StringBuilder();

    boolean changedScheme = false;

    // FIXME: temporary hack until class is made a properly injected bean
    Container cont = ActionContext.getContext().getContainer();
    int httpPort = Integer.parseInt(cont.getInstance(String.class, StrutsConstants.STRUTS_URL_HTTP_PORT));
    int httpsPort = Integer.parseInt(cont.getInstance(String.class, StrutsConstants.STRUTS_URL_HTTPS_PORT));

    // only append scheme if it is different to the current scheme *OR*
    // if we explicity want it to be appended by having forceAddSchemeHostAndPort = true
    if (forceAddSchemeHostAndPort) {
        String reqScheme = request.getScheme();
        changedScheme = true;//from w w  w. j  av  a  2 s  .c o  m
        link.append(scheme != null ? scheme : reqScheme);
        link.append("://");
        link.append(request.getServerName());

        if (scheme != null) {
            // If switching schemes, use the configured port for the particular scheme.
            if (!scheme.equals(reqScheme)) {
                if ((scheme.equals("http") && (httpPort != DEFAULT_HTTP_PORT))
                        || (scheme.equals("https") && httpsPort != DEFAULT_HTTPS_PORT)) {
                    link.append(":");
                    link.append(scheme.equals("http") ? httpPort : httpsPort);
                }
                // Else use the port from the current request.
            } else {
                int reqPort = request.getServerPort();

                if ((scheme.equals("http") && (reqPort != DEFAULT_HTTP_PORT))
                        || (scheme.equals("https") && reqPort != DEFAULT_HTTPS_PORT)) {
                    link.append(":");
                    link.append(reqPort);
                }
            }
        }
    } else if ((scheme != null) && !scheme.equals(request.getScheme())) {
        changedScheme = true;
        link.append(scheme);
        link.append("://");
        link.append(request.getServerName());

        if ((scheme.equals("http") && (httpPort != DEFAULT_HTTP_PORT))
                || (scheme.equals("https") && httpsPort != DEFAULT_HTTPS_PORT)) {
            link.append(":");
            link.append(scheme.equals("http") ? httpPort : httpsPort);
        }
    }

    if (action != null) {
        // Check if context path needs to be added
        // Add path to absolute links
        if (action.startsWith("/") && includeContext) {
            String contextPath = request.getContextPath();
            if (!contextPath.equals("/")) {
                link.append(contextPath);
            }
        } else if (changedScheme) {

            // (Applicable to Servlet 2.4 containers)
            // If the request was forwarded, the attribute below will be set with the original URL
            String uri = (String) request.getAttribute("javax.servlet.forward.request_uri");

            // If the attribute wasn't found, default to the value in the request object
            if (uri == null) {
                uri = request.getRequestURI();
            }

            link.append(uri.substring(0, uri.lastIndexOf('/') + 1));
        }

        // Add page
        link.append(action);
    } else {
        // Go to "same page"
        String requestURI = (String) request.getAttribute("struts.request_uri");

        // (Applicable to Servlet 2.4 containers)
        // If the request was forwarded, the attribute below will be set with the original URL
        if (requestURI == null) {
            requestURI = (String) request.getAttribute("javax.servlet.forward.request_uri");
        }

        // If neither request attributes were found, default to the value in the request object
        if (requestURI == null) {
            requestURI = request.getRequestURI();
        }

        link.append(requestURI);
    }

    //if the action was not explicitly set grab the params from the request
    if (escapeAmp) {
        buildParametersString(params, link, AMP);
    } else {
        buildParametersString(params, link, "&");
    }

    String result = link.toString();

    if (StringUtils.containsIgnoreCase(result, "<script")) {
        result = StringEscapeUtils.escapeEcmaScript(result);
    }
    try {
        result = encodeResult ? response.encodeURL(result) : result;
    } catch (Exception ex) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Could not encode the URL for some reason, use it unchanged", ex);
        }
        result = link.toString();
    }

    return result;
}

From source file:com.frequentis.maritime.mcsr.web.rest.AccountResource.java

/**
 * POST  /register : register the user./* ww w.ja v a  2  s.c  o  m*/
 *
 * @param managedUserDTO the managed user DTO
 * @param request the HTTP request
 * @return the ResponseEntity with status 201 (Created) if the user is registered or 400 (Bad Request) if the login or e-mail is already in use
 */
@RequestMapping(value = "/register", method = RequestMethod.POST, produces = { MediaType.APPLICATION_JSON_VALUE,
        MediaType.TEXT_PLAIN_VALUE })
@Timed
public ResponseEntity<?> registerAccount(@Valid @RequestBody ManagedUserDTO managedUserDTO,
        HttpServletRequest request) {

    HttpHeaders textPlainHeaders = new HttpHeaders();
    textPlainHeaders.setContentType(MediaType.TEXT_PLAIN);

    return userRepository.findFirstByLogin(managedUserDTO.getLogin().toLowerCase())
            .map(user -> new ResponseEntity<>("login already in use", textPlainHeaders, HttpStatus.BAD_REQUEST))
            .orElseGet(() -> userRepository.findFirstByEmail(managedUserDTO.getEmail())
                    .map(user -> new ResponseEntity<>("e-mail address already in use", textPlainHeaders,
                            HttpStatus.BAD_REQUEST))
                    .orElseGet(() -> {
                        User user = userService.createUserInformation(managedUserDTO.getLogin(),
                                managedUserDTO.getPassword(), managedUserDTO.getFirstName(),
                                managedUserDTO.getLastName(), managedUserDTO.getEmail().toLowerCase(),
                                managedUserDTO.getLangKey());
                        String baseUrl = request.getScheme() + // "http"
                        "://" + // "://"
                        request.getServerName() + // "myhost"
                        ":" + // ":"
                        request.getServerPort() + // "80"
                        request.getContextPath(); // "/myContextPath" or "" if deployed in root context

                        mailService.sendActivationEmail(user, baseUrl);
                        return new ResponseEntity<>(HttpStatus.CREATED);
                    }));
}