Example usage for org.apache.shiro.util StringUtils hasText

List of usage examples for org.apache.shiro.util StringUtils hasText

Introduction

In this page you can find the example usage for org.apache.shiro.util StringUtils hasText.

Prototype

public static boolean hasText(String str) 

Source Link

Document

Check whether the given String has actual text.

Usage

From source file:com.rekoe.shiro.web.SimpleCookie.java

License:Apache License

private void appendComment(StringBuilder sb, String comment) {
    if (StringUtils.hasText(comment)) {
        sb.append(ATTRIBUTE_DELIMITER);/*from w  w w.  j  a v  a2  s . c o  m*/
        sb.append(COMMENT_ATTRIBUTE_NAME).append(NAME_VALUE_DELIMITER).append(comment);
    }
}

From source file:com.rekoe.shiro.web.SimpleCookie.java

License:Apache License

private void appendDomain(StringBuilder sb, String domain) {
    if (StringUtils.hasText(domain)) {
        sb.append(ATTRIBUTE_DELIMITER);/*from   w  w  w .j a  v  a 2  s.co m*/
        sb.append(DOMAIN_ATTRIBUTE_NAME).append(NAME_VALUE_DELIMITER).append(domain);
    }
}

From source file:com.rekoe.shiro.web.SimpleCookie.java

License:Apache License

private void appendPath(StringBuilder sb, String path) {
    if (StringUtils.hasText(path)) {
        sb.append(ATTRIBUTE_DELIMITER);//www.ja  v  a  2s.  co  m
        sb.append(PATH_ATTRIBUTE_NAME).append(NAME_VALUE_DELIMITER).append(path);
    }
}

From source file:com.sanweibook.lingdu.shiro.cache.RedisCacheManager.java

License:Apache License

@Override
public <K, V> Cache<K, V> getCache(String name) throws CacheException {
    if (!StringUtils.hasText(name)) {
        throw new CacheException("getCache the name cannot be null");
    }//from   w w  w . j  a  v  a  2  s  .  com
    Cache cache = caches.get(name);
    if (cache == null && StringUtils.hasText(prefixKey)) {
        cache = new RedisCache(redisClientTemplate, prefixKey);
    }
    caches.put(name, cache);
    return cache;
}

From source file:com.stormpath.shiro.authz.CustomDataPermissionsEditor.java

License:Apache License

@Override
public PermissionsEditor remove(String perm) {
    if (StringUtils.hasText(perm)) {
        Collection<String> perms = lookupPermissionStrings();
        if (!CollectionUtils.isEmpty(perms)) {
            if (perms instanceof List) {
                //hasn't yet been converted to a set that we maintain:
                String attrName = getFieldName();
                perms = asSet(attrName, (List) perms);
                CUSTOM_DATA.put(attrName, perms);
            }// w  w  w  .  ja v a2 s  .  c o m
            perms.remove(perm);
        }
    }
    return this;
}

From source file:com.stormpath.shiro.servlet.env.StormpathShiroEnvironmentLoaderListener.java

License:Apache License

@Override
public void contextInitialized(ServletContextEvent sce) {

    String environmentClassParam = sce.getServletContext()
            .getInitParameter(EnvironmentLoader.ENVIRONMENT_CLASS_PARAM);
    if (!StringUtils.hasText(environmentClassParam)) {
        sce.getServletContext().setInitParameter(EnvironmentLoader.ENVIRONMENT_CLASS_PARAM,
                StormpathShiroIniEnvironment.class.getName());
    }/*from  w ww  .  j  a v  a  2 s. c  om*/

    super.contextInitialized(sce);
}

From source file:com.zrk.oauthclient.shiro.support.UsernamePasswordAndClientRealm.java

License:Apache License

/**
 * Split a string into a list of not empty and trimmed strings, delimiter is
 * a comma./*w w  w . ja  va2 s . c  o  m*/
 *
 * @param s
 *            the input string
 * @return the list of not empty and trimmed strings
 */
protected List<String> split(final String s) {
    final List<String> list = new ArrayList<String>();
    final String[] elements = StringUtils.split(s, ',');
    if (elements != null && elements.length > 0) {
        for (final String element : elements) {
            if (StringUtils.hasText(element)) {
                list.add(element.trim());
            }
        }
    }
    return list;
}

From source file:de.elomagic.mag.RouteBuilderFactory.java

License:Apache License

/**
 * Returns URI of SMB component./*ww w  . jav  a  2s .  c o m*/
 * <p>
 * URI format = smb://[[[domain;]username[:password]@]server[:port]/[[share/[dir/]]]][?options]
 * <p>
 * Options:
 * <ul>
 * <li>password: <b>Mandatory</b> Specifies the password to use to log in to the remote file system.</li>
 * <li> localWorkDirectory: When consuming, a local work directory can be used to store the remote
 * file content directly in local files, to avoid loading the content into memory.
 * This is beneficial, if you consume a very big remote file and thus can conserve
 * memory. See below for more details.</li>
 * </ul>
 *
 * @return
 */
private static String getSmbUri() {
    StringBuilder sb = new StringBuilder("smb://");
    if (StringUtils.hasText(Configuration.get(ConfigurationKey.TargetSmbDomain))) {
        sb.append(Configuration.get(ConfigurationKey.TargetSmbDomain));
        sb.append(";");
    }

    sb.append(Configuration.get(ConfigurationKey.TargetSmbUsername));

    sb.append("@");

    sb.append(Configuration.get(ConfigurationKey.TargetSmbHostname));

    sb.append("/");

    if (StringUtils.hasText(Configuration.get(ConfigurationKey.TargetSmbShare))) {
        sb.append(Configuration.get(ConfigurationKey.TargetSmbShare));
    }

    sb.append("?localWorkDirectory=");
    sb.append(System.getProperty("java.io.tmpdir"));

    if (StringUtils.hasText(Configuration.get(ConfigurationKey.TargetSmbPassword))) {
        sb.append("&password=");
        sb.append(Configuration.get(ConfigurationKey.TargetSmbPassword));
    }

    return sb.toString();
}

From source file:graphene.web.components.security.LoginForm.java

License:Apache License

public String getLoginMessage() {
    if (StringUtils.hasText(loginMessage)) {
        return loginMessage;
    } else {/*w ww.j a  v  a 2 s . c  o  m*/
        return " ";
    }
}

From source file:io.buji.pac4j.ClientRealm.java

License:Apache License

/**
 * Split a string into a list of not empty and trimmed strings, delimiter is
 * a comma.//from   w  w  w  . j a  v  a2  s.  c om
 *
 * @param s
 *            the input string
 * @return the list of not empty and trimmed strings
 */
protected List<String> split(final String s) {
    final List<String> list = new ArrayList<>();
    final String[] elements = StringUtils.split(s, ',');
    if (elements != null && elements.length > 0) {
        for (final String element : elements) {
            if (StringUtils.hasText(element)) {
                list.add(element.trim());
            }
        }
    }
    return list;
}