@Override public Iterator<Registration> getAllRegistrations() { return store.getAllRegistrations(); }
@Override public Registration getById(String id) { return store.getRegistration(id); }
@Override public Registration getByEndpoint(String endpoint) { return store.getRegistrationByEndpoint(endpoint); }
public RegistrationServiceImpl(RegistrationStore store) { this.store = store; store.setExpirationListener(this); }
@Override public String getIdentity(InetSocketAddress inetAddress) { if (registrationStore == null) return null; Registration registration = registrationStore.getRegistrationByAdress(inetAddress); if (registration != null) { SecurityInfo securityInfo = securityStore.getByEndpoint(registration.getEndpoint()); if (securityInfo != null) { return securityInfo.getIdentity(); } return null; } return null; }
public SendableResponse<DeregisterResponse> deregister(Identity sender, DeregisterRequest deregisterRequest) { // We must check if the client is using the right identity. Registration registration = registrationService.getById(deregisterRequest.getRegistrationId()); if (registration == null) { return new SendableResponse<>(DeregisterResponse.notFound()); } if (authorizer.isAuthorized(deregisterRequest, registration, sender) == null) { // TODO replace by Forbidden if https://github.com/OpenMobileAlliance/OMA_LwM2M_for_Developers/issues/181 is // closed. return new SendableResponse<>(DeregisterResponse.badRequest("forbidden")); } final Deregistration deregistration = registrationService.getStore() .removeRegistration(deregisterRequest.getRegistrationId()); if (deregistration != null) { LOG.debug("Deregistered client: {}", deregistration.getRegistration()); // Create callback to notify new de-registration Runnable whenSent = new Runnable() { @Override public void run() { registrationService.fireUnregistered(deregistration.getRegistration(), deregistration.getObservations(), null); }; }; return new SendableResponse<>(DeregisterResponse.success(), whenSent); } else { LOG.debug("Invalid deregistration : registration {} not found", registration.getId()); return new SendableResponse<>(DeregisterResponse.notFound()); } }
final UpdatedRegistration updatedRegistration = registrationService.getStore().updateRegistration(update); if (updatedRegistration == null) { LOG.debug("Invalid update: registration {} not found", registration.getId());
final Deregistration deregistration = registrationService.getStore().addRegistration(registration);