Example usage for org.apache.commons.lang StringUtils lowerCase

List of usage examples for org.apache.commons.lang StringUtils lowerCase

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils lowerCase.

Prototype

public static String lowerCase(String str) 

Source Link

Document

Converts a String to lower case as per String#toLowerCase() .

Usage

From source file:info.magnolia.init.DefaultMagnoliaInitPaths.java

/**
 * Figures out the local host name, makes sure it's lowercase, and use its unqualified name if the {@value #MAGNOLIA_UNQUALIFIED_SERVER_NAME} init parameter is set to true.
 *///from  w  w w . j a v  a  2 s.  c o  m
protected String determineServerName(ServletContext context) {
    final boolean unqualifiedServerName = BooleanUtils
            .toBoolean(context.getInitParameter(MAGNOLIA_UNQUALIFIED_SERVER_NAME));
    final String retroCompatMethodCall = magnoliaServletContextListener.initServername(unqualifiedServerName);
    if (retroCompatMethodCall != null) {
        DeprecationUtil.isDeprecated(
                "You should update your code and override determineServerName(ServletContext) instead of initServername(String)");
        return retroCompatMethodCall;
    }

    try {
        String serverName = StringUtils.lowerCase(InetAddress.getLocalHost().getHostName());

        if (unqualifiedServerName && StringUtils.contains(serverName, ".")) {
            serverName = StringUtils.substringBefore(serverName, ".");
        }
        return serverName;
    } catch (UnknownHostException e) {
        log.error(e.getMessage());
        return null;
    }
}

From source file:com.sonicle.webtop.core.app.shiro.WTRealm.java

@Override
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
    if (token instanceof UsernamePasswordToken) {
        UsernamePasswordToken upt = (UsernamePasswordToken) token;

        String domainId = null;//from w  ww .  j a v a 2  s.com
        if (token instanceof UsernamePasswordDomainToken) {
            domainId = ((UsernamePasswordDomainToken) token).getDomain();
        }
        //logger.debug("isRememberMe={}",upt.isRememberMe());

        String sprincipal = (String) upt.getPrincipal();
        String internetDomain = StringUtils.lowerCase(StringUtils.substringAfterLast(sprincipal, "@"));
        String username = StringUtils.substringBeforeLast(sprincipal, "@");
        logger.trace("doGetAuthenticationInfo [{}, {}, {}]", domainId, internetDomain, username);

        Principal principal = authenticateUser(domainId, internetDomain, username, upt.getPassword());

        // Update token with new values resulting from authentication
        if (token instanceof UsernamePasswordDomainToken) {
            ((UsernamePasswordDomainToken) token).setDomain(principal.getDomainId());
        }
        upt.setUsername(principal.getUserId());

        return new WTAuthenticationInfo(principal, upt.getPassword(), this.getName());

    } else {
        return null;
    }
}

From source file:com.epam.storefront.security.AcceleratorAuthenticationProvider.java

/**
 * @param authentication//from   w  w w .j av  a 2s .co m
 * @param username
 * @return
 */
private Authentication doAuth(final Authentication authentication, final String username) {
    try {
        final Authentication authResult = super.authenticate(authentication);

        if (authResult.isAuthenticated() && !StringUtils.isEmpty(username)) {
            final UserModel userModel = getUserService().getUserForUID(StringUtils.lowerCase(username));

            if (userModel instanceof CustomerModel) {
                final CustomerModel customerModel = (CustomerModel) userModel;

                customerModel.setAttemptCount(Integer.valueOf(0));

                getModelService().save(customerModel);

                bruteForceAttackCounter.resetUserCounter(userModel.getUid());
            }
        }

        return authResult;
    } catch (BadCredentialsException badCredentialsException) {
        if (!StringUtils.isEmpty(username)) {
            final UserModel userModel = getUserService().getUserForUID(StringUtils.lowerCase(username));

            if (userModel instanceof CustomerModel) {
                final CustomerModel customerModel = (CustomerModel) userModel;

                final int attemptCount = customerModel.getAttemptCount() != null
                        ? customerModel.getAttemptCount().intValue()
                        : 0;

                customerModel.setAttemptCount(Integer.valueOf(attemptCount + 1));

                getModelService().save(customerModel);
            }
        }

        throw badCredentialsException;
    } catch (AuthenticationException authenticationException) {
        throw authenticationException;
    }
}

From source file:com.abssh.util.Page.java

/**
 * ???.//from www.j  a  va 2  s. c om
 * 
 * @param order
 *            ?descasc,?','.
 */
public void setOrder(final String order) {
    // order?
    if (order == null) {
        return;
    }
    String[] orders = StringUtils.split(StringUtils.lowerCase(order), ',');
    for (String orderStr : orders) {
        if (!StringUtils.equals(DESC, orderStr) && !StringUtils.equals(ASC, orderStr)) {
            throw new IllegalArgumentException("??" + orderStr + "??");
        }
    }

    this.order = StringUtils.lowerCase(order);
}

From source file:net.shopxx.entity.Admin.java

@PrePersist
public void prePersist() {
    setUsername(StringUtils.lowerCase(getUsername()));
    setEmail(StringUtils.lowerCase(getEmail()));
    setLockKey(DigestUtils.md5Hex(UUID.randomUUID() + RandomStringUtils.randomAlphabetic(30)));
}

From source file:cec.easyshop.storefront.controllers.cms.AbstractCMSComponentController.java

protected String getView(final T component) {
    // build a jsp response based on the component type
    return ControllerConstants.Views.Cms.ComponentPrefix + StringUtils.lowerCase(getTypeCode(component));
}

From source file:de.hybris.platform.accountsummaryaddon.controllers.cms.AbstractCMSComponentController.java

protected String getView(final T component) {
    // build a jsp response based on the component type
    return AccountSummaryAddonControllerConstants.Views.Cms.ComponentPrefix
            + StringUtils.lowerCase(getTypeCode(component));
}

From source file:info.magnolia.cms.taglibs.util.ImgTag.java

/**
 * @see javax.servlet.jsp.tagext.TagSupport#doEndTag()
 */// ww  w.j av  a  2s .  c o m
public int doEndTag() throws JspException {
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

    Content contentNode = getFirtMatchingNode();
    if (contentNode == null) {
        return EVAL_PAGE;
    }

    NodeData imageNodeData = contentNode.getNodeData(this.nodeDataName);

    if (!imageNodeData.isExist()) {
        return EVAL_PAGE;
    }

    FileProperties props = new FileProperties(contentNode, this.nodeDataName);
    String imgSrc = props.getProperty(FileProperties.PATH);

    String altNodeDataNameDef = this.altNodeDataName;
    if (StringUtils.isEmpty(altNodeDataNameDef)) {
        altNodeDataNameDef = nodeDataName + "Alt";
    }

    String alt = contentNode.getNodeData(altNodeDataNameDef).getString();

    if (StringUtils.isEmpty(alt)) {
        alt = props.getProperty(FileProperties.NAME_WITHOUT_EXTENSION);
    }

    JspWriter out = pageContext.getOut();

    // don't modify the original map, remember tag pooling
    Map attributes = new HashMap(htmlAttributes);
    attributes.put("title", alt);

    if (!attributes.containsKey("width") && !attributes.containsKey("height")) {
        String width = props.getProperty(FileProperties.PROPERTY_WIDTH);
        if (StringUtils.isNotEmpty(width)) {
            attributes.put("width", width);
        }

        String height = props.getProperty(FileProperties.PROPERTY_HEIGHT);
        if (StringUtils.isNotEmpty(height)) {
            attributes.put("height", height);
        }
    }

    try {
        if (StringUtils.lowerCase(imgSrc).endsWith(".swf")) {
            // handle flash movies

            out.write("<object type=\"application/x-shockwave-flash\" data=\"");
            out.write(request.getContextPath());
            out.write(imgSrc);
            out.write("\" ");
            writeAttributes(out, attributes);
            out.write(">");

            out.write("<param name=\"movie\" value=\"");
            out.write(request.getContextPath());
            out.write(imgSrc);
            out.write("\"/>");
            out.write("</object>");

        } else {

            attributes.put("alt", alt);

            out.write("<img src=\"");
            out.write(request.getContextPath());
            out.write(imgSrc);
            out.write("\" ");

            writeAttributes(out, attributes);
            out.write("/>");
        }
    } catch (IOException e) {
        // should never happen
        throw new NestableRuntimeException(e);
    }

    return super.doEndTag();
}

From source file:net.shopxx.entity.Admin.java

@PreUpdate
public void preUpdate() {
    setEmail(StringUtils.lowerCase(getEmail()));
}

From source file:com.adobe.acs.commons.workflow.process.impl.WorkflowDelegationStep.java

@Override
public void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metadata)
        throws WorkflowException {

    Map<String, String> args = getProcessArgsMap(metadata);

    String propertyName = args.get(WORKFLOW_PROPERTY_NAME);
    String defaultWorkflowModelId = args.get(DEFAULT_WORKFLOW_MODEL);
    boolean terminateOnDelegation = Boolean
            .parseBoolean(StringUtils.lowerCase(args.get(TERMINATE_ON_DELEGATION)));

    if (StringUtils.isBlank(propertyName)) {
        throw new WorkflowException("PROCESS_ARG [ " + WORKFLOW_PROPERTY_NAME + " ] not defined");
    }//  w  w  w  .j av a 2  s .  c om

    log.debug("Provided PROCESS_ARGS: propertyName = [ {} ], Default Workflow Model = [ {} ]", propertyName,
            defaultWorkflowModelId);

    ResourceResolver resolver = null;
    WorkflowData wfData = workItem.getWorkflowData();

    if (!workflowHelper.isPathTypedPayload(wfData)) {
        log.warn("Could not locate a JCR_PATH payload for this workflow. Skipping delegation.");
        return;
    }

    final String path = wfData.getPayload().toString();

    // Get the resource resolver

    resolver = workflowHelper.getResourceResolver(workflowSession);
    if (resolver == null) {
        throw new WorkflowException(
                "Could not adapt the WorkflowSession to a ResourceResolver. Something has gone terribly wrong!");
    }

    // Derive the Page or Asset resource so we have a normalized entry-point for finding the /jcr:content resource

    final Resource pageOrAssetResource = workflowHelper.getPageOrAssetResource(resolver, path);
    if (pageOrAssetResource == null) {
        log.warn("Could not resolve [ {} ] to an Asset or Page. Skipping delegation.", path);
        return;
    }

    // Get the Asset or Page's jcr:content resource, so we have a common inherited property look-up scheme

    final Resource jcrContentResource = pageOrAssetResource.getChild(JcrConstants.JCR_CONTENT);
    if (jcrContentResource == null) {
        throw new WorkflowException(String.format("Could not find a child jcr:content resource for [ %s ]",
                pageOrAssetResource.getPath()));
    }

    // Look up the content-hierarchy for the delegate workflow model

    final InheritanceValueMap inheritance = new HierarchyNodeInheritanceValueMap(jcrContentResource);
    final String foundWorkflowModelId = StringUtils.trim(inheritance.getInherited(propertyName, String.class));
    final WorkflowModel delegateWorkflowModel = getDelegateWorkflowModel(workflowSession, foundWorkflowModelId,
            defaultWorkflowModelId);

    if (delegateWorkflowModel != null) {
        workflowSession.startWorkflow(delegateWorkflowModel, wfData);
        log.info("Delegating payload [ {} ] to Workflow Model [ {} ]", wfData.getPayload(),
                delegateWorkflowModel.getId());

        if (terminateOnDelegation) {
            log.info("Terminating current workflow due to PROCESS_ARGS[ {} ] = [ {} ]", TERMINATE_ON_DELEGATION,
                    terminateOnDelegation);
            workflowSession.terminateWorkflow(workItem.getWorkflow());
        }
    } else {
        log.warn("No valid delegate Workflow Model could be located. Skipping workflow delegation.");
    }
}