Class AnjaySecurityObject


  • public final class AnjaySecurityObject
    extends java.lang.Object
    Default implementation of LwM2M Security Object (/0).
    • Method Detail

      • install

        public static AnjaySecurityObject install​(Anjay anjay)
                                           throws java.lang.Exception
        Installs the Security Object in an Anjay instance.
        Parameters:
        anjay - Anjay instance for which the Security Object is installed.
        Returns:
        Security object which may be used to manage its instances.
        Throws:
        java.lang.Exception - In case of error.
      • addInstance

        public int addInstance​(AnjaySecurityObject.Instance instance)
                        throws java.lang.Exception
        Adds new Instance of Security Object and returns newly created Instance ID.

        Warning: calling this function during active communication with Bootstrap Server may yield undefined behavior and unexpected failures may occur.

        Parameters:
        instance - Security Instance to insert.
        Returns:
        ID of the added instance.
        Throws:
        java.lang.Exception - If instance can't be added.
      • addInstance

        public int addInstance​(AnjaySecurityObject.Instance instance,
                               int preferredIid)
                        throws java.lang.Exception
        Overload of addInstance(Instance), but allows to specify preferred Instance ID.

        Note: if preferredIid is set to Anjay.ID_INVALID then the Instance ID is generated automatically.

        Parameters:
        instance - Security Instance to insert.
        preferredIid - Preferred Instance ID to be set.
        Returns:
        ID of the added instance.
        Throws:
        java.lang.Exception - If instance can't be added.
      • purge

        public void purge()
        Purges instances of Security Object leaving it in an empty state.
      • persist

        public void persist​(java.io.OutputStream outputStream)
                     throws java.lang.Exception
        Dumps Security Object Instances into the outputStream.
        Parameters:
        outputStream - Stream to write to.
        Throws:
        java.lang.Exception - If instances can't be persisted.
      • restore

        public void restore​(java.io.InputStream inputStream)
                     throws java.lang.Exception
        Attempts to restore Security Object Instances from specified inputStream.

        Note: if restore fails, then Security Object will be left untouched, on success though all Instances stored within the Object will be purged.

        Parameters:
        inputStream - Stream to read from.
        Throws:
        java.lang.Exception - If instances can't be restored.
      • isModified

        public boolean isModified()
        Checks whether the Security Object from Anjay instance has been modified since last successful call to persist() or restore.
        Returns:
        true if Security Object has beed modified, false otherwise.