List of usage examples for org.apache.commons.lang StringUtils isAlphanumeric
public static boolean isAlphanumeric(String str)
Checks if the String contains only unicode letters or digits.
From source file:GestoreAccountLocale.GestoreAccountLocale.java
private static void checkCognome(String cognome) throws VincoliInputException { if (cognome == null) { throw new VincoliInputException(ErrorLabels.COGNOME_NOT_SPECIFICIED_ITA); }//from w ww . j ava 2 s. c om if (!(cognome.length() >= 1 && cognome.length() <= 50)) { throw new VincoliInputException(ErrorLabels.COGNOME_LENGTH_ERROR_ITA); } if (!StringUtils.isAlphanumeric(cognome)) { throw new VincoliInputException(ErrorLabels.COGNOME_IS_NOT_ALPHANUMERIC_ITA); } }
From source file:br.com.nordestefomento.jrimum.domkee.financeiro.banco.febraban.Agencia.java
public void verify() { if (codigo < 0) { throw new IllegalArgumentException( "O cdigo da agncia deve ser um inteiro natural (incluindo zero)"); }/*w w w . j ava2 s . c o m*/ if (String.valueOf(codigo).length() > 5) { throw new IllegalArgumentException("O cdigo da agncia deve possuir de 1 a 5 dgitos"); } if (StringUtils.isBlank(digitoVerificador)) { throw new IllegalArgumentException( "O dgito verificador da agncia no pode ser null ou apenas espaos em branco"); } if (digitoVerificador.length() > 1) { throw new IllegalArgumentException("O dgito verificador da agncia deve possuir apenas um dgito"); } if (!StringUtils.isAlphanumeric(digitoVerificador)) { throw new IllegalArgumentException("O dgito verificador da agncia deve ser letra ou dgito"); } }
From source file:edu.virginia.speclab.juxta.author.view.DocumentSourceCard.java
/** * Scroll the text area to center on the specified offset and * highlight the xml tag found there./*from w ww .j av a 2 s .c o m*/ * * @param origOffset */ public void highlightText(int origOffset, boolean fullTag) { try { this.dsTextArea.setSelectedTextColor(JuxtaUserInterfaceStyle.SECOND_COLOR); this.dsTextArea.grabFocus(); this.dsTextArea.getHighlighter().removeAllHighlights(); boolean foundStart = false; boolean foundEnd = false; int s = origOffset; int e = origOffset; int len = this.getDocument().getSourceDocument().getRawXMLContent().length(); while (!(foundEnd == true && foundStart == true)) { if (foundStart == false) { if (s <= 0) { foundStart = true; } else { char sc = this.getDocument().getSourceDocument().getRawXMLContent().charAt(--s); if (fullTag == false) { if (StringUtils.isAlphanumeric(String.valueOf(sc)) == false) { foundStart = true; } } else { foundStart = (sc == '>'); } } } if (foundEnd == false) { if (e >= len - 1) { foundEnd = true; } else { char ec = this.getDocument().getSourceDocument().getRawXMLContent().charAt(++e); if (fullTag == false) { if (StringUtils.isAlphanumeric(String.valueOf(ec)) == false) { foundEnd = true; } } else { foundEnd = (ec == '<'); } } } } this.dsTextArea.setSelectionStart(s + 1); this.dsTextArea.setSelectionEnd(e); int txtCenter = s + (e - s) / 2; // first scroll to start, then to specified offset. // this allows back scrolling to work this.dsTextArea.scrollRectToVisible(this.dsTextArea.modelToView(0)); Rectangle comparandRect = this.dsTextArea.modelToView(txtCenter); if (comparandRect != null) { Rectangle viewRect = this.dsTextArea.getVisibleRect(); comparandRect.y += viewRect.height / 2; this.dsTextArea.scrollRectToVisible(comparandRect); } } catch (BadLocationException e) { e.printStackTrace(); } }
From source file:net.sf.sail.webapp.presentation.validators.ChangePasswordParametersValidator.java
public void validatePasswordAlphaNumeric(Errors errors, String passwd) { if (!StringUtils.isAlphanumeric(passwd)) errors.rejectValue("passwd1", "error.password-illegal-characters"); }
From source file:edu.ku.brc.af.auth.specify.SpecifySecurityMgr.java
@Override public boolean authenticateDB(final String user, final String pass, final String driverClass, final String url, final String dbUserName, final String dbPwd) throws Exception { Connection conn = null;// ww w . j av a 2s .c o m Statement stmt = null; boolean passwordMatch = false; try { Class.forName(driverClass); conn = DriverManager.getConnection(url, dbUserName, dbPwd); String query = "SELECT * FROM specifyuser where name='" + user + "'"; //$NON-NLS-1$ //$NON-NLS-2$ stmt = conn.createStatement(); ResultSet result = stmt.executeQuery(query); String dbPassword = null; while (result.next()) { if (!result.isFirst()) { throw new LoginException("authenticateDB - Ambiguous user (located more than once): " + user); //$NON-NLS-1$ } dbPassword = result.getString(result.findColumn("Password")); //$NON-NLS-1$ if (StringUtils.isNotEmpty(dbPassword) && StringUtils.isAlphanumeric(dbPassword) && UIHelper.isAllCaps(dbPassword) && dbPassword.length() > 20) { dbPassword = Encryption.decrypt(dbPassword, pass); } break; } /*if (dbPassword == null) { throw new LoginException("authenticateDB - Password for User " + user + " undefined."); //$NON-NLS-1$ //$NON-NLS-2$ }*/ if (pass != null && dbPassword != null && pass.equals(dbPassword)) { passwordMatch = true; } // else: passwords do NOT match, user will not be authenticated } catch (java.lang.ClassNotFoundException e) { e.printStackTrace(); edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(SpecifySecurityMgr.class, e); log.error("authenticateDB - Could not connect to database, driverclass - ClassNotFoundException: "); //$NON-NLS-1$ log.error(e.getMessage()); throw new LoginException("authenticateDB - Database driver class not found: " + driverClass); //$NON-NLS-1$ } catch (SQLException ex) { if (debug) log.error("authenticateDB - SQLException: " + ex.toString()); //$NON-NLS-1$ if (debug) log.error("authenticateDB - " + ex.getMessage()); //$NON-NLS-1$ throw new LoginException("authenticateDB - SQLException: " + ex.getMessage()); //$NON-NLS-1$ } finally { try { if (conn != null) conn.close(); if (stmt != null) stmt.close(); } catch (SQLException e) { edu.ku.brc.af.core.UsageTracker.incrSQLUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(SpecifySecurityMgr.class, e); log.error("Exception caught: " + e.toString()); //$NON-NLS-1$ e.printStackTrace(); } } return passwordMatch; }
From source file:jamm.webapp.DomainAdminAction.java
/** * Prepares the account information and adds it to the web page. * * @param request The request we're servicing * @param manager a mail manager instance to use * @param domain The domain we're manipulating * @exception MailManagerException if an error occurs *//*from w w w . j av a 2s . c o m*/ private void doAccounts(HttpServletRequest request, MailManager manager, String domain) throws MailManagerException { List accounts; String startsWith = request.getParameter("startsWith"); if (StringUtils.isAlphanumeric(startsWith) && StringUtils.isNotEmpty(startsWith)) { accounts = manager.getAccountsStartingWith(startsWith, domain); } else { accounts = manager.getAccounts(domain); } request.setAttribute("accounts", accounts); List activeAccounts = new ArrayList(); List adminAccounts = new ArrayList(); List deleteAccounts = new ArrayList(); Iterator i = accounts.iterator(); while (i.hasNext()) { AccountInfo account = (AccountInfo) i.next(); String name = account.getName(); if (account.isActive()) { activeAccounts.add(name); } if (account.isAdministrator()) { adminAccounts.add(name); } if (account.getDelete()) { deleteAccounts.add(name); } } String[] activeAccountsArray = (String[]) activeAccounts.toArray(new String[0]); String[] adminAccountsArray = (String[]) adminAccounts.toArray(new String[0]); String[] deleteAccountsArray = (String[]) deleteAccounts.toArray(new String[0]); DomainConfigForm dcf = new DomainConfigForm(); dcf.setOriginalActiveItems(activeAccountsArray); dcf.setActiveItems(activeAccountsArray); dcf.setOriginalAdminItems(adminAccountsArray); dcf.setAdminItems(adminAccountsArray); dcf.setOriginalItemsToDelete(deleteAccountsArray); dcf.setItemsToDelete(deleteAccountsArray); dcf.setDomain(domain); request.setAttribute("domainAccountForm", dcf); }
From source file:ezbake.deployer.EzBakeDeployerHandler.java
@Override public final DeploymentMetadata deployService(ArtifactManifest manifest, ByteBuffer artifact, EzSecurityToken token) throws TException { checkSecurityToken(token);/* w w w . j ava 2 s. c om*/ log.info("Artifact " + getFqAppId(manifest) + " requested to be deployed."); if (!StringUtils.isAlphanumeric(getServiceId(manifest))) { log.error("ServiceId must be alphanumeric: " + getServiceId(manifest)); throw new DeploymentException("Service ids must be alphanumeric"); } DeploymentArtifact deployedArtifact = ezDeployerStore.writeArtifactToStore(manifest, artifact); publishArtifact(deployedArtifact, token); return deployedArtifact.getMetadata(); }
From source file:com.sun.socialsite.util.UtilitiesModel.java
public static boolean isAlphanumeric(String str) { return StringUtils.isAlphanumeric(str); }
From source file:com.manydesigns.elements.blobs.BlobManager.java
public void ensureValidCode(String code) { if (!StringUtils.isAlphanumeric(code)) { throw new IllegalArgumentException("Code is not alphanumeric: " + code); }/*from w ww . j av a2s .c o m*/ }
From source file:jamm.webapp.DomainAdminAction.java
/** * Prepares the aliases for the page.// w w w. j a v a 2 s . co m * * @param request the request being serviced * @param manager The mail manager to use * @param domain which domain are we manipulating * @exception MailManagerException if an error occurs */ private void doAliases(HttpServletRequest request, MailManager manager, String domain) throws MailManagerException { List aliases; String startsWith = request.getParameter("startsWith"); if (StringUtils.isAlphanumeric(startsWith) && StringUtils.isNotEmpty(startsWith)) { aliases = manager.getAliasesStartingWith(startsWith, domain); } else { aliases = manager.getAliases(domain); } request.setAttribute("aliases", aliases); List activeAliases = new ArrayList(); List adminAliases = new ArrayList(); Iterator i = aliases.iterator(); while (i.hasNext()) { AliasInfo alias = (AliasInfo) i.next(); if (alias.isActive()) { activeAliases.add(alias.getName()); } if (alias.isAdministrator()) { adminAliases.add(alias.getName()); } } String[] activeAliasesArray = (String[]) activeAliases.toArray(new String[0]); String[] adminAliasesArray = (String[]) adminAliases.toArray(new String[0]); DomainConfigForm dcf = new DomainConfigForm(); dcf.setOriginalActiveItems(activeAliasesArray); dcf.setActiveItems(activeAliasesArray); dcf.setOriginalAdminItems(adminAliasesArray); dcf.setAdminItems(adminAliasesArray); dcf.setDomain(domain); request.setAttribute("domainAliasForm", dcf); }