Java Code Examples for org.joda.time.DateTime#isBeforeNow()
The following examples show how to use
org.joda.time.DateTime#isBeforeNow() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WrittenEvaluation.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 6 votes |
private void checkEnrolmentDates(final Date enrolmentBeginDay, final Date enrolmentEndDay, final Date enrolmentBeginTime, final Date enrolmentEndTime) throws DomainException { final DateTime enrolmentBeginDate = createDate(enrolmentBeginDay, enrolmentBeginTime); final DateTime enrolmentEndDate = createDate(enrolmentEndDay, enrolmentEndTime); if (getEnrollmentBeginDayDate() == null && enrolmentBeginDate.isBeforeNow()) { throw new DomainException("error.beginDate.sooner.today"); } if (enrolmentEndDate.isBefore(enrolmentBeginDate)) { throw new DomainException("error.endDate.sooner.beginDate"); } if (getBeginningDateTime().isBefore(enrolmentEndDate)) { throw new DomainException("error.examDate.sooner.endDate"); } }
Example 2
Source File: DefaultJwtSecurityTokenService.java From onetwo with Apache License 2.0 | 6 votes |
@Override public Authentication createAuthentication(String token) throws BadCredentialsException { Claims claims = createClaimsFromToken(token); DateTime expireation = new DateTime(claims.getExpiration()); if(expireation.isBeforeNow()){ return null; } String authorityString = claims.get(JwtSecurityUtils.CLAIM_AUTHORITIES).toString(); List<GrantedAuthority> authorities = GuavaUtils.splitAsStream(authorityString, ",").map(auth->{ return new SimpleGrantedAuthority(auth); }) .collect(Collectors.toList()); Authentication authentication = buildAuthentication(claims, authorities); return authentication; }
Example 3
Source File: FutureDateTimeValidator.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void performValidation() { HtmlSimpleValueComponent component = (HtmlSimpleValueComponent) getComponent(); String value = component.getValue(); if (value == null || value.length() == 0) { setMessage("renderers.validator.dateTime.required"); setValid(!isRequired()); } else { super.performValidation(); if (isValid()) { DateTime dateTime = new DateTime(value); if (dateTime.isBeforeNow()) { setMessage("renderers.validator.dateTime.beforeNow"); setValid(false); } } } }
Example 4
Source File: StudentPortalBean.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 6 votes |
public void setEnrolment(WrittenEvaluation writtenEvaluation) { DateTime beginDateTime = writtenEvaluation.getEnrolmentPeriodStart(); DateTime endDateTime = writtenEvaluation.getEnrolmentPeriodEnd(); this.enrolmentPast = endDateTime == null ? false : endDateTime.isBeforeNow(); this.enrolmentElapsing = false; if (writtenEvaluation.getEnrollmentBeginDayDateYearMonthDay() != null && writtenEvaluation.getEnrollmentEndDayDateYearMonthDay() != null) { this.enrolmentElapsing = new Interval(beginDateTime, endDateTime).containsNow(); this.enrolment = writtenEvaluation.getEnrollmentBeginDayDateYearMonthDay().toString() + " " + BundleUtil.getString(Bundle.STUDENT, "message.out.until") + " " + writtenEvaluation.getEnrollmentEndDayDateYearMonthDay().toString(); } else { this.enrolment = "-"; this.register = "-"; } }
Example 5
Source File: BackupRotation.java From chipster with MIT License | 5 votes |
/** * Create some empty files with backup-like filenames for testing. * * @throws IOException */ private void createFakeBackupFiles() throws IOException { DateTime date = new DateTime(2010, 1, 1, 5, 00); while (date.isBeforeNow()) { File backupFile = getBackupFile(date); backupFile.createNewFile(); date = date.plus(24*60*60*1000); } }
Example 6
Source File: NfsSecondaryStorageResource.java From cloudstack with Apache License 2.0 | 5 votes |
public void validatePostUploadRequest(String signature, String metadata, String timeout, String hostname, long contentLength, String uuid) throws InvalidParameterValueException { // check none of the params are empty if (StringUtils.isEmpty(signature) || StringUtils.isEmpty(metadata) || StringUtils.isEmpty(timeout)) { updateStateMapWithError(uuid, "signature, metadata and expires are compulsory fields."); throw new InvalidParameterValueException("signature, metadata and expires are compulsory fields."); } //check that contentLength exists and is greater than zero if (contentLength <= 0) { throw new InvalidParameterValueException("content length is not set in the request or has invalid value."); } //validate signature String fullUrl = "https://" + hostname + "/upload/" + uuid; String computedSignature = EncryptionUtil.generateSignature(metadata + fullUrl + timeout, getPostUploadPSK()); boolean isSignatureValid = computedSignature.equals(signature); if (!isSignatureValid) { updateStateMapWithError(uuid, "signature validation failed."); throw new InvalidParameterValueException("signature validation failed."); } //validate timeout DateTime timeoutDateTime = DateTime.parse(timeout, ISODateTimeFormat.dateTime()); if (timeoutDateTime.isBeforeNow()) { updateStateMapWithError(uuid, "request not valid anymore."); throw new InvalidParameterValueException("request not valid anymore."); } }
Example 7
Source File: ExecutionSemester.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 5 votes |
public DateMidnight getThisMonday() { final DateTime beginningOfSemester = getBeginDateYearMonthDay().toDateTimeAtMidnight(); final DateTime endOfSemester = getEndDateYearMonthDay().toDateTimeAtMidnight(); if (beginningOfSemester.isAfterNow() || endOfSemester.isBeforeNow()) { return null; } final DateMidnight now = new DateMidnight(); return now.withField(DateTimeFieldType.dayOfWeek(), 1); }
Example 8
Source File: WrittenEvaluation.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 5 votes |
public boolean isInEnrolmentPeriod() { if (this.getEnrollmentBeginDayDate() == null || this.getEnrollmentBeginTimeDate() == null || this.getEnrollmentEndDayDate() == null || this.getEnrollmentEndTimeDate() == null) { throw new DomainException("error.enrolmentPeriodNotDefined"); } final DateTime enrolmentBeginDate = createDate(this.getEnrollmentBeginDayDate(), this.getEnrollmentBeginTimeDate()); final DateTime enrolmentEndDate = createDate(this.getEnrollmentEndDayDate(), this.getEnrollmentEndTimeDate()); return enrolmentBeginDate.isBeforeNow() && enrolmentEndDate.isAfterNow(); }
Example 9
Source File: NfsSecondaryStorageResource.java From cosmic with Apache License 2.0 | 5 votes |
public void validatePostUploadRequest(final String signature, final String metadata, final String timeout, final String hostname, final long contentLength, final String uuid) throws InvalidParameterValueException { // check none of the params are empty if (StringUtils.isEmpty(signature) || StringUtils.isEmpty(metadata) || StringUtils.isEmpty(timeout)) { updateStateMapWithError(uuid, "signature, metadata and expires are compulsory fields."); throw new InvalidParameterValueException("signature, metadata and expires are compulsory fields."); } //check that contentLength exists and is greater than zero if (contentLength <= 0) { throw new InvalidParameterValueException("content length is not set in the request or has invalid value."); } //validate signature final String fullUrl = "https://" + hostname + "/upload/" + uuid; final String computedSignature = EncryptionUtil.generateSignature(metadata + fullUrl + timeout, getPostUploadPSK()); final boolean isSignatureValid = computedSignature.equals(signature); if (!isSignatureValid) { updateStateMapWithError(uuid, "signature validation failed."); throw new InvalidParameterValueException("signature validation failed."); } //validate timeout final DateTime timeoutDateTime = DateTime.parse(timeout, ISODateTimeFormat.dateTime()); if (timeoutDateTime.isBeforeNow()) { updateStateMapWithError(uuid, "request not valid anymore."); throw new InvalidParameterValueException("request not valid anymore."); } }
Example 10
Source File: QueryExecutor.java From sonar-break-maven-plugin with MIT License | 5 votes |
/** * Get the status from sonar for the currently executing build. This waits for sonar to complete its processing * before returning the results. * * @param queryUrl The sonar URL to get the results from * @return Matching result object for this build * @throws IOException * @throws SonarBreakException */ private Result fetchSonarStatusWithRetries(URL analysisQueryUrl, URL queryUrl) throws IOException, SonarBreakException { DateTime oneMinuteAgo = DateTime.now().minusSeconds(sonarLookBackSeconds); DateTime waitUntil = DateTime.now().plusSeconds(waitForProcessingSeconds); do { // If this is the first time the job is running on sonar the URL might not be available. Return null and wait. if (isAnalysisAvailable(analysisQueryUrl,oneMinuteAgo)) { Result result = fetchSonarStatus(queryUrl); if(null != result && null != result.getStatus()) { return result; }else{ log.debug("Sleeping while waiting for sonar to process job."); } } else { log.debug(String.format("Query url not available yet: %s", queryUrl)); } try { Thread.sleep(SONAR_PROCESSING_WAIT_TIME); } catch (InterruptedException e) { // Do nothing } } while (!waitUntil.isBeforeNow()); String message = String.format("Timed out while waiting for Sonar. Waited %d seconds. This time can be extended " + "using the \"waitForProcessingSeconds\" configuration parameter.", waitForProcessingSeconds); throw new SonarBreakException(message); }
Example 11
Source File: ScheduleService.java From htwplus with MIT License | 5 votes |
/** * Returns a DateTime for hour and minute. * * @param hour Hour * @param minute Minute * @return DateTime */ private DateTime nextExecution(int hour, int minute) { DateTime next = new DateTime() .withHourOfDay(hour) .withMinuteOfHour(minute) .withSecondOfMinute(0) .withMillisOfSecond(0); return (next.isBeforeNow()) ? next.plusHours(24) : next; }
Example 12
Source File: SAMLTokenValidator.java From cxf with Apache License 2.0 | 5 votes |
protected boolean validateConditions( SamlAssertionWrapper assertion, ReceivedToken validateTarget ) { DateTime validFrom = null; DateTime validTill = null; DateTime issueInstant = null; if (assertion.getSamlVersion().equals(SAMLVersion.VERSION_20)) { validFrom = assertion.getSaml2().getConditions().getNotBefore(); validTill = assertion.getSaml2().getConditions().getNotOnOrAfter(); issueInstant = assertion.getSaml2().getIssueInstant(); } else { validFrom = assertion.getSaml1().getConditions().getNotBefore(); validTill = assertion.getSaml1().getConditions().getNotOnOrAfter(); issueInstant = assertion.getSaml1().getIssueInstant(); } if (validFrom != null && validFrom.isAfterNow()) { LOG.log(Level.WARNING, "SAML Token condition not met"); return false; } else if (validTill != null && validTill.isBeforeNow()) { LOG.log(Level.WARNING, "SAML Token condition not met"); validateTarget.setState(STATE.EXPIRED); return false; } if (issueInstant != null && issueInstant.isAfterNow()) { LOG.log(Level.WARNING, "SAML Token IssueInstant not met"); return false; } return true; }
Example 13
Source File: SAMLTokenValidator.java From cxf-fediz with Apache License 2.0 | 5 votes |
/** * Check the Conditions of the Assertion. */ protected boolean isConditionValid(SamlAssertionWrapper assertion, int maxClockSkew) throws WSSecurityException { DateTime validFrom = null; DateTime validTill = null; if (assertion.getSamlVersion().equals(SAMLVersion.VERSION_20) && assertion.getSaml2().getConditions() != null) { validFrom = assertion.getSaml2().getConditions().getNotBefore(); validTill = assertion.getSaml2().getConditions().getNotOnOrAfter(); } else if (assertion.getSamlVersion().equals(SAMLVersion.VERSION_11) && assertion.getSaml1().getConditions() != null) { validFrom = assertion.getSaml1().getConditions().getNotBefore(); validTill = assertion.getSaml1().getConditions().getNotOnOrAfter(); } if (validFrom != null) { DateTime currentTime = new DateTime(); currentTime = currentTime.plusSeconds(maxClockSkew); if (validFrom.isAfter(currentTime)) { LOG.debug("SAML Token condition (Not Before) not met"); return false; } } if (validTill != null && validTill.isBeforeNow()) { LOG.debug("SAML Token condition (Not On Or After) not met"); return false; } return true; }
Example 14
Source File: MailProcessingTask.java From mireka with Apache License 2.0 | 4 votes |
private boolean taskHasBeenFailingForTooMuchTime() { DateTime deadline = dateOfFirstFailedAttempt.plusDays(1); return deadline.isBeforeNow(); }
Example 15
Source File: AbstractSAMLToken.java From freehealth-connector with GNU Affero General Public License v3.0 | 4 votes |
public void checkValidity() throws TechnicalConnectorException { DateTime calendar = SAMLHelper.getNotOnOrAfterCondition(this.assertion); if (calendar.isBeforeNow()) { throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.INVALID_TOKEN, new Object[]{"token is expired."}); } }
Example 16
Source File: AbstractReloadingMetadataProvider.java From lams with GNU General Public License v2.0 | 4 votes |
/** * Processes metadata that has been determined to be valid at the time it was fetched. A metadata document is * considered be valid if its root element returns true when passed to the {@link #isValid(XMLObject)} method. * * @param metadataIdentifier identifier of the metadata source * @param refreshStart when the current refresh cycle started * @param metadataBytes raw bytes of the new metadata document * @param metadata new metadata document unmarshalled * * @throws MetadataProviderException thrown if there s a problem processing the metadata */ protected void processNonExpiredMetadata(String metadataIdentifier, DateTime refreshStart, byte[] metadataBytes, XMLObject metadata) throws MetadataProviderException { Document metadataDom = metadata.getDOM().getOwnerDocument(); log.debug("Filtering metadata from '{}'", metadataIdentifier); try { filterMetadata(metadata); } catch (FilterException e) { String errMsg = "Error filtering metadata from " + metadataIdentifier; log.error(errMsg, e); throw new MetadataProviderException(errMsg, e); } log.debug("Releasing cached DOM for metadata from '{}'", metadataIdentifier); releaseMetadataDOM(metadata); log.debug("Post-processing metadata from '{}'", metadataIdentifier); postProcessMetadata(metadataBytes, metadataDom, metadata); log.debug("Computing expiration time for metadata from '{}'", metadataIdentifier); DateTime metadataExpirationTime = SAML2Helper.getEarliestExpiration(metadata, refreshStart.plus(getMaxRefreshDelay()), refreshStart); log.debug("Expiration of metadata from '{}' will occur at {}", metadataIdentifier, metadataExpirationTime.toString()); cachedMetadata = metadata; lastUpdate = refreshStart; long nextRefreshDelay; if (metadataExpirationTime.isBeforeNow()) { expirationTime = new DateTime(ISOChronology.getInstanceUTC()).plus(getMinRefreshDelay()); nextRefreshDelay = getMaxRefreshDelay(); } else { expirationTime = metadataExpirationTime; nextRefreshDelay = computeNextRefreshDelay(expirationTime); } nextRefresh = new DateTime(ISOChronology.getInstanceUTC()).plus(nextRefreshDelay); emitChangeEvent(); log.info("New metadata succesfully loaded for '{}'", getMetadataIdentifier()); }
Example 17
Source File: AbstractSAMLToken.java From freehealth-connector with GNU Affero General Public License v3.0 | 4 votes |
public void checkValidity() throws TechnicalConnectorException { DateTime calendar = SAMLHelper.getNotOnOrAfterCondition(this.assertion); if (calendar.isBeforeNow()) { throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.INVALID_TOKEN, new Object[]{"token is expired."}); } }
Example 18
Source File: AbstractSAMLToken.java From freehealth-connector with GNU Affero General Public License v3.0 | 4 votes |
public void checkValidity() throws TechnicalConnectorException { DateTime calendar = SAMLHelper.getNotOnOrAfterCondition(this.assertion); if (calendar.isBeforeNow()) { throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.INVALID_TOKEN, new Object[]{"token is expired."}); } }
Example 19
Source File: AbstractSAMLToken.java From freehealth-connector with GNU Affero General Public License v3.0 | 4 votes |
public void checkValidity() throws TechnicalConnectorException { DateTime calendar = SAMLHelper.getNotOnOrAfterCondition(this.assertion); if (calendar.isBeforeNow()) { throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.INVALID_TOKEN, new Object[]{"token is expired."}); } }
Example 20
Source File: AbstractSAMLToken.java From freehealth-connector with GNU Affero General Public License v3.0 | 4 votes |
public void checkValidity() throws TechnicalConnectorException { DateTime calendar = SAMLHelper.getNotOnOrAfterCondition(this.assertion); if (calendar.isBeforeNow()) { throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.INVALID_TOKEN, new Object[]{"token is expired."}); } }