List of usage examples for org.joda.time DateTime minus
public DateTime minus(ReadablePeriod period)
From source file:com.tremolosecurity.idp.providers.OpenIDConnectIdP.java
License:Apache License
private void completeUserLogin(HttpServletRequest request, HttpServletResponse response, String code, String clientID, String clientSecret, UrlHolder holder, AuthInfo authData) throws ServletException, IOException, MalformedURLException { String lastMileToken = null;/*from ww w.j ava 2 s . c o m*/ try { lastMileToken = this.inflate(code); lastMileToken = new String( org.bouncycastle.util.encoders.Base64.encode(lastMileToken.getBytes("UTF-8"))); } catch (Exception e) { throw new ServletException("Could not inflate code", e); } OpenIDConnectTrust trust = this.trusts.get(clientID); if (!trust.isPublicEndpoint()) { if (!clientSecret.equals(trust.getClientSecret())) { AccessLog.log(AccessEvent.AzFail, holder.getApp(), (HttpServletRequest) request, authData, "NONE"); response.sendError(403); return; } } ConfigManager cfg = (ConfigManager) request.getAttribute(ProxyConstants.TREMOLO_CFG_OBJ); SecretKey codeKey = cfg.getSecretKey(trust.getCodeLastmileKeyName()); com.tremolosecurity.lastmile.LastMile lmreq = new com.tremolosecurity.lastmile.LastMile(); try { lmreq.loadLastMielToken(lastMileToken, codeKey); } catch (Exception e) { logger.warn("Could not decrypt code token", e); response.sendError(403); AccessLog.log(AccessEvent.AzFail, holder.getApp(), (HttpServletRequest) request, authData, "NONE"); return; } if (!lmreq.isValid()) { response.sendError(403); logger.warn("Could not validate code token"); AccessLog.log(AccessEvent.AzFail, holder.getApp(), (HttpServletRequest) request, authData, "NONE"); return; } Attribute dn = null; Attribute scopes = null; String nonce = null; for (Attribute attr : lmreq.getAttributes()) { if (attr.getName().equalsIgnoreCase("dn")) { dn = attr; } else if (attr.getName().equalsIgnoreCase("scope")) { scopes = attr; } else if (attr.getName().equalsIgnoreCase("nonce")) { nonce = attr.getValues().get(0); } } ConfigManager cfgMgr = (ConfigManager) request.getAttribute(ProxyConstants.TREMOLO_CFG_OBJ); DateTime now = new DateTime(); DateTime notBefore = now.minus(trust.getCodeTokenTimeToLive()); DateTime notAfter = now.plus(trust.getCodeTokenTimeToLive()); int authLevel = lmreq.getLoginLevel(); String authMethod = lmreq.getAuthChain(); try { lmreq = new com.tremolosecurity.lastmile.LastMile(request.getRequestURI(), notBefore, notAfter, authLevel, authMethod); } catch (URISyntaxException e) { throw new ServletException("Could not request access token", e); } /* lmreq.getAttributes().add(new Attribute("dn",dn.getValues().get(0))); SecretKey key = cfgMgr.getSecretKey(trust.getAccessLastmileKeyName()); String accessToken = null; try { accessToken = lmreq.generateLastMileToken(key); } catch (Exception e) { throw new ServletException("Could not generate access token",e); }*/ String accessToken = null; try { accessToken = this .produceJWT(this.generateClaims(dn.getValues().get(0), cfgMgr, new URL(request.getRequestURL().toString()), trust, nonce), cfgMgr) .getCompactSerialization(); } catch (JoseException | LDAPException | ProvisioningException e1) { throw new ServletException("Could not generate jwt", e1); } OpenIDConnectAccessToken access = new OpenIDConnectAccessToken(); access.setAccess_token(accessToken); access.setExpires_in((int) (trust.getAccessTokenTimeToLive() / 1000)); try { access.setId_token(this .produceJWT(this.generateClaims(dn.getValues().get(0), cfgMgr, new URL(request.getRequestURL().toString()), trust, nonce), cfgMgr) .getCompactSerialization()); } catch (Exception e) { throw new ServletException("Could not generate JWT", e); } access.setToken_type("Bearer"); OIDCSession oidcSession = null; try { oidcSession = this.storeSession(access, holder.getApp(), trust.getCodeLastmileKeyName(), request, dn.getValues().get(0), clientID); } catch (InvalidKeyException | NoSuchAlgorithmException | NoSuchPaddingException | IllegalBlockSizeException | BadPaddingException e) { throw new ServletException("Could not store session", e); } access.setRefresh_token(oidcSession.getEncryptedRefreshToken()); Gson gson = new Gson(); String json = gson.toJson(access); response.setContentType("text/json"); response.getOutputStream().write(json.getBytes("UTF-8")); response.getOutputStream().flush(); if (logger.isDebugEnabled()) { logger.debug("Token JSON : '" + json + "'"); } AuthInfo remUser = new AuthInfo(); remUser.setUserDN(dn.getValues().get(0)); AccessLog.log(AccessEvent.AzSuccess, holder.getApp(), (HttpServletRequest) request, remUser, "NONE"); }
From source file:com.tremolosecurity.idp.providers.OpenIDConnectIdP.java
License:Apache License
private void postResponse(OpenIDConnectTransaction transaction, HttpServletRequest request, HttpServletResponse response, AuthInfo authInfo, UrlHolder holder) throws Exception { //first generate a lastmile token OpenIDConnectTrust trust = trusts.get(transaction.getClientID()); ConfigManager cfgMgr = (ConfigManager) request.getAttribute(ProxyConstants.TREMOLO_CFG_OBJ); DateTime now = new DateTime(); DateTime notBefore = now.minus(trust.getCodeTokenTimeToLive()); DateTime notAfter = now.plus(trust.getCodeTokenTimeToLive()); com.tremolosecurity.lastmile.LastMile lmreq = new com.tremolosecurity.lastmile.LastMile( request.getRequestURI(), notBefore, notAfter, authInfo.getAuthLevel(), authInfo.getAuthMethod()); lmreq.getAttributes().add(new Attribute("dn", authInfo.getUserDN())); Attribute attr = new Attribute("scope"); attr.getValues().addAll(transaction.getScope()); lmreq.getAttributes().add(attr);/*from w w w . j ava 2s.com*/ if (transaction.getNonce() != null) { lmreq.getAttributes().add(new Attribute("nonce", transaction.getNonce())); } SecretKey key = cfgMgr.getSecretKey(trust.getCodeLastmileKeyName()); String codeToken = lmreq.generateLastMileToken(key); ByteArrayOutputStream baos = new ByteArrayOutputStream(); DeflaterOutputStream compressor = new DeflaterOutputStream(baos, new Deflater(Deflater.BEST_COMPRESSION, true)); compressor.write(org.bouncycastle.util.encoders.Base64.decode(codeToken.getBytes("UTF-8"))); compressor.flush(); compressor.close(); String b64 = new String(org.bouncycastle.util.encoders.Base64.encode(baos.toByteArray())); StringBuffer b = new StringBuffer(); b.append(transaction.getRedirectURI()).append("?").append("code=").append(URLEncoder.encode(b64, "UTF-8")) .append("&state=").append(URLEncoder.encode(transaction.getState(), "UTF-8")); response.sendRedirect(b.toString()); }
From source file:com.tremolosecurity.proxy.util.LastMileUtil.java
License:Apache License
public static void addLastMile(ConfigManager cfg, String username, String userNameAttr, HttpRequestBase req, String keyAlias, boolean addHeader) throws Exception { if (!addHeader) { return;//w w w .j a v a2 s .c o m } String uri = req.getURI().getPath(); DateTime now = new DateTime(); DateTime notBefore = now.minus(5 * 60 * 1000); DateTime notAfter = now.plus(5 * 60 * 1000); LastMile lm = new LastMile(uri, notBefore, notAfter, 0, "nochain"); lm.getAttributes().add(new Attribute(userNameAttr, username)); SecretKey sk = cfg.getSecretKey(keyAlias); String header = lm.generateLastMileToken(sk); req.addHeader("tremoloHeader", header); }
From source file:com.vmware.identity.samlservice.impl.AuthnRequestStateValidator.java
License:Open Source License
@Override public ValidationResult validate(AuthnRequestState t) { log.debug("Validating request {}", t); ValidationResult vr = null;/*from ww w . j a v a 2s. c o m*/ try { Validate.notNull(t); HttpServletRequest httpRequest = t.getRequest(); Validate.notNull(httpRequest); AuthnRequest request = t.getAuthnRequest(); Validate.notNull(request); Validate.notNull(request.getIssuer()); IdmAccessor accessor = t.getIdmAccessor(); Validate.notNull(accessor); Validate.notNull(accessor.getTenant()); // Validate assertion consumer service first, if that is valid, we can send SAML replies try { boolean validateACSWithMetadata = !this.isRequestSigned(t); String acsUrl = accessor.getAcsForRelyingParty(request.getIssuer().getValue(), request.getAssertionConsumerServiceIndex(), request.getAssertionConsumerServiceURL(), request.getProtocolBinding(), validateACSWithMetadata); t.setAcsUrl(acsUrl); } catch (IllegalStateException e) { // set validation result to 400 log.debug("Caught illegal state exception while Validating {} returning 400", e.toString()); vr = new ValidationResult(HttpServletResponse.SC_BAD_REQUEST, e.getMessage(), null); } // Validate ID if (vr == null && request.getID() == null) { vr = new ValidationResult(OasisNames.REQUESTER); log.debug("Validation FAILED - Request ID is missing"); } // Validate version if (vr == null) { SAMLVersion version = request.getVersion(); if ((version.getMajorVersion() > Shared.REQUIRED_SAML_VERSION.getMajorVersion()) || version.getMajorVersion() == Shared.REQUIRED_SAML_VERSION.getMajorVersion() && version.getMinorVersion() > Shared.REQUIRED_SAML_VERSION.getMinorVersion()) { // version too high vr = new ValidationResult(OasisNames.VERSION_MISMATCH, OasisNames.REQUEST_VERSION_TOO_HIGH); log.debug("Validation FAILED - Version is too high"); } else if ((version.getMajorVersion() < Shared.REQUIRED_SAML_VERSION.getMajorVersion()) || version.getMajorVersion() == Shared.REQUIRED_SAML_VERSION.getMajorVersion() && version.getMinorVersion() < Shared.REQUIRED_SAML_VERSION.getMinorVersion()) { // version too low vr = new ValidationResult(OasisNames.VERSION_MISMATCH, OasisNames.REQUEST_VERSION_TOO_LOW); log.debug("Validation FAILED - Version is too low"); } } // Validate IssueInstant only if this is a new request (i.e. it had not pass been validated) if (vr == null && !t.isExistingRequest()) { DateTime dtPlus = request.getIssueInstant(); DateTime dtMinus = request.getIssueInstant(); DateTime instant = new DateTime(); long clockTolerance = accessor.getClockTolerance(); if (dtPlus == null) { vr = new ValidationResult(OasisNames.REQUESTER); log.debug("Validation FAILED - Issue Instant is missing"); } else { dtPlus = dtPlus.plus(clockTolerance); dtMinus = dtMinus.minus(clockTolerance); // dtPlus must be after now and dtMinus must be before now // in order to satisfy clock tolerance if (dtPlus.isBefore(instant) || dtMinus.isAfter(instant)) { vr = new ValidationResult(OasisNames.REQUESTER); log.debug("Validation FAILED - Issue Instant outside of clock tolerance"); log.debug("clockTolerance {}", clockTolerance); log.debug("now {}", instant); log.debug("dtPlus {}", dtPlus.toString()); log.debug("dtMinus {}", dtMinus.toString()); } } } // Destination URL skipped, this is already done by OpenSAML when parsing // validate scoping if presenet if (vr == null) { vr = validateScoping(t); } // signature must NOT be included if (vr == null) { if (request.getSignature() != null) { log.debug("Validation FAILED - Signature MUST NOT be present"); vr = new ValidationResult(OasisNames.REQUESTER, OasisNames.REQUEST_UNSUPPORTED); } } // ensure that we don't accept unsigned requests if configuration requires signing if (vr == null) { try { boolean mustBeSigned = accessor .getAuthnRequestsSignedForRelyingParty(request.getIssuer().getValue()); this.validateSigning(mustBeSigned, t); } catch (IllegalStateException e) { // set validation result to request denied log.error("Validation FAILED - unsigned request detected, signing required"); vr = new ValidationResult(OasisNames.RESPONDER, OasisNames.REQUEST_DENIED); } } // validate NameIDPolicy if present if (vr == null) { NameIDPolicy policy = request.getNameIDPolicy(); if (policy != null) { String format = policy.getFormat(); if (format != null && !format.equals(OasisNames.PERSISTENT) && !format.equals(OasisNames.EMAIL_ADDRESS) && !format.equals(SAMLNames.IDFORMAT_VAL_UPN.toString())) { log.error("Validation FAILED - unknown NameIDPolicy Format"); vr = new ValidationResult(OasisNames.REQUESTER, OasisNames.INVALID_NAMEID_POLICY); } } } // validate conditions if (vr == null) { Conditions conditions = request.getConditions(); if (conditions != null) { // notBefore processing DateTime notBefore = conditions.getNotBefore(); if (notBefore != null) { // no additional validation, we'll use whatever client wants t.setStartTime(notBefore.toDate()); } // delegable and renewable conditions for (Condition c : conditions.getConditions()) { if (c == null) { continue; } if (c instanceof RenewableType) { t.setRenewable(true); } if (c instanceof DelegableType) { t.setDelegable(true); } } } } if (vr == null) { computeSupportedAuthnTypes(t, request); } // validation done if (vr == null) { log.info("Authentication request validation succeeded"); vr = new ValidationResult(); // success // check if we need to convert a principal into emailAddress if (request.getNameIDPolicy() != null && request.getNameIDPolicy().getFormat() != null && request.getNameIDPolicy().getFormat().equals(OasisNames.EMAIL_ADDRESS)) { t.setIdentityFormat(OasisNames.IDENTITY_FORMAT_EMAIL_ADDRESS); } else { t.setIdentityFormat(OasisNames.IDENTITY_FORMAT_UPN); } } } catch (Exception e) { vr = new ValidationResult(HttpServletResponse.SC_BAD_REQUEST, "BadRequest", null); log.debug("Caught exception while Validating " + e.toString() + ", returning 400"); } return vr; }
From source file:com.vmware.identity.samlservice.impl.LogoutStateValidator.java
License:Open Source License
/** * Validate LogoutResponse//from ww w . ja v a 2 s . c o m * * @param vr * @param accessor * @param response * @return */ private com.vmware.identity.samlservice.SamlValidator.ValidationResult validateLogoutResponse( com.vmware.identity.samlservice.SamlValidator.ValidationResult vr, IdmAccessor accessor, LogoutResponse response, SessionManager sm) { Validate.notNull(response.getIssuer()); // Validate single logout service first, if that is valid, we can send // SAML replies try { @SuppressWarnings("unused") String acsUrl = accessor.getSloForRelyingParty(response.getIssuer().getValue(), OasisNames.HTTP_REDIRECT); } catch (IllegalStateException e) { // set validation result to 400 log.debug("Caught illegal state exception while Validating " + e.toString() + ", returning 400"); vr = new ValidationResult(HttpServletResponse.SC_BAD_REQUEST, e.getMessage(), null); } // Validate ID if (vr == null && response.getID() == null) { vr = new ValidationResult(OasisNames.REQUESTER); log.debug("Validation FAILED - Request ID is missing"); } // Validate version if (vr == null) { SAMLVersion version = response.getVersion(); if ((version.getMajorVersion() > Shared.REQUIRED_SAML_VERSION.getMajorVersion()) || version.getMajorVersion() == Shared.REQUIRED_SAML_VERSION.getMajorVersion() && version.getMinorVersion() > Shared.REQUIRED_SAML_VERSION.getMinorVersion()) { // version too high vr = new ValidationResult(OasisNames.VERSION_MISMATCH, OasisNames.REQUEST_VERSION_TOO_HIGH); log.debug("Validation FAILED - Version is too high"); } else if ((version.getMajorVersion() < Shared.REQUIRED_SAML_VERSION.getMajorVersion()) || version.getMajorVersion() == Shared.REQUIRED_SAML_VERSION.getMajorVersion() && version.getMinorVersion() < Shared.REQUIRED_SAML_VERSION.getMinorVersion()) { // version too low vr = new ValidationResult(OasisNames.VERSION_MISMATCH, OasisNames.REQUEST_VERSION_TOO_LOW); log.debug("Validation FAILED - Version is too low"); } } // Validate IssueInstant if (vr == null) { DateTime dtPlus = response.getIssueInstant(); DateTime dtMinus = response.getIssueInstant(); DateTime instant = new DateTime(); long clockTolerance = accessor.getClockTolerance(); if (dtPlus == null) { vr = new ValidationResult(OasisNames.REQUESTER); log.debug("Validation FAILED - Issue Instant is missing"); } else { dtPlus = dtPlus.plus(clockTolerance); dtMinus = dtMinus.minus(clockTolerance); // dtPlus must be after now and dtMinus must be before now // in order to satisfy clock tolerance if (dtPlus.isBefore(instant) || dtMinus.isAfter(instant)) { vr = new ValidationResult(OasisNames.REQUESTER); log.debug("Validation FAILED - Issue Instant outside of clock tolerance"); log.debug("clockTolerance {} ", clockTolerance); log.debug("now {}", instant); log.debug("dtPlus {}", dtPlus.toString()); log.debug("dtMinus {}", dtMinus.toString()); } } } // Destination URL skipped, this is already done by OpenSAML when // parsing // validate inResponseTo (which is the corresponding SLO request ID that // this response is targetting at) if (vr == null) { String inResponseTo = response.getInResponseTo(); if (inResponseTo == null) { vr = new ValidationResult(OasisNames.REQUESTER); log.debug("Validation FAILED - inResponseTo is missing"); } else { // try to find a session by LogoutRequest id that we have Session session = sm.getByLogoutRequestId(inResponseTo); if (session == null) { // No session found using the SLO request ID. This could // happen due to // fail-over (node switch). So here we ignore rather than // throw error at browser log.info( "Unable to identify a session the SLO response is referring to. This could be caused by site-affinity switch."); } } } // check response status code if (vr == null) { Status status = null; StatusCode statusCode = null; if (vr == null) { // check LogoutResponse status code here status = response.getStatus(); if (status == null) { vr = new ValidationResult(OasisNames.REQUESTER); log.debug("Validation FAILED - unable to find status code"); } } if (vr == null) { statusCode = status.getStatusCode(); if (statusCode == null) { vr = new ValidationResult(OasisNames.REQUESTER); log.debug("Validation FAILED - unable to find status code"); } } if (vr == null) { String code = statusCode.getValue(); if (!OasisNames.SUCCESS.equals(code)) { vr = new ValidationResult(OasisNames.SUCCESS, OasisNames.PARTIAL_LOGOUT); log.debug("Validation FAILED - partially logged out session"); } } } // validation done if (vr == null) { vr = new ValidationResult(); // success } return vr; }
From source file:com.vmware.identity.samlservice.impl.LogoutStateValidator.java
License:Open Source License
/** * Validate LogoutRequest// ww w. jav a 2 s. c o m * * @param vr * @param accessor * @param request * @return */ private ValidationResult validateLogoutRequest(ValidationResult vr, IdmAccessor accessor, LogoutRequest request) { Validate.notNull(request.getIssuer()); // Validate single logout service first, if that is valid, we can send // SAML replies try { @SuppressWarnings("unused") String acsUrl = accessor.getSloForRelyingParty(request.getIssuer().getValue(), OasisNames.HTTP_REDIRECT); } catch (IllegalStateException e) { // set validation result to 400 log.debug("Caught illegal state exception while Validating " + e.toString() + ", returning 400"); vr = new ValidationResult(HttpServletResponse.SC_BAD_REQUEST, e.getMessage(), null); } // Validate ID if (vr == null && request.getID() == null) { vr = new ValidationResult(OasisNames.REQUESTER); log.debug("Validation FAILED - Request ID is missing"); } // Validate version if (vr == null) { SAMLVersion version = request.getVersion(); if ((version.getMajorVersion() > Shared.REQUIRED_SAML_VERSION.getMajorVersion()) || version.getMajorVersion() == Shared.REQUIRED_SAML_VERSION.getMajorVersion() && version.getMinorVersion() > Shared.REQUIRED_SAML_VERSION.getMinorVersion()) { // version too high vr = new ValidationResult(OasisNames.VERSION_MISMATCH, OasisNames.REQUEST_VERSION_TOO_HIGH); log.debug("Validation FAILED - Version is too high"); } else if ((version.getMajorVersion() < Shared.REQUIRED_SAML_VERSION.getMajorVersion()) || version.getMajorVersion() == Shared.REQUIRED_SAML_VERSION.getMajorVersion() && version.getMinorVersion() < Shared.REQUIRED_SAML_VERSION.getMinorVersion()) { // version too low vr = new ValidationResult(OasisNames.VERSION_MISMATCH, OasisNames.REQUEST_VERSION_TOO_LOW); log.debug("Validation FAILED - Version is too low"); } } // Validate IssueInstant if (vr == null) { DateTime dtPlus = request.getIssueInstant(); DateTime dtMinus = request.getIssueInstant(); DateTime instant = new DateTime(); long clockTolerance = accessor.getClockTolerance(); if (dtPlus == null) { vr = new ValidationResult(OasisNames.REQUESTER); log.debug("Validation FAILED - Issue Instant is missing"); } else { dtPlus = dtPlus.plus(clockTolerance); dtMinus = dtMinus.minus(clockTolerance); // dtPlus must be after now and dtMinus must be before now // in order to satisfy clock tolerance if (dtPlus.isBefore(instant) || dtMinus.isAfter(instant)) { vr = new ValidationResult(OasisNames.REQUESTER); log.debug("Validation FAILED - Issue Instant outside of clock tolerance"); log.debug("clockTolerance {}", clockTolerance); log.debug("now {}", instant); log.debug("dtPlus {}", dtPlus.toString()); log.debug("dtMinus {}", dtMinus.toString()); } } } // Destination URL skipped, this is already done by OpenSAML when // parsing // Validate NotOnOrAfter if (vr == null) { DateTime notOnOrAfter = request.getNotOnOrAfter(); if (notOnOrAfter != null) { DateTime instant = new DateTime(); if (!instant.isBefore(notOnOrAfter)) { vr = new ValidationResult(OasisNames.REQUESTER, OasisNames.REQUEST_DENIED); log.debug("Validation FAILED - NotOnOrAfter condition violated"); log.debug("now {}", instant); log.debug("notOnOrAfter {}", notOnOrAfter.toString()); } } } // validate NameID if (vr == null) { NameID nameID = request.getNameID(); if (nameID == null || nameID.getFormat() == null || nameID.getValue() == null) { log.debug("Validation FAILED for NameID: node, format or value missing"); vr = new ValidationResult(OasisNames.REQUESTER); } } // validate session index if (vr == null) { List<SessionIndex> sessionList = request.getSessionIndexes(); if (sessionList == null || sessionList.size() == 0) { log.debug("Validation FAILED for session indices: at least one session index is required"); vr = new ValidationResult(OasisNames.REQUESTER); } } // validation done if (vr == null) { vr = new ValidationResult(); // success } return vr; }
From source file:com.yandex.money.api.model.showcase.components.uicontrols.Date.java
License:Open Source License
private static DateTime parseWithPeriod(DateTime dateTime, Period period, boolean add) { return add ? dateTime.plus(period) : dateTime.minus(period); }
From source file:ddf.catalog.cache.solr.impl.SolrFilterDelegate.java
License:Open Source License
@Override public SolrQuery relative(String propertyName, long duration) { DateTime now = new DateTime(); Date start = now.minus(duration).toDate(); Date end = now.toDate();/*w ww. j a v a2s.c o m*/ String formattedStartDate = formatDate(start); String formattedEndDate = formatDate(end); return buildDateQuery(propertyName, SOLR_INCLUSIVE_START, formattedStartDate, formattedEndDate, SOLR_INCLUSIVE_END); }
From source file:ddf.catalog.filter.proxy.adapter.GeotoolsFilterAdapterImpl.java
License:Open Source License
public Object visit(PropertyIsEqualTo filter, Object delegate) { ExpressionValues filterValues = getExpressions(filter, delegate); String propertyName = filterValues.propertyName; Object literal = filterValues.literal; String functionName = filterValues.functionName; List<Object> functionArgs = filterValues.functionArgs; // Special case to handle relative temporal queries if (literal instanceof String && RELATIVE_TEMPORAL_REGEX.matcher((String) literal).matches()) { DateTime currentDateTime = new DateTime(); org.joda.time.Period period = PeriodParser.parse((String) literal, RELATIVE_TEMPORAL_REGEX); DateTime pastDateTime = currentDateTime.minus(period); return ((FilterDelegate<?>) delegate).propertyIsBetween(propertyName, pastDateTime.toDate(), currentDateTime.toDate()); }/*ww w . ja v a2 s . c om*/ if (functionName != null) { return ((FilterDelegate<?>) delegate).propertyIsEqualTo(functionName, functionArgs, literal); } else if (literal instanceof String) { return ((FilterDelegate<?>) delegate).propertyIsEqualTo(propertyName, (String) literal, filter.isMatchingCase()); } else if (literal instanceof Date) { return ((FilterDelegate<?>) delegate).propertyIsEqualTo(propertyName, (Date) literal); } else if (literal instanceof Instant) { return ((FilterDelegate<?>) delegate).propertyIsEqualTo(propertyName, ((Instant) literal).getPosition().getDate()); } else if (literal instanceof Period) { return ((FilterDelegate<?>) delegate).propertyIsEqualTo(propertyName, ((Period) literal).getBeginning().getPosition().getDate(), ((Period) literal).getEnding().getPosition().getDate()); } else if (literal instanceof Integer) { return ((FilterDelegate<?>) delegate).propertyIsEqualTo(propertyName, ((Integer) literal).intValue()); } else if (literal instanceof Short) { return ((FilterDelegate<?>) delegate).propertyIsEqualTo(propertyName, ((Short) literal).shortValue()); } else if (literal instanceof Long) { return ((FilterDelegate<?>) delegate).propertyIsEqualTo(propertyName, ((Long) literal).longValue()); } else if (literal instanceof Float) { return ((FilterDelegate<?>) delegate).propertyIsEqualTo(propertyName, ((Float) literal).floatValue()); } else if (literal instanceof Double) { return ((FilterDelegate<?>) delegate).propertyIsEqualTo(propertyName, ((Double) literal).doubleValue()); } else if (literal instanceof Boolean) { return ((FilterDelegate<?>) delegate).propertyIsEqualTo(propertyName, ((Boolean) literal).booleanValue()); } else if (literal instanceof byte[]) { return ((FilterDelegate<?>) delegate).propertyIsEqualTo(propertyName, (byte[]) literal); } else { return ((FilterDelegate<?>) delegate).propertyIsEqualTo(propertyName, literal); } }
From source file:de.ifgi.airbase.feeder.io.filter.TimeRangeFilter.java
License:Open Source License
public void addRange(Period length, DateTime end) { this.ranges.add(new Range(end.minus(length), end)); }