Package com.avsystem.anjay
Class AnjaySecurityObject
- java.lang.Object
-
- com.avsystem.anjay.AnjaySecurityObject
-
public final class AnjaySecurityObject extends java.lang.ObjectDefault implementation of LwM2M Security Object (/0).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAnjaySecurityObject.InstanceInstance of LwM2M Security Object.static classAnjaySecurityObject.SecurityModePossible values of the Security Mode Resource, as described in the Security Object definition.static classAnjaySecurityObject.SmsSecurityModePossible values of the SMS Security Mode Resource, as described in the Security Object definition.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intaddInstance(AnjaySecurityObject.Instance instance)Adds new Instance of Security Object and returns newly created Instance ID.intaddInstance(AnjaySecurityObject.Instance instance, int preferredIid)Overload ofaddInstance(Instance), but allows to specify preferred Instance ID.static AnjaySecurityObjectinstall(Anjay anjay)Installs the Security Object in an Anjay instance.booleanisModified()voidpersist(java.io.OutputStream outputStream)Dumps Security Object Instances into theoutputStream.voidpurge()Purges instances of Security Object leaving it in an empty state.voidrestore(java.io.InputStream inputStream)Attempts to restore Security Object Instances from specifiedinputStream.
-
-
-
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 ofaddInstance(Instance), but allows to specify preferred Instance ID.Note: if
preferredIidis set toAnjay.ID_INVALIDthen 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.ExceptionDumps Security Object Instances into theoutputStream.- 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.ExceptionAttempts to restore Security Object Instances from specifiedinputStream.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.
-
-