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

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

Introduction

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

Prototype

public static boolean equals(String str1, String str2) 

Source Link

Document

Compares two Strings, returning true if they are equal.

Usage

From source file:com.cyclopsgroup.waterview.jelly.taglib.JellyScriptTag.java

/**
 * Overwrite or implement method processTag()
 *
 * @see com.cyclopsgroup.waterview.utils.TagSupportBase#processTag(org.apache.commons.jelly.XMLOutput)
 *//*from   w  w  w. ja  v  a 2s  .  c o m*/
protected void processTag(XMLOutput output) throws Exception {
    requireAttribute("type");
    requireAttribute("path");
    Script script = null;
    if (StringUtils.equals(getType(), "system")) {
        JellyEngine je = (JellyEngine) getServiceManager().lookup(JellyEngine.ROLE);
        script = je.getScript(getPath());
    } else if (StringUtils.equals(getType(), "classpath")) {
        URL resource = getClass().getClassLoader().getResource(getPath());
        if (resource != null) {
            script = context.compileScript(resource);
        }
    } else if (StringUtils.equals(getType(), "file")) {
        File file = new File(getPath());
        if (file.exists()) {
            script = context.compileScript(file.toURL());
        }
    } else {
        throw new JellyTagException("Type must be system|classpath|file, default value is system");
    }
    if (script == null) {
        throw new FileNotFoundException("Resource " + getPath() + " is not found in " + getType());
    }
    JellyContext jc = new JellyContext(getContext());
    if (script != null) {
        script.run(jc, output);
        output.flush();
    }
}

From source file:com.activecq.samples.loginmodule.SampleAuthentication.java

@Override
public boolean authenticate(Credentials credentials) throws RepositoryException {
    if (!(credentials instanceof SimpleCredentials)) {
        return false;
    }// w  ww  . j  av a 2s . co m

    SimpleCredentials simpleCredentials = (SimpleCredentials) credentials;
    final String userId = simpleCredentials.getUserID();

    return StringUtils.equals(userId, "davidg");
}

From source file:com.kelson.keeku.security.MyFormAuthenticationFilter.java

@Override
protected boolean executeLogin(ServletRequest request, ServletResponse response) throws Exception {
    String username = getUsername(request);
    String password = getPassword(request);
    boolean isAjaxLogin = StringUtils.equals(WebUtils.getCleanParam(request, "ajaxLogin"), "1");
    boolean rememberMe = isRememberMe(request);
    String host = getHost(request);
    UsernamePasswordToken token = new UsernamePasswordToken(username, password, rememberMe, host);

    try {//from w ww.  j a  v  a 2  s . co  m
        Subject subject = getSubject(request, response);
        subject.login(token);
        Session session = subject.getSession();
        Integer userId = (Integer) session.getAttribute("userId");
        LoggerUtil.operation(Operation.Login, String.valueOf(userId) + "has logined",
                (HttpServletRequest) request);
        if (isAjaxLogin) {
            if (StringUtils.equals(WebUtils.getCleanParam(request, "needRedirect"), "1")) {//when login successfully by ajax login and redirect to backurl
                SavedRequest savedRequest = WebUtils.getAndClearSavedRequest(request);
                if (savedRequest != null
                        && savedRequest.getMethod().equalsIgnoreCase(AccessControlFilter.GET_METHOD)) {
                    request.setAttribute("backUrl", savedRequest.getRequestUrl());
                }
            }
            return true;
        } else {
            return onLoginSuccess(token, subject, request, response);
        }
    } catch (AuthenticationException e) {
        if (SecurityUtils.getSubject().getSession(false) != null) {
            SecurityUtils.getSubject().getSession(false).removeAttribute("userId");
        }
        return onLoginFailure(token, e, request, response);
    }
}

From source file:com.iggroup.oss.restdoclet.doclet.util.ControllerTypePredicate.java

/**
 * {@inheritDoc}// www. j  a  v  a 2s.com
 */
public boolean evaluate(final Object object) {
    boolean result;
    if (object instanceof ControllerSummary) {
        result = StringUtils.equals(type, ((ControllerSummary) object).getType());
    } else {
        result = false;
    }
    return result;
}

From source file:com.cyclopsgroup.tornado.ui.action.admin.security.SaveUserAction.java

/**
 * Overwrite or implement method execute()
 *
 * @see com.cyclopsgroup.waterview.Action#execute(com.cyclopsgroup.waterview.RuntimeData, com.cyclopsgroup.waterview.ActionContext)
 *///from   w ww  .  ja v  a2  s  .  co  m
public void execute(RuntimeData data, ActionContext context) throws Exception {
    String newPassword = data.getParameters().getString("new_password");
    if (StringUtils.isNotEmpty(newPassword)
            && !StringUtils.equals(newPassword, data.getParameters().getString("confirmed_password"))) {
        context.error("confirmed_password", "Two passwords are not the same");
        return;
    }

    PersistenceManager persist = (PersistenceManager) lookup(PersistenceManager.ROLE);
    User user = (User) persist.load(User.class, data.getParameters().getString("user_id"));

    TypeUtils.getBeanUtils().copyProperties(user, data.getParameters().toProperties());
    if (StringUtils.isNotEmpty(newPassword)) {
        user.setPrivatePassword(newPassword);
    }
    persist.update(user);
    context.addMessage("User " + user.getDisplayName() + " is changed");
}

From source file:ddf.registry.service.internal.DynamicServiceResolverRegistry.java

@Override
public String getServiceType(String factoryPid) {
    for (DynamicServiceIdentifier identifier : identifiers) {
        if (StringUtils.equals(factoryPid, identifier.getFactoryIdentifier())) {
            return identifier.getServiceType();
        }//from   w  w  w .j a  v  a  2  s.c o m
    }
    LOGGER.info("No Service Type found for {}, returning a 'null' type.", factoryPid);
    return null;
}

From source file:com.qrmedia.commons.persistence.hibernate.clone.SimplePropertyEqualStubHibernateEntity.java

@Override
public boolean equals(Object obj) {

    if (this == obj) {
        return true;
    }/*from  ww  w.j  av  a 2 s  .  com*/

    if (!(obj instanceof SimplePropertyEqualStubHibernateEntity)) {
        return false;
    }

    return StringUtils.equals(simpleBeanProperty,
            ((SimplePropertyEqualStubHibernateEntity) obj).simpleBeanProperty);
}

From source file:com.mewmew.fairy.v1.book.Xargs.java

@Override
public void before() {
    super.before();
    if (StringUtils.equals("{}", token)) {
        token = "\\{\\}";
    }//from  w  w  w .j av  a2 s .  c o m
}

From source file:com.steeleforge.aem.ironsites.wcm.page.filter.property.StringEqualsFilter.java

public boolean propertyEquals(Page page, String property, Object value) {
    return StringUtils.equals(page.getProperties().get(property, String.class), value.toString());
}

From source file:io.kamax.mxisd.notification.NotificationManager.java

@Autowired
public NotificationManager(NotificationConfig cfg, List<INotificationHandler> handlers) {
    this.handlers = new HashMap<>();
    handlers.forEach(h -> {/*from   ww  w.  java 2s.  c  om*/
        log.info("Found handler {} for medium {}", h.getId(), h.getMedium());
        String handlerId = cfg.getHandler().getOrDefault(h.getMedium(), "raw");
        if (StringUtils.equals(handlerId, h.getId())) {
            this.handlers.put(h.getMedium(), h);
        }
    });

    log.info("--- Notification handler ---");
    this.handlers.forEach((k, v) -> log.info("\tHandler for {}: {}", k, v.getId()));
}