/** * Create an interval which start now and ends after the maximum of MIN_ALLCOCATION_TIME_MILLI * and the executionTimePeriod. * Updates the executionTimePeriod of the given actionDescription. * * @param actionDescription actionDescription * @return an Interval generated as described above */ public static Interval getAllocationInterval(final ActionDescription.Builder actionDescription) { Interval.Builder interval = Interval.newBuilder(); actionDescription.setExecutionTimePeriod(Math.min(actionDescription.getExecutionTimePeriod(), actionDescription.getExecutionValidity().getMillisecondsSinceEpoch() - System.currentTimeMillis())); interval.setBegin(TimestampProcessor.getCurrentTimestamp()); interval.setEnd(TimestampJavaTimeTransform.transform(System.currentTimeMillis() + Math.max(MIN_ALLOCATION_TIME_MILLI, actionDescription.getExecutionTimePeriod()))); return interval.build(); }
applyDataUpdate(ActivationState.newBuilder().setValue(ActivationState.State.DEACTIVE).setTimestamp(TimestampProcessor.getCurrentTimestamp()).build(), ServiceType.ACTIVATION_STATE_SERVICE);
authenticator.setTimestamp(TimestampProcessor.getCurrentTimestamp());
public static void validateTicket(Ticket ticket, Authenticator authenticator) throws RejectedException { // validate that client and ids in authenticator and ticket match if (!ticket.hasClientId() || ticket.getClientId().isEmpty()) { throw new RejectedException("Ticket does not contain a client id"); } if (!authenticator.hasClientId() || authenticator.getClientId().isEmpty()) { throw new RejectedException("Authenticator does not contain a client id"); } if (!authenticator.getClientId().equals(ticket.getClientId())) { System.err.println("Received an erroneous request regarding the client id. Expected[" + ticket.getClientId() + "] but was[" + authenticator.getClientId() + "]"); throw new RejectedException("ClientIds do not match"); } // validate that the timestamp from the client request is inside the validation interval of the ticket if (!AuthenticationServerHandler.isTimestampInInterval(authenticator.getTimestamp(), ticket.getValidityPeriod())) { throw new SessionExpiredException(); } // validate that the timestamp does not differ to much from the time of the server Timestamp currentTime = TimestampProcessor.getCurrentTimestamp(); if (authenticator.getTimestamp().getTime() < (currentTime.getTime() - MAX_TIME_DIFF_SERVER_CLIENT) || authenticator.getTimestamp().getTime() > (currentTime.getTime() + MAX_TIME_DIFF_SERVER_CLIENT)) { throw new SessionExpiredException(); } }
/** * Initializes a ServiceServer request by setting the current timestamp in the authenticator. * * @param serviceServerSessionKey SS session key provided by handleTGSResponse() * @param wrapper TicketAuthenticatorWrapper wrapper that contains both encrypted Authenticator and CST * @return Returns a wrapper class containing both the CST and modified Authenticator * * @throws BadPaddingException If the decryption of the Authenticator fails. * @throws IOException If de- or encryption fail because of a general I/O error. */ public static TicketAuthenticatorWrapper initServiceServerRequest(byte[] serviceServerSessionKey, TicketAuthenticatorWrapper wrapper) throws IOException, BadPaddingException { // decrypt authenticator Authenticator.Builder authenticator = EncryptionHelper.decryptSymmetric(wrapper.getAuthenticator(), serviceServerSessionKey, Authenticator.class).toBuilder(); // update timestamp authenticator.setTimestamp(TimestampProcessor.getCurrentTimestamp()); // update ticket authenticatorWrapper TicketAuthenticatorWrapper.Builder ticketAuthenticatorWrapper = wrapper.toBuilder(); ticketAuthenticatorWrapper.setAuthenticator(EncryptionHelper.encryptSymmetric(authenticator.build(), serviceServerSessionKey)); return ticketAuthenticatorWrapper.build(); }
applyDataUpdate(activation.toBuilder().setTimestamp(TimestampProcessor.getCurrentTimestamp()).build(), ServiceType.ACTIVATION_STATE_SERVICE); } catch (CouldNotPerformException ex) { throw new CouldNotPerformException("Could not " + StringProcessor.transformUpperCaseToCamelCase(activation.getValue().name()) + " " + this, ex);