List of usage examples for org.apache.commons.lang Validate notEmpty
public static void notEmpty(String string)
Validate an argument, throwing IllegalArgumentException
if the argument String is empty (null
or zero length).
Validate.notEmpty(myString);
The message in the exception is 'The validated string is empty'.
From source file:com.vmware.identity.saml.DefaultSamlAuthorityFactory.java
@Override public TokenValidator createAuthnOnlyTokenValidator(String tenantName) throws NoSuchIdPException, SystemException { Validate.notEmpty(tenantName); return createAuthnOnlyTokenValidator(tenantName, getConfigExtractor(tenantName)); }
From source file:com.vmware.identity.samlservice.impl.AuthnRequestStateKerbAuthenticationFilter.java
@Override public void authenticate(AuthnRequestState t) throws SamlServiceException { log.debug("AuthnRequestStateKerbAuthenticationFilter.authenticate is called"); Validate.notNull(t);// w ww. j a v a2 s . co m IdmAccessor accessor = t.getIdmAccessor(); Validate.notNull(accessor); HttpServletRequest request = t.getRequest(); Validate.notNull(request); AuthnRequest authnRequest = t.getAuthnRequest(); Validate.notNull(authnRequest); GSSResult result = null; // call IDM to perform GSS auth String castleAuthParam = request.getParameter(Shared.REQUEST_AUTH_PARAM); Validate.notNull(castleAuthParam); castleAuthParam = castleAuthParam.replace(Shared.KERB_AUTH_PREFIX, "").trim(); String[] parts = castleAuthParam.split(" "); Validate.isTrue(parts.length == 1 || parts.length == 2); String browserAuthHeader = request.getHeader(Shared.IWA_AUTH_REQUEST_HEADER); String contextId = parts[0]; String encodedToken = null; if (parts.length == 1) { t.setKerbAuthnType(KerbAuthnType.IWA); if (browserAuthHeader == null) { t.setWwwAuthenticate(Shared.KERB_AUTH_PREFIX); t.setValidationResult( new ValidationResult(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized", null)); throw new SamlServiceException(); } else { encodedToken = browserAuthHeader.replace(Shared.KERB_AUTH_PREFIX, "").trim(); } } else { t.setKerbAuthnType(KerbAuthnType.CIP); encodedToken = parts[1]; } Validate.notEmpty(contextId); Validate.notEmpty(encodedToken); byte[] decodedAuthData = Base64.decode(encodedToken); try { result = accessor.authenticate(contextId, decodedAuthData); } catch (Exception ex) { // Could not authenticate with GSS, send browser login credential // error message. this allow user fall back to using password // authentication. ValidationResult vr = new ValidationResult(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized", null); t.setValidationResult(vr); throw new SamlServiceException(); } if (result != null) { if (!result.complete()) { // need additional auth exchange log.debug("Requesting more auth data"); String encodedAuthData = Shared.encodeBytes(result.getServerLeg()); if (t.getKerbAuthnType() == KerbAuthnType.CIP) { t.setWwwAuthenticate(Shared.KERB_AUTH_PREFIX + " " + contextId + " " + encodedAuthData); } else { t.setWwwAuthenticate(Shared.KERB_AUTH_PREFIX + " " + encodedAuthData); } t.setValidationResult( new ValidationResult(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized", null)); throw new SamlServiceException(); } PrincipalId principalId = result.getPrincipalId(); Validate.notNull(principalId); t.setPrincipalId(principalId); t.setAuthnMethod(AuthnMethod.KERBEROS); } }
From source file:com.netflix.simianarmy.aws.janitor.SimpleDBJanitorResourceTracker.java
@Override public Resource getResource(String resourceId) { Validate.notEmpty(resourceId); StringBuilder query = new StringBuilder(); query.append(String.format("select * from %s where resourceId = '%s'", domain, resourceId)); LOGGER.debug(String.format("Query is '%s'", query)); List<Item> items = querySimpleDBItems(query.toString()); Validate.isTrue(items.size() <= 1); if (items.size() == 0) { LOGGER.info(String.format("Not found resource with id %s", resourceId)); return null; } else {/*from w ww . j a v a 2 s. com*/ Resource resource = null; try { resource = parseResource(items.get(0)); } catch (Exception e) { // Ignore the item that cannot be parsed. LOGGER.error(String.format("SimpleDB item %s cannot be parsed into a resource.", items.get(0))); } return resource; } }
From source file:com.evolveum.liferay.usercreatehook.ws.ModelPortWrapper.java
/** * Should be called when user is deleted in LR. *///from www . j a v a 2 s . co m public static boolean deleteUser(String name) { Validate.notEmpty(name); boolean result = false; try { ModelPortType modelPort = getModelPort(); UserType user = searchUserByName(modelPort, StringEscapeUtils.escapeXml(name)); if (user == null) { // user with given screenname not found LOG.error("User with given screenname '" + name + "' not found in midpoint - giving up!"); } else { LOG.info("Deleting user with oid '" + user.getOid() + "'"); deleteUser(modelPort, user.getOid()); LOG.info("User with oid '" + user.getOid() + "' deleted successfully."); result = true; } } catch (Exception e) { LOG.error("Error while user delete in midpoint: " + e.getMessage(), e); } return result; }
From source file:com.lpm.fanger.commons.util.Reflections.java
/** * ?, ?DeclaredMethod,?.// ww w.j a v a 2s .c o m * ?Object?, null. * ???+? * * ?. ?Method,?Method.invoke(Object obj, Object... args) */ public static Method getAccessibleMethod(final Object obj, final String methodName, final Class<?>... parameterTypes) { Validate.notNull(obj, "object can't be null"); Validate.notNull(methodName, "method can't be null"); Validate.notEmpty(methodName); for (Class<?> searchType = obj.getClass(); searchType != Object.class; searchType = searchType .getSuperclass()) { try { Method method = searchType.getDeclaredMethod(methodName, parameterTypes); makeAccessible(method); return method; } catch (NoSuchMethodException e) { // Method??,? continue;// new add } } return null; }
From source file:com.umeng.core.utils.wurfl.SpringWurflManagerByMe.java
public void setWurflHolderKey(String wurflHolderKey) { Validate.notEmpty(wurflHolderKey); this.wurflHolderKey = wurflHolderKey; }
From source file:com.hmsinc.epicenter.model.permission.impl.PermissionRepositoryImpl.java
public void addOrganization(Organization organization) throws PermissionException { Validate.notNull(organization);/*from ww w. j a v a 2 s .c om*/ Validate.notEmpty(organization.getName()); long orgs = ((Long) namedQuery(entityManager, "getOrganizationCount") .setParameter("name", organization.getName()).getSingleResult()).longValue(); if (orgs > 0) { throw new PermissionException(PermissionExceptionType.ORGANIZATION_ALREADY_EXISTS, organization.getName()); } save(organization); }
From source file:com.edmunds.zookeeper.treewatcher.ZooKeeperTreeState.java
public void deleteNode(String path) { Validate.notEmpty(path); final ZooKeeperTreeNode node = pathMapping.get(path); Validate.notNull(node);//from w ww . j a v a 2 s.c om final ZooKeeperTreeNode parent = parentMapping.get(node); Validate.notNull(parent); deleteNodes(parent, Collections.singleton(node)); }
From source file:com.topsec.tsm.sim.util.TalVersionUtil.java
/** * @method: writeVersionFile //from www.ja v a2 s. c o m * ??. * @author: ?(yang_xuanjia@topsec.com.cn) * @param: newBuildVersion: ? * @return: null */ public synchronized void writeVersionFile(String newBuildVersion, String key) { Validate.notEmpty(newBuildVersion); Element readVersionFile = readVersionFile(); Element buildVersion = readVersionFile.element(key); buildVersion.setText(newBuildVersion); System.out.println(""); XMLWriter writer = null; try { writer = new XMLWriter(new FileWriter(new File(path + "buildVersion.xml"))); writer.write(readVersionFile); writer.flush(); } catch (Exception e) { e.printStackTrace(); } finally { if (writer != null) { try { writer.close(); } catch (Exception e2) { e2.printStackTrace(); } } } }
From source file:com.palantir.atlasdb.table.description.ColumnValueDescription.java
private ColumnValueDescription(Format format, String className, String canonicalClassName, Compression compression, Descriptor protoDescriptor) { this.compression = Preconditions.checkNotNull(compression); this.type = ValueType.BLOB; this.format = Preconditions.checkNotNull(format); Validate.notEmpty(className); Validate.notEmpty(canonicalClassName); Validate.isTrue(format != Format.VALUE_TYPE); this.canonicalClassName = Preconditions.checkNotNull(canonicalClassName); this.className = Preconditions.checkNotNull(className); this.protoDescriptor = protoDescriptor; }