|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.musclecard.CardEdge.ObjectManager
Object Manager Class
Objects are linked in a list in the dynamic memory. No smart search is done at the moment.
TODO - Could we definitively avoid a map enforcing the ID (equal to the memory address, i.e.) - security implications ?
Object fields:short next short obj_class short obj_id short obj_size byte[] data
Field Summary | |
private short |
it
Iterator on objects. |
private MemoryManager |
mem
The Memory Manager object |
static byte |
OBJ_ACL_SIZE
|
private static byte |
OBJ_H_ACL
|
private static byte |
OBJ_H_CLASS
|
private static byte |
OBJ_H_DATA
|
private static byte |
OBJ_H_ID
|
private static byte |
OBJ_H_NEXT
|
private static byte |
OBJ_H_SIZE
|
private static byte |
OBJ_HEADER_SIZE
|
private short |
obj_list_head
Head of the objects' list |
static short |
RECORD_SIZE
Size of an Object Record filled by getFirstRecord() or getNextRecord(): ID, Size, ACL |
static short |
SW_NO_MEMORY_LEFT
There have been memory problems on the card |
static short |
SW_OBJECT_NOT_FOUND
|
Constructor Summary | |
ObjectManager(MemoryManager mem_ref)
Constructor for the ObjectManager class. |
Method Summary | |
boolean |
authorizeDeleteFromAddress(short base,
short logged_ids)
Allow or unallow delete on object given the logged identities |
private boolean |
authorizeOp(short required_ids,
short logged_ids)
Check if logged in identities satisfy requirements for an operation |
boolean |
authorizeReadFromAddress(short base,
short logged_ids)
Allow or unallow read on object given the logged identities |
boolean |
authorizeWriteFromAddress(short base,
short logged_ids)
Allow or unallow write on object given the logged identities |
boolean |
clampObject(short type,
short id,
short new_size)
Clamps an object freeing the unused memory |
boolean |
compareACLFromAddress(short base,
byte[] acl)
Compare an object's ACL with the provided ACL. |
short |
createObject(short type,
short id,
short size,
byte[] acl_buf,
short acl_offset)
Creates an object with specified parameters. |
short |
createObjectMax(short type,
short id,
byte[] acl_buf,
short acl_offset)
Creates an object with the maximum available size |
void |
destroyObject(short type,
short id,
boolean secure)
Destroy the specified object |
boolean |
exists(short type,
short id)
Checks if an object exists |
short |
getBaseAddress(short type,
short id)
Returns the data base address (offset) for an object. |
private short |
getEntry(short type,
short id)
Returns the header base address (offset) for the specified object. |
boolean |
getFirstRecord(byte[] buffer,
short offset)
Resets the objects iterator and retrieves the information record of the first object, if any. |
boolean |
getNextRecord(byte[] buffer,
short offset)
Retrieves the information record of the next object, if any. |
short |
getSizeFromAddress(short base)
Returns object size from the base address |
private void |
setACL(short type,
short id,
byte[] acl_buf,
short acl_offset)
Set the object's ACL. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private short it
private MemoryManager mem
public static final byte OBJ_ACL_SIZE
private static final byte OBJ_H_ACL
private static final byte OBJ_H_CLASS
private static final byte OBJ_H_DATA
private static final byte OBJ_H_ID
private static final byte OBJ_H_NEXT
private static final byte OBJ_H_SIZE
private static final byte OBJ_HEADER_SIZE
private short obj_list_head
public static final short RECORD_SIZE
public static final short SW_NO_MEMORY_LEFT
public static final short SW_OBJECT_NOT_FOUND
Constructor Detail |
public ObjectManager(MemoryManager mem_ref)
mem_ref
- The MemoryManager object to be used to allocate
objects' memory.Method Detail |
public boolean authorizeDeleteFromAddress(short base, short logged_ids)
private boolean authorizeOp(short required_ids, short logged_ids)
required_ids
- The required identities as from an ACL shortlogged_ids
- The current logged in identities as stored in
CardEdge.logged_idspublic boolean authorizeReadFromAddress(short base, short logged_ids)
base
- The object base address as returned from
getBaseAddress()logged_ids
- The current logged in identities as stored in
CardEdge.logged_idspublic boolean authorizeWriteFromAddress(short base, short logged_ids)
base
- The object base address as returned from
getBaseAddress()logged_ids
- The current logged in identities as stored in
CardEdge.logged_idspublic boolean clampObject(short type, short id, short new_size)
type
- Object Typeid
- Object ID (Type and ID form a generic 4 bytes
identifier)new_size
- The new object size (must be less than current
size)
SW_NO_MEMORY_LEFT
- exception if cannot allocate the
memory. Does not check if object exists.public boolean compareACLFromAddress(short base, byte[] acl)
base
- The object base address, as returned from
getBaseAddress()acl
- The buffer containing the ACL
public short createObject(short type, short id, short size, byte[] acl_buf, short acl_offset)
type
- Object Typeid
- Object ID (Type and ID form a generic 4 bytes
identifier)acl_buf
- Java byte array containing the ACL for the new objectacl_offset
- Offset at which the ACL starts in acl_buf[]
SW_NO_MEMORY_LEFT
- exception if cannot allocate the
memory. Does not check if object exists.public short createObjectMax(short type, short id, byte[] acl_buf, short acl_offset)
public void destroyObject(short type, short id, boolean secure)
type
- Object Typeid
- Object ID (Type and ID form a generic 4 bytes
identifier)secure
- If true, object memory is zeroed before being
released.public boolean exists(short type, short id)
type
- The object typeid
- The object ID
public short getBaseAddress(short type, short id)
The base address can be used for further calls to xxxFromAddress() methods
This function should only be used if performance issue arise. setObjectData() and getObjectData() should be used, instead.
type
- Object Typeid
- Object ID (Type and ID form a generic 4 bytes
identifier)
private short getEntry(short type, short id)
Object header is found at the returned offset, while object data starts right after the header.
This performs a linear search, so performance issues could arise as the number of objects grows If object is not found, then returns NULL_OFFSET.
type
- Object Typeid
- Object ID (Type and ID form a generic 4 bytes
identifier)
public boolean getFirstRecord(byte[] buffer, short offset)
buffer
- The byte array into which the record will be copiedoffset
- The offset in buffer[] at which the record will be
copied
getNextRecord(byte[], short)
public boolean getNextRecord(byte[] buffer, short offset)
buffer
- The byte array into which the record will be copiedoffset
- The offset in buffer[] at which the record will be
copied
getFirstRecord(byte[], short)
public short getSizeFromAddress(short base)
private void setACL(short type, short id, byte[] acl_buf, short acl_offset)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |