Skip to content

Commit

Permalink
Align with latest feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
rikard-sics committed Feb 12, 2025
1 parent f480653 commit 5a7e44d
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.eclipse.californium.oscore.OSCoreCtx;
import org.eclipse.californium.oscore.OSCoreCtxDB;
import org.eclipse.leshan.core.observation.Observation;
import org.eclipse.leshan.core.peer.LwM2mIdentity;
import org.eclipse.leshan.core.peer.OscoreIdentity;
import org.eclipse.leshan.server.registration.Registration;
import org.eclipse.leshan.server.registration.RegistrationListener;
Expand Down Expand Up @@ -58,9 +59,19 @@ public void updated(RegistrationUpdate update, Registration updatedReg, Registra
@Override
public void unregistered(Registration registration, Collection<Observation> observations, boolean expired,
Registration newReg) {
if (registration.getClientTransportData().getIdentity() instanceof OscoreIdentity && newReg == null) {
removeContext(((OscoreIdentity) registration.getClientTransportData().getIdentity()).getRecipientId());
LwM2mIdentity unregisteredIdentity = registration.getClientTransportData().getIdentity();

// Not an OSCORE identity : nothing to clear
if (!(unregisteredIdentity instanceof OscoreIdentity))
return;

// This is a Re-Registration and client use same OSCORE Identity : nothing to clear
if (newReg != null && unregisteredIdentity.equals(newReg.getClientTransportData().getIdentity())) {
return;
}

// else
removeContext(((OscoreIdentity) unregisteredIdentity).getRecipientId());
}

@Override
Expand Down

0 comments on commit 5a7e44d

Please sign in to comment.