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

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

Introduction

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

Prototype

public static boolean equals(final CharSequence cs1, final CharSequence cs2) 

Source Link

Document

Compares two CharSequences, returning true if they represent equal sequences of characters.

null s are handled without exceptions.

Usage

From source file:com.jiwhiz.web.filter.StaticResourcesProductionFilter.java

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
        throws IOException, ServletException {
    HttpServletRequest httpRequest = (HttpServletRequest) request;
    String contextPath = ((HttpServletRequest) request).getContextPath();
    String requestURI = httpRequest.getRequestURI();
    requestURI = StringUtils.substringAfter(requestURI, contextPath);
    if (StringUtils.equals("/", requestURI)) {
        requestURI = "/index.html";
    }/*  w  ww. j  a v a  2 s .c o  m*/
    String newURI = "/dist" + requestURI;
    request.getRequestDispatcher(newURI).forward(request, response);
}

From source file:ch.cyberduck.core.sftp.PreferencesHostKeyVerifier.java

@Override
public boolean verify(final String hostname, final int port, final PublicKey key)
        throws ConnectionCanceledException, ChecksumException {
    final String lookup = preferences.getProperty(this.getFormat(hostname, key));
    if (StringUtils.equals(Base64.toBase64String(key.getEncoded()), lookup)) {
        if (log.isInfoEnabled()) {
            log.info(String.format("Accepted host key %s matching %s", key, lookup));
        }/*from   w  ww .  j  a va 2s  .c  o  m*/
        return true;
    }
    final boolean accept;
    if (null == lookup) {
        accept = this.isUnknownKeyAccepted(hostname, key);
    } else {
        accept = this.isChangedKeyAccepted(hostname, key);
    }
    return accept;
}

From source file:com.mirth.connect.client.ui.codetemplate.CodeTemplateTreeTableNode.java

@Override
public Object getValueAt(int i) {
    // @formatter:off
    switch (i) {/*from w ww .  j  a  va  2  s  . c o m*/
    case CodeTemplatePanel.TEMPLATE_NAME_COLUMN:
        return codeTemplate.getName();
    case CodeTemplatePanel.TEMPLATE_ID_COLUMN:
        return codeTemplate.getId();
    case CodeTemplatePanel.TEMPLATE_TYPE_COLUMN:
        return codeTemplate.getType();
    case CodeTemplatePanel.TEMPLATE_DESCRIPTION_COLUMN:
        if (StringUtils.equals(CodeTemplateUtil.getDocumentation(CodeTemplate.DEFAULT_CODE).getDescription(),
                codeTemplate.getDescription())) {
            return null;
        }
        return codeTemplate.getDescription();
    case CodeTemplatePanel.TEMPLATE_REVISION_COLUMN:
        return codeTemplate.getRevision();
    case CodeTemplatePanel.TEMPLATE_LAST_MODIFIED_COLUMN:
        return codeTemplate.getLastModified();
    default:
        return null;
    }
    // @formatter:on
}

From source file:com.nagopy.android.xposed.SettingChangedReceiver.java

@Override
public void onReceive(Context context, Intent intent) {
    Object obj = dataObject.get();
    if (!StringUtils.equals(intent.getAction(), action) || obj == null) {
        context.unregisterReceiver(this);
        return;//from   w w w. j  a v a 2  s  .c  o m
    }

    Bundle extras = intent.getExtras();
    if (extras == null || extras.size() != 2) {
        return;
    }

    try {
        // target?value????????
        String target = extras.getString("target");
        Object value = extras.get("value");
        obj.getClass().getField(target).set(obj, value);

        onDataChanged();
    } catch (Throwable t) {
        Logger.e(getClass().getSimpleName(), Log.getStackTraceString(t));
    }
}

From source file:com.erudika.para.security.SimpleAuthenticationSuccessHandler.java

@Override
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response,
        Authentication authentication) throws IOException, ServletException {
    User u = SecurityUtils.getAuthenticatedUser(authentication);
    if (u != null) {
        if (!StringUtils.equals(request.getRemoteAddr(), u.getLastIp())) {
            u.setLastIp(request.getRemoteAddr());
            u.update();//from   w w  w .j  a  v a 2 s.  c  o  m
        }
    }
    if (isRestRequest(request)) {
        RestUtils.returnStatusResponse(response, HttpServletResponse.SC_NO_CONTENT, "Authentication success.");
    } else {
        super.onAuthenticationSuccess(request, response, authentication);
    }
}

From source file:architecture.ee.web.util.ServletUtils.java

public static String getContextPath(HttpServletRequest request) {

    if (StringUtils.isEmpty(request.getContextPath())) {
        return CONTEXT_ROOT_PATH;
    } else if (StringUtils.equals("/", request.getContextPath().trim())) {
        return CONTEXT_ROOT_PATH;
    } else {/* w w w  . j a  va2  s .c om*/
        return request.getContextPath();
    }
}

From source file:de.micromata.genome.gwiki.plugin.keywordsmarttags_1_0.GWikiKeywordPageChangedFilter.java

public Void filter(GWikiFilterChain<Void, GWikiPageChangedFilterEvent, GWikiPageChangedFilter> chain,
        GWikiPageChangedFilterEvent event) {
    GWikiKeywordLoadElementInfosFilter chf = GWikiKeywordLoadElementInfosFilter.getInstance();
    if (chf == null) {
        return chain.nextFilter(event);
    }/*from   www  .  j av  a 2 s  .co m*/

    if (event.getOldInfo() != null && event.getNewInfo() != null) {
        String oKeyWords = event.getOldInfo().getProps().getStringValue(GWikiPropKeys.KEYWORDS);
        String nKeyWords = event.getNewInfo().getProps().getStringValue(GWikiPropKeys.KEYWORDS);
        if (StringUtils.equals(oKeyWords, nKeyWords) == true) {
            return chain.nextFilter(event);
        }

    } else if (event.getOldInfo() != null) {
        String oKeyWords = event.getOldInfo().getProps().getStringValue(GWikiPropKeys.KEYWORDS);
        if (StringUtils.isEmpty(oKeyWords) == false) {
        } else {
            return chain.nextFilter(event);
        }
    } else if (event.getNewInfo() != null) {
        String nKeyWords = event.getNewInfo().getProps().getStringValue(GWikiPropKeys.KEYWORDS);
        if (StringUtils.isEmpty(nKeyWords) == false) {
        } else {
            return chain.nextFilter(event);
        }
    }
    chf.clearKeywords();
    event.getWikiWeb().getPageCache().clearCompiledFragments(GWikiWikiPageArtefakt.class);
    return chain.nextFilter(event);
}

From source file:cn.vlabs.clb.server.service.auth.IAppAuthService.java

public AppAuthInfo authenticate(String name, String password) {
    if (password == null) {
        password = "";
    }//from  w  w w . j av a  2s  . com
    AppAuthInfo appAuth = getAppAuthInfo(name);
    if (appAuth != null) {
        if (StringUtils.equals(password, appAuth.getPassword())) {
            return appAuth;
        } else {
            return null;
        }
    } else {
        AppAuthInfo info = new AppAuthInfo();
        info.setName(name);
        info.setPassword(password);
        int appid = dao.save(info);
        info.setId(appid);
        return info;
    }
}

From source file:de.dominikschadow.javasecurity.servlets.FormServlet.java

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    String name = request.getParameter("name");

    logger.info("Received {} as name", name);

    String result = "FAILURE";

    if (StringUtils.equals(name, "inject")) {
        result = "SUCCESS";
    }//from   w w w . ja v a2s. co m

    response.setContentType("text/html");

    try (PrintWriter out = response.getWriter()) {
        out.println("<html><head>");
        out.println("<title>InterceptMe</title>");
        out.println("<link rel=\"stylesheet\" type=\"text/css\" href=\"resources/css/styles.css\" />");
        out.println("</head>");
        out.println("<body>");
        out.println("<h1>InterceptMe</h1>");
        out.println("<p>" + result + "</p>");
        out.println("<p><a href=\"index.jsp\">Home</a></p>");
        out.println("</body></html>");
    } catch (IOException ex) {
        logger.error(ex.getMessage(), ex);
    }
}

From source file:de.micromata.genome.gwiki.model.matcher.GWikiElementTypeMatcher.java

@Override
public boolean match(GWikiElementInfo ei) {
    if (ei.getMetaTemplate() == null) {
        GWikiLog.warn("Element without metatemplate: " + ei.getId());
        return false;
    }// ww  w .j  a va 2s. c o m
    final String et = ei.getMetaTemplate().getElementType();
    return StringUtils.equals(elementType, et);
}