List of usage examples for org.apache.commons.lang StringUtils lowerCase
public static String lowerCase(String str)
Converts a String to lower case as per String#toLowerCase() .
From source file:org.jasig.ssp.dao.PersonDao.java
public Person fromUsername(@NotNull final String username) { if (!StringUtils.isNotBlank(username)) { throw new IllegalArgumentException("username can not be empty."); }//from ww w. jav a 2 s . co m Dialect dialect = ((SessionFactoryImplementor) sessionFactory).getDialect(); Session currentSession = sessionFactory.getCurrentSession(); final Criteria query = currentSession.createCriteria(Person.class); //Sqlserver does a case insensitive string compare so we don't do the string //normalization for sqlserver so that it hits index on person table idx_person_username if (dialect instanceof SQLServerDialect) { query.add(Restrictions.eq("username", username)).setFlushMode(FlushMode.COMMIT); return (Person) query.uniqueResult(); } else { //Postgres has an index on lower(username): idx_func_username_person query.add(Restrictions.eq("username", StringUtils.lowerCase(username))).setFlushMode(FlushMode.COMMIT); } return (Person) query.uniqueResult(); }
From source file:org.jasig.ssp.dao.PersonDao.java
public Person getByUsername(final String username) throws ObjectNotFoundException { if (!StringUtils.isNotBlank(username)) { throw new IllegalArgumentException("username can not be empty."); }/* www . j av a 2 s.c o m*/ final Person person = (Person) createCriteria() .add(Restrictions.eq("username", StringUtils.lowerCase(username))).uniqueResult(); if (person == null) { throw new ObjectNotFoundException("Person not found with username: " + username, Person.class.getName()); } return person; }
From source file:org.jasig.ssp.dao.PersonDao.java
@SuppressWarnings(UNCHECKED) public PagingWrapper<CoachPersonLiteTO> getCoachPersonsLiteByUsernames(final Collection<String> coachUsernames, final SortingAndPaging sAndP, final String homeDepartment) { List<String> normalizedCoachUsernames = new ArrayList<String>(); //Normalize usernames as per SSP-1733 for (String coachUsername : coachUsernames) { normalizedCoachUsernames.add(StringUtils.lowerCase(coachUsername)); }/*from w ww .j av a 2 s. c o m*/ BatchProcessor<String, CoachPersonLiteTO> processor = new BatchProcessor(normalizedCoachUsernames, sAndP); do { // ignore department name and office location for now... would // require join we know we don't actually need for existing call sites Criteria criteria = createCriteria(sAndP); if (homeDepartment != null && homeDepartment.length() > 0) { criteria.createAlias("staffDetails", "personStaffDetails") .add(Restrictions.eq("personStaffDetails.departmentName", homeDepartment)); } else { criteria.createAlias("staffDetails", "personStaffDetails", JoinType.LEFT_OUTER_JOIN); } criteria.setProjection(Projections.projectionList().add(Projections.property("id").as("person_id")) .add(Projections.property("firstName").as("person_firstName")) .add(Projections.property("lastName").as("person_lastName")) .add(Projections.property("primaryEmailAddress").as("person_primaryEmailAddress")) .add(Projections.property("workPhone").as("person_workPhone")) .add(Projections.property("photoUrl").as("person_photoUrl")) .add(Projections.property("personStaffDetails.departmentName").as("person_departmentName")) .add(Projections.property("personStaffDetails.officeLocation").as("person_officeLocation"))) .setResultTransformer( new NamespacedAliasToBeanResultTransformer(CoachPersonLiteTO.class, "person_")); processor.process(criteria, "username"); } while (processor.moreToProcess()); return processor.getSortedAndPagedResults(); }
From source file:org.jasig.ssp.dao.security.oauth2.OAuth2ClientDao.java
public OAuth2Client findByClientId(String clientId) { if (StringUtils.isBlank(StringUtils.lowerCase(clientId))) { throw new IllegalArgumentException("username can not be empty."); }/*from w w w. ja v a 2 s .c o m*/ final Criteria query = sessionFactory.getCurrentSession().createCriteria(OAuth2Client.class); query.add(Restrictions.eq(OAuth2Client.getPhysicalClientIdColumnName(), clientId)); return (OAuth2Client) query.uniqueResult(); }
From source file:org.jasig.ssp.model.DirectoryPerson.java
public void setUsername(@NotNull @NotEmpty final String username) { this.username = StringUtils.lowerCase(username); }
From source file:org.jasig.ssp.service.external.impl.ExternalPersonServiceImpl.java
/** * Modifies state of Person for values of ExternalPerson that are different. * //from w w w . jav a2 s.c o m * @param person * person */ @Override public void updatePersonFromExternalPerson(final Person person, final ExternalPerson externalPerson, boolean commit) { LOGGER.debug("Person and ExternalPerson Sync. Person school id {}, username {}", person.getSchoolId(), person.getUsername()); // Allow ExternalPerson.schoolId to override that Person field since // the ExternalPerson might have been looked up by username rather than // schoolId and Person.schoolId is not necessarily trustworthy on 1st // time login (https://issues.jasig.org/browse/SSP-1750). // // Comparison here is intentionally case-sensitive pending // https://issues.jasig.org/browse/SSP-1735 if (person.getSchoolId() == null || (!person.getSchoolId().equals(externalPerson.getSchoolId()))) { person.setSchoolId(externalPerson.getSchoolId()); } if (person.getUsername() == null || (!person.getUsername().equalsIgnoreCase(externalPerson.getUsername()))) { person.setUsername(StringUtils.lowerCase(externalPerson.getUsername())); } if ((person.getFirstName() == null) || (!person.getFirstName().equals(externalPerson.getFirstName()))) { person.setFirstName(externalPerson.getFirstName()); } if ((person.getLastName() == null) || (!person.getLastName().equals(externalPerson.getLastName()))) { person.setLastName(externalPerson.getLastName()); } if ((person.getMiddleName() == null) || (!person.getMiddleName().equals(externalPerson.getMiddleName()))) { person.setMiddleName(externalPerson.getMiddleName()); } if ((person.getBirthDate() == null) || (!person.getBirthDate().equals(externalPerson.getBirthDate()))) { person.setBirthDate(externalPerson.getBirthDate()); } if ((person.getPrimaryEmailAddress() == null) || (!person.getPrimaryEmailAddress().equals(externalPerson.getPrimaryEmailAddress()))) { person.setPrimaryEmailAddress(externalPerson.getPrimaryEmailAddress()); } if ((person.getAddressLine1() == null) || (!person.getAddressLine1().equals(externalPerson.getAddressLine1()))) { person.setAddressLine1(externalPerson.getAddressLine1()); } if ((person.getAddressLine2() == null) || (!person.getAddressLine2().equals(externalPerson.getAddressLine2()))) { person.setAddressLine2(externalPerson.getAddressLine2()); } if ((person.getCity() == null) || (!person.getCity().equals(externalPerson.getCity()))) { person.setCity(externalPerson.getCity()); } if ((person.getState() == null) || (!person.getState().equals(externalPerson.getState()))) { person.setState(externalPerson.getState()); } if ((person.getZipCode() == null) || (!person.getZipCode().equals(externalPerson.getZipCode()))) { person.setZipCode(externalPerson.getZipCode()); } if ((person.getHomePhone() == null) || (!person.getHomePhone().equals(externalPerson.getHomePhone()))) { person.setHomePhone(externalPerson.getHomePhone()); } if ((person.getWorkPhone() == null) || (!person.getWorkPhone().equals(externalPerson.getWorkPhone()))) { person.setWorkPhone(externalPerson.getWorkPhone()); } if ((person.getCellPhone() == null) || (!person.getCellPhone().equals(externalPerson.getCellPhone()))) { person.setCellPhone(externalPerson.getCellPhone()); } if ((person.getPhotoUrl() == null) || (!person.getPhotoUrl().equals(externalPerson.getPhotoUrl()))) { person.setPhotoUrl(externalPerson.getPhotoUrl()); } if ((person.getActualStartTerm() == null) || (!person.getActualStartTerm().equals(externalPerson.getActualStartTerm()))) { person.setActualStartTerm(externalPerson.getActualStartTerm()); } if ((person.getActualStartYear() == null) || (!person.getActualStartYear().equals(externalPerson.getActualStartYear()))) { person.setActualStartYear(externalPerson.getActualStartYear()); } if ((person.getNonLocalAddress() == null) || (!person.getNonLocalAddress().equals(externalPerson.getNonLocalAddress()))) { person.setNonLocalAddress(externalPerson.getNonLocalAddress()); } if ((person.getResidencyCounty() == null) || (!person.getResidencyCounty().equals(externalPerson.getResidencyCounty()))) { person.setResidencyCounty(externalPerson.getResidencyCounty()); } if ((person.getF1Status() == null) || (!person.getF1Status().equals(externalPerson.getF1Status()))) { person.setF1Status(externalPerson.getF1Status()); } setCoachForPerson(person, externalPerson.getCoachSchoolId()); setStudentTypeForPerson(person, externalPerson.getStudentType()); if ((StringUtils.isBlank(externalPerson.getDepartmentName()) && StringUtils.isBlank(externalPerson.getOfficeHours()) && StringUtils.isBlank(externalPerson.getOfficeLocation()))) { // this is likely not a staff member if (person.getStaffDetails() != null) { try { staffDetailsService.delete(person.getStaffDetails().getId()); } catch (final ObjectNotFoundException e) { LOGGER.info( "Strange that we found a staffDetails object a moment ago, but cannot find it again to delte it.", e); } } } else { // this is a staff member, add their details if (person.getStaffDetails() == null) { person.setStaffDetails(new PersonStaffDetails()); } if ((person.getStaffDetails().getOfficeHours() == null) || (!person.getStaffDetails().getOfficeHours().equals(externalPerson.getOfficeHours()))) { person.getStaffDetails().setOfficeHours(externalPerson.getOfficeHours()); } if ((person.getStaffDetails().getOfficeLocation() == null) || (!person.getStaffDetails().getOfficeLocation().equals(externalPerson.getOfficeLocation()))) { person.getStaffDetails().setOfficeLocation(externalPerson.getOfficeLocation()); } if ((person.getStaffDetails().getDepartmentName() == null) || (!person.getStaffDetails().getDepartmentName().equals(externalPerson.getDepartmentName()))) { person.getStaffDetails().setDepartmentName(externalPerson.getDepartmentName()); } } PersonDemographics demographics; if (person.getDemographics() == null) { demographics = new PersonDemographics(); person.setDemographics(demographics); } else { demographics = person.getDemographics(); } //As per SSP-874, how to handle external data overwrites: // Based on jasig-ssp discussions, the rules for the updates to the person_demographics are: // 1. Null/Empty/Blank value from external table: over-write (they may be intentionally desiring the existing value overwritten. // 2. Valid value from external table that matches entry in reference table: over-write // 3. Invalid value from external table that has no matching entry in reference table: don't over-write if (StringUtils.isBlank(externalPerson.getMaritalStatus())) { demographics.setMaritalStatus(null); } else { MaritalStatus maritalStatus = maritalStatusService.getByName(externalPerson.getMaritalStatus()); demographics.setMaritalStatus(maritalStatus == null ? demographics.getMaritalStatus() : maritalStatus); } if (StringUtils.isBlank(externalPerson.getEthnicity())) { demographics.setEthnicity(null); } else { Ethnicity ethnicity = ethnicityService.getByName(externalPerson.getEthnicity()); demographics.setEthnicity(ethnicity == null ? demographics.getEthnicity() : ethnicity); } if (StringUtils.isBlank(externalPerson.getRace())) { demographics.setRace(null); } else { Race race = raceService.getByCode(externalPerson.getRace()); demographics.setRace(race == null ? demographics.getRace() : race); } if (StringUtils.isBlank(externalPerson.getGender())) { demographics.setGender(null); } else { try { Genders gender = Genders.valueOf(externalPerson.getGender()); demographics.setGender(gender); } catch (IllegalArgumentException e) { demographics.setGender(null); } } if (externalPerson.getIsLocal() == null) { demographics.setLocal(null); } else { demographics.setLocal(externalPerson.getIsLocal().equalsIgnoreCase("Y")); } if (externalPerson.getBalanceOwed() == null) { demographics.setBalanceOwed(null); } else { if ((demographics.getBalanceOwed() == null) || (!demographics.getBalanceOwed().equals(externalPerson.getBalanceOwed()))) { demographics.setBalanceOwed(externalPerson.getBalanceOwed()); } } try { if (commit) { personService.save(person); } } catch (final ObjectNotFoundException e) { LOGGER.error("person failed to save", e); } }
From source file:org.jasig.ssp.service.security.oauth2.impl.OAuth2ClientServiceImpl.java
private void invalidateAllTokensByClientId(String clientId) { final Collection<OAuth2AccessToken> tokensByClientId = consumerTokenService .findTokensByClientId(StringUtils.lowerCase(clientId)); for (OAuth2AccessToken token : tokensByClientId) { consumerTokenService.revokeToken(token.getValue()); }//w ww . jav a 2s . c o m }
From source file:org.jasig.ssp.service.security.oauth2.impl.OAuth2ClientServiceImpl.java
private void invalidateClientOnlyTokensByClientId(String clientId) { final Collection<OAuth2AccessToken> tokensByClientId = consumerTokenService .findTokensByClientId(StringUtils.lowerCase(clientId)); for (OAuth2AccessToken token : tokensByClientId) { final OAuth2Authentication authN = resourceServerTokenService.loadAuthentication(token.getValue()); if (authN.isClientOnly()) { consumerTokenService.revokeToken(token.getValue()); }/*w ww . j ava 2 s . c o m*/ } }
From source file:org.jmesa.core.filter.StringFilterMatcher.java
@Override public boolean evaluate(Object itemValue, String filterValue) { String item = StringUtils.lowerCase(String.valueOf(itemValue)); String filter = StringUtils.lowerCase(String.valueOf(filterValue)); if (StringUtils.contains(item, filter)) { return true; }/*from ww w . j a va2 s .com*/ return false; }
From source file:org.jspringbot.keyword.expression.engine.CaseInsensitiveResolver.java
@Override public void setValue(ELContext context, Object base, Object property, Object value) throws NullPointerException, PropertyNotFoundException, PropertyNotWritableException, ELException { if (String.class.isInstance(property)) { property = StringUtils.lowerCase(property.toString()); }//from w w w. j a v a 2 s .c om super.setValue(context, base, property, value); }