Example usage for org.springframework.util Assert hasLength

List of usage examples for org.springframework.util Assert hasLength

Introduction

In this page you can find the example usage for org.springframework.util Assert hasLength.

Prototype

public static void hasLength(@Nullable String text, Supplier<String> messageSupplier) 

Source Link

Document

Assert that the given String is not empty; that is, it must not be null and not the empty String.

Usage

From source file:org.acegisecurity.captcha.CaptchaEntryPoint.java

public void afterPropertiesSet() throws Exception {
    Assert.hasLength(captchaFormUrl, "captchaFormUrl must be specified");
    Assert.hasLength(originalRequestMethodParameterName,
            "originalRequestMethodParameterName must be specified");
    Assert.hasLength(originalRequestParametersNameValueSeparator,
            "originalRequestParametersNameValueSeparator must be specified");
    Assert.hasLength(originalRequestParametersParameterName,
            "originalRequestParametersParameterName must be specified");
    Assert.hasLength(originalRequestParametersSeparator,
            "originalRequestParametersSeparator must be specified");
    Assert.hasLength(originalRequestUrlParameterName, "originalRequestUrlParameterName must be specified");
    Assert.hasLength(urlEncodingCharset, "urlEncodingCharset must be specified");
    Assert.notNull(portMapper, "portMapper must be specified");
    Assert.notNull(portResolver, "portResolver must be specified");
    URLEncoder.encode("   fzaef &  ", urlEncodingCharset);
}

From source file:org.acegisecurity.ldap.DefaultInitialDirContextFactory.java

/**
 * Set the LDAP url/*from  w  w  w  .ja va 2 s  .co  m*/
 *
 * @param providerUrl a String of the form <code>ldap://localhost:389/base_dn<code>
 */
private void setProviderUrl(String providerUrl) {
    Assert.hasLength(providerUrl, "An LDAP connection URL must be supplied.");

    this.providerUrl = providerUrl;

    StringTokenizer st = new StringTokenizer(providerUrl);

    // Work out rootDn from the first URL and check that the other URLs (if any) match
    while (st.hasMoreTokens()) {
        String url = st.nextToken();
        String urlRootDn = LdapUtils.parseRootDnFromUrl(url);

        logger.info(" URL '" + url + "', root DN is '" + urlRootDn + "'");

        if (rootDn == null) {
            rootDn = urlRootDn;
        } else if (!rootDn.equals(urlRootDn)) {
            throw new IllegalArgumentException("Root DNs must be the same when using multiple URLs");
        }
    }

    // This doesn't necessarily hold for embedded servers.
    //Assert.isTrue(uri.getScheme().equals("ldap"), "Ldap URL must start with 'ldap://'");
}

From source file:org.acegisecurity.ldap.DefaultInitialDirContextFactory.java

public void setAuthenticationType(String authenticationType) {
    Assert.hasLength(authenticationType, "LDAP Authentication type must not be empty or null");
    this.authenticationType = authenticationType;
}

From source file:org.acegisecurity.ldap.DefaultInitialDirContextFactory.java

public void setInitialContextFactory(String initialContextFactory) {
    Assert.hasLength(initialContextFactory, "Initial context factory name cannot be empty or null");
    this.initialContextFactory = initialContextFactory;
}

From source file:org.acegisecurity.ldap.DefaultInitialDirContextFactory.java

/**
 * Sets the directory user to authenticate as when obtaining a context using the
 * <tt>newInitialDirContext()</tt> method.
 * If no name is supplied then the context will be obtained anonymously.
 *
 * @param managerDn The name of the "manager" user for default authentication.
 *///  w  w  w.  j  a v a2 s  .  com
public void setManagerDn(String managerDn) {
    Assert.hasLength(managerDn, "Manager user name  cannot be empty or null.");
    this.managerDn = managerDn;
}

From source file:org.acegisecurity.ldap.DefaultInitialDirContextFactory.java

/**
 * Sets the password which will be used in combination with the manager DN.
 *
 * @param managerPassword The "manager" user's password.
 *///  w  w w .  j  a  v  a2 s . co  m
public void setManagerPassword(String managerPassword) {
    Assert.hasLength(managerPassword, "Manager password must not be empty or null.");
    this.managerPassword = managerPassword;
}

From source file:org.acegisecurity.providers.anonymous.AnonymousAuthenticationProvider.java

public void afterPropertiesSet() throws Exception {
    Assert.hasLength(key, "A Key is required");
    Assert.notNull(this.messages, "A message source must be set");
}

From source file:org.acegisecurity.providers.cas.ticketvalidator.AbstractTicketValidator.java

public void afterPropertiesSet() throws Exception {
    Assert.hasLength(casValidate, "A casValidate URL must be set");
    Assert.notNull(serviceProperties, "serviceProperties must be specified");

    if ((trustStore != null) && (!"".equals(trustStore))) {
        if (logger.isDebugEnabled()) {
            logger.debug(/* w w  w.  jav a2 s .co  m*/
                    "Setting system property 'javax.net.ssl.trustStore'" + " to value [" + trustStore + "]");
        }

        System.setProperty("javax.net.ssl.trustStore", trustStore);
    }
}

From source file:org.acegisecurity.providers.jaas.JaasAuthenticationProvider.java

public void afterPropertiesSet() throws Exception {
    Assert.notNull(loginConfig, "loginConfig must be set on " + getClass());
    Assert.hasLength(loginContextName, "loginContextName must be set on " + getClass());

    configureJaas(loginConfig);//from   www  .  j  a va  2 s  .c  o m

    Assert.notNull(Configuration.getConfiguration(),
            "As per http://java.sun.com/j2se/1.5.0/docs/api/javax/security/auth/login/Configuration.html "
                    + "\"If a Configuration object was set via the Configuration.setConfiguration method, then that object is "
                    + "returned. Otherwise, a default Configuration object is returned\". Your JRE returned null to "
                    + "Configuration.getConfiguration().");
}

From source file:org.acegisecurity.providers.ldap.authenticator.PasswordComparisonAuthenticator.java

public void setPasswordAttributeName(String passwordAttribute) {
    Assert.hasLength(passwordAttribute, "passwordAttributeName must not be empty or null");
    this.passwordAttributeName = passwordAttribute;
}