FileDocCategorySizeDatePackage
AccessControlManager.javaAPI DocphoneME MR2 API (J2ME)4672Wed May 02 18:00:38 BST 2007com.sun.satsa.acl

AccessControlManager

public class AccessControlManager extends Object
This class represents access control information manager.

Fields Summary
private static ACSlot[]
ACLInfo
Access control information for card slots.
private static com.sun.midp.ssl.MessageDigest
sha
SHA-1 message digest object.
private static Object
shaSync
Synchronization object for message digest calculation.
Constructors Summary
Methods Summary
public static APDUPermissionsgetAPDUPermissions(int slot, byte[] selectAPDU, java.lang.String root)
Returns object that should be used for access control verification.

param
slot slot number.
param
selectAPDU SELECT APDU command data.
param
root name of CA that authorized the suite.
return
object that can be used to check permissions.

        if (ACLInfo == null || ACLInfo[slot] == null) {
            APDUPermissions perm;
            perm = new APDUPermissions(null);
            perm.setType(ACLPermissions.DISALLOW);
            return perm;
        }

        return (APDUPermissions) ACLInfo[slot].getACLPermissions(true,
               selectAPDU, root);
    
public static byte[]getHash(byte[] inBuf, int inOff, int inLen)
Calculates hash value.

param
inBuf data buffer.
param
inOff offset of data in the buffer.
param
inLen length of data.
return
array containing SHA-1 hash.


                                  
             

        synchronized (shaSync) {

            try {
                if (sha == null) {
                    sha = MessageDigest.getInstance(MessageDigest.ALG_SHA,
                            false);
                }
                sha.reset();
                byte[] hash = new byte[20];
                sha.doFinal(inBuf, inOff, inLen, hash, 0);
                return hash;
            } catch (Exception e) {
                e.printStackTrace();
                return null;
            }
        }
    
public static JCRMIPermissionsgetJCRMIPermissions(int slot, byte[] selectAPDU, java.lang.String root)
Returns object that should be used for access control verification.

param
slot slot number.
param
selectAPDU SELECT APDU command data.
param
root name of CA that authorized the suite.
return
object that can be used to check permissions.

        if (ACLInfo == null || ACLInfo[slot] == null) {
            JCRMIPermissions perm = new JCRMIPermissions(null);
            perm.setType(ACLPermissions.DISALLOW);
            return perm;
        }

        return (JCRMIPermissions) ACLInfo[slot].getACLPermissions(false,
               selectAPDU, root);
    
private static synchronized voidinit()
Initialise ACL information.

        if (ACLInfo != null) {
            return;
        }
        int maxSlot = APDUManager.getSlotCount();
        ACLInfo = new ACSlot[maxSlot];
        for (int i = 0; i < maxSlot; i++) {
            ACLInfo[i] = ACSlot.load(i);
        }
    
public static synchronized voidinit(int slot)
Initialize ACL information.

param
slot int the slot number.

        if (ACLInfo == null) {
            init();
        }
        if (ACLInfo != null) {
            ACLInfo[slot] = ACSlot.load(slot);
        }