/** * Validate if the timestamps are equal. * Compares now + 1 == then, because server adds +1 to authenticator's timestamp. * * @param now the first timestamp * @param then the second timestamp * @throws RejectedException thrown if the timestamps have a different time */ public static void validateTimestamp(Timestamp now, Timestamp then) throws RejectedException { if (now.getTime() + 1 != then.getTime()) { throw new RejectedException("Timestamps do not match"); } } }
@Override public void processData(String id, IdentifiableMessage<String, UnitConfig, Builder> entry, ProtoBufMessageMap<String, UnitConfig, Builder> entryMap, ProtoBufRegistry<String, UnitConfig, Builder> registry) throws CouldNotPerformException, EntryModification { final UnitConfig.Builder unitConfig = entry.getMessage().toBuilder(); for (final String alias : unitConfig.getAliasList()) { if (!aliasUnitIdMap.containsKey(alias.toLowerCase())) { aliasUnitIdMap.put(alias.toLowerCase(), unitConfig.getId()); } else { // if already known check if this unit is owning the alias otherwise throw invalid state if (!aliasUnitIdMap.get(alias.toLowerCase()).equals(unitConfig.getId())) { throw new RejectedException("Alias[" + alias.toLowerCase() + "] of Unit[" + ScopeGenerator.generateStringRep(unitConfig.getScope()) + ", " + unitConfig.getId() + "] is already used by Unit[" + aliasUnitIdMap.get(alias.toLowerCase()) + "]"); } } } }
public TicketAuthenticatorWrapper initializeServiceServerRequest() throws RejectedException { try { return AuthenticationClientHandler.initServiceServerRequest(this.getSessionKey(), this.getTicketAuthenticatorWrapper()); } catch (IOException | BadPaddingException ex) { throw new RejectedException("Initializing request rejected", ex); } }
@Override public void beforeRemove(IdentifiableMessage<String, UnitConfig, UnitConfig.Builder> entry) throws RejectedException { try { for (String unitId : entry.getMessage().getDeviceConfig().getUnitIdList()) { dalUnitRegistry.remove(unitId); } } catch (CouldNotPerformException ex) { throw new RejectedException("Could not remove all units for the removed device!", ex); } }
public void setupRootLocationIfNeeded() throws RejectedException { try { // check if any location exist if (getRegistry().isEmpty()) { getRegistry().register(generateDefaultRootLocation()); } } catch (final CouldNotPerformException ex) { throw new RejectedException("Could not setup default root location!", ex); } }
timeout = checkStart - System.currentTimeMillis(); if (timeout <= 0) { throw new RejectedException("Rejected because of scene timeout.");
throw new RejectedException(matcher.group(1));
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(); } }
throw new RejectedException(matcher.group(1));
throw new RejectedException(matcher.group(1));
throw new RejectedException(matcher.group(1));
throw new RejectedException(matcher.group(1));
throw new RejectedException("The root location cannot be removed. If you want to remove this location introduce another root first."); throw new RejectedException("Could not remove all regions of tile[" + entry.getMessage().getLabel() + "] which have to be removed"); throw new RejectedException("Could not remove all connection of tile[" + entry.getMessage().getLabel() + "] which have to be removed"); throw new RejectedException("Unable to transfer all units registerd at[" + entry.getMessage().getLabel() + "] to its parent", ex); throw new RejectedException("Unable to transfer all units registerd at[" + entry.getMessage().getLabel() + "] to its parent", ex);
} catch (BadPaddingException ex) { ExceptionPrinter.printHistory(ex, LOGGER, LogLevel.ERROR); throw new RejectedException(ex); } catch (RejectedException ex) { throw ExceptionPrinter.printHistoryAndReturnThrowable(ex, LOGGER, LogLevel.ERROR);
throw new RejectedException("Could not update position in device from a change in a unit", ex);