/** * Gets Date for ZonedDateTime. * * @param time Time object to be converted. * @return Date representing time */ public static Date dateOf(final ChronoZonedDateTime time) { return dateOf(time.toInstant()); }
/** * Format the datetime given. * * @param dt the datetime * @return the date and time */ public String format(final Instant dt) { return format(DateTimeUtils.dateOf(dt)); } }
/** * Format the datetime given. * * @param dt the datetime * @return the date and time */ public String format(final ZonedDateTime dt) { return format(DateTimeUtils.dateOf(dt)); }
/** * Build cas assertion. * * @param principal the principal * @param registeredService the registered service * @param attributes the attributes * @return the assertion */ protected Assertion buildCasAssertion(final String principal, final RegisteredService registeredService, final Map<String, Object> attributes) { val p = new AttributePrincipalImpl(principal, attributes); return new AssertionImpl(p, DateTimeUtils.dateOf(ZonedDateTime.now()), null, DateTimeUtils.dateOf(ZonedDateTime.now()), attributes); }
@Override public void encode(final BsonWriter writer, final ZonedDateTime zonedDateTime, final EncoderContext encoderContext) { writer.writeTimestamp(new BsonTimestamp(DateTimeUtils.dateOf(zonedDateTime).getTime())); }
@Override public Set<? extends AuditActionContext> getAuditRecordsSince(final LocalDate localDate) { val dt = DateTimeUtils.dateOf(localDate); LOGGER.debug("Retrieving audit records since [{}] from [{}]", dt, this.collectionName); val query = new Query().addCriteria(Criteria.where("whenActionWasPerformed").gte(dt)); return new LinkedHashSet<>(this.mongoTemplate.find(query, AuditActionContext.class, this.collectionName)); } }
/** * Records an audit action. * * @param request The current HTTP request. * @param actionName Name of the action to be recorded. */ protected void recordAuditAction(final HttpServletRequest request, final String actionName) { val userToUse = getUsernameParameterFromRequest(request); val clientInfo = ClientInfoHolder.getClientInfo(); val resource = StringUtils.defaultString(request.getParameter(CasProtocolConstants.PARAMETER_SERVICE), "N/A"); val context = new AuditActionContext( userToUse, resource, actionName, this.applicationCode, DateTimeUtils.dateOf(ZonedDateTime.now(ZoneOffset.UTC)), clientInfo.getClientIpAddress(), clientInfo.getServerIpAddress()); LOGGER.debug("Recording throttled audit action [{}}", context); this.auditTrailExecutionPlan.record(context); } }
@Override @SneakyThrows public String build(final TicketGrantingTicket ticketGrantingTicket) { val authentication = ticketGrantingTicket.getAuthentication(); val attributes = new HashMap<String, Object>(authentication.getAttributes()); attributes.putAll(authentication.getPrincipal().getAttributes()); val dt = ZonedDateTime.now().plusSeconds(expirationPolicy.getTimeToLive()); val validUntilDate = DateTimeUtils.dateOf(dt); return buildJwt(ticketGrantingTicket.getId(), casSeverPrefix, DateTimeUtils.dateOf(ticketGrantingTicket.getCreationTime()), authentication.getPrincipal().getId(), validUntilDate, attributes); }
/** * Build cas assertion. * * @param authentication the authentication * @param service the service * @param registeredService the registered service * @param attributesToCombine the attributes to combine * @return the assertion */ protected Assertion buildCasAssertion(final Authentication authentication, final Service service, final RegisteredService registeredService, final Map<String, Object> attributesToCombine) { val attributes = registeredService.getAttributeReleasePolicy().getAttributes(authentication.getPrincipal(), service, registeredService); val principal = new AttributePrincipalImpl(authentication.getPrincipal().getId(), attributes); val authnAttrs = new LinkedHashMap(authentication.getAttributes()); authnAttrs.putAll(attributesToCombine); return new AssertionImpl(principal, DateTimeUtils.dateOf(authentication.getAuthenticationDate()), null, DateTimeUtils.dateOf(authentication.getAuthenticationDate()), authnAttrs); }
@Override @SneakyThrows public String build(final String serviceTicketId, final Service service) { val assertion = this.ticketValidator.validate(serviceTicketId, service.getId()); val attributes = new HashMap<String, Object>(assertion.getAttributes()); attributes.putAll(assertion.getPrincipal().getAttributes()); val validUntilDate = FunctionUtils.doIf( assertion.getValidUntilDate() != null, assertion::getValidUntilDate, () -> { val dt = ZonedDateTime.now().plusSeconds(expirationPolicy.getTimeToLive()); return DateTimeUtils.dateOf(dt); }) .get(); return buildJwt(serviceTicketId, service.getId(), assertion.getAuthenticationDate(), assertion.getPrincipal().getName(), validUntilDate, attributes); }
sso.put(SsoSessionAttributeKeys.AUTHENTICATION_DATE.toString(), authentication.getAuthenticationDate()); sso.put(SsoSessionAttributeKeys.AUTHENTICATION_DATE_FORMATTED.toString(), dateFormat.format(DateTimeUtils.dateOf(authentication.getAuthenticationDate()))); sso.put(SsoSessionAttributeKeys.NUMBER_OF_USES.toString(), tgt.getCountOfUses()); sso.put(SsoSessionAttributeKeys.TICKET_GRANTING_TICKET.toString(), tgt.getId());
sso.put(SsoSessionAttributeKeys.AUTHENTICATION_DATE.toString(), authentication.getAuthenticationDate()); sso.put(SsoSessionAttributeKeys.AUTHENTICATION_DATE_FORMATTED.toString(), dateFormat.format(DateTimeUtils.dateOf(authentication.getAuthenticationDate()))); sso.put(SsoSessionAttributeKeys.NUMBER_OF_USES.toString(), tgt.getCountOfUses()); sso.put(SsoSessionAttributeKeys.TICKET_GRANTING_TICKET.toString(), tgt.getId());
} else { final ZonedDateTime dt = ZonedDateTime.now().plusSeconds(ticketGrantingTicketExpirationPolicy.getTimeToLive()); claims.expirationTime(DateTimeUtils.dateOf(dt));