mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 884594 - Part 4: Initial integration with ACE. r=allstars.chh
This commit is contained in:
parent
7bc6d6e3c4
commit
1bd29c68d9
@ -199,6 +199,9 @@ function SecureElementManager() {
|
||||
this._registerMessageListeners();
|
||||
this._registerSEListeners();
|
||||
Services.obs.addObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
|
||||
this._acEnforcer =
|
||||
Cc["@mozilla.org/secureelement/access-control/ace;1"]
|
||||
.getService(Ci.nsIAccessControlEnforcer);
|
||||
}
|
||||
|
||||
SecureElementManager.prototype = {
|
||||
@ -219,7 +222,10 @@ SecureElementManager.prototype = {
|
||||
// key: secure element type, value: (Boolean) is present/accessible
|
||||
_sePresence: {},
|
||||
|
||||
_acEnforcer: null,
|
||||
|
||||
_shutdown: function() {
|
||||
this._acEnforcer = null;
|
||||
this.secureelement = null;
|
||||
Services.obs.removeObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
|
||||
this._unregisterMessageListeners();
|
||||
@ -288,7 +294,6 @@ SecureElementManager.prototype = {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Bug 1118098 - Integrate with ACE module
|
||||
let connector = getConnector(msg.type);
|
||||
if (!connector) {
|
||||
debug("No SE connector available");
|
||||
@ -296,29 +301,41 @@ SecureElementManager.prototype = {
|
||||
return;
|
||||
}
|
||||
|
||||
connector.openChannel(SEUtils.byteArrayToHexString(msg.aid), {
|
||||
notifyOpenChannelSuccess: (channelNumber, openResponse) => {
|
||||
// Add the new 'channel' to the map upon success
|
||||
let channelToken =
|
||||
gMap.addChannel(msg.appId, msg.type, msg.aid, channelNumber);
|
||||
if (channelToken) {
|
||||
callback({
|
||||
error: SE.ERROR_NONE,
|
||||
channelToken: channelToken,
|
||||
isBasicChannel: (channelNumber === SE.BASIC_CHANNEL),
|
||||
openResponse: SEUtils.hexStringToByteArray(openResponse)
|
||||
});
|
||||
} else {
|
||||
callback({ error: SE.ERROR_GENERIC });
|
||||
}
|
||||
},
|
||||
|
||||
notifyError: (reason) => {
|
||||
debug("Failed to open the channel to AID : " +
|
||||
SEUtils.byteArrayToHexString(msg.aid) +
|
||||
", Rejected with Reason : " + reason);
|
||||
callback({ error: SE.ERROR_GENERIC, reason: reason, response: [] });
|
||||
this._acEnforcer.isAccessAllowed(msg.appId, msg.type, msg.aid)
|
||||
.then((allowed) => {
|
||||
if (!allowed) {
|
||||
callback({ error: SE.ERROR_SECURITY });
|
||||
return;
|
||||
}
|
||||
connector.openChannel(SEUtils.byteArrayToHexString(msg.aid), {
|
||||
|
||||
notifyOpenChannelSuccess: (channelNumber, openResponse) => {
|
||||
// Add the new 'channel' to the map upon success
|
||||
let channelToken =
|
||||
gMap.addChannel(msg.appId, msg.type, msg.aid, channelNumber);
|
||||
if (channelToken) {
|
||||
callback({
|
||||
error: SE.ERROR_NONE,
|
||||
channelToken: channelToken,
|
||||
isBasicChannel: (channelNumber === SE.BASIC_CHANNEL),
|
||||
openResponse: SEUtils.hexStringToByteArray(openResponse)
|
||||
});
|
||||
} else {
|
||||
callback({ error: SE.ERROR_GENERIC });
|
||||
}
|
||||
},
|
||||
|
||||
notifyError: (reason) => {
|
||||
debug("Failed to open the channel to AID : " +
|
||||
SEUtils.byteArrayToHexString(msg.aid) +
|
||||
", Rejected with Reason : " + reason);
|
||||
callback({ error: SE.ERROR_GENERIC, reason: reason, response: [] });
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
debug("Failed to get info from accessControlEnforcer " + error);
|
||||
callback({ error: SE.ERROR_SECURITY });
|
||||
});
|
||||
},
|
||||
|
||||
@ -337,6 +354,7 @@ SecureElementManager.prototype = {
|
||||
return;
|
||||
}
|
||||
|
||||
// Bug 1137533 - ACE GPAccessRulesManager APDU filters
|
||||
connector.exchangeAPDU(channel.channelNumber, msg.apdu.cla, msg.apdu.ins,
|
||||
msg.apdu.p1, msg.apdu.p2,
|
||||
SEUtils.byteArrayToHexString(msg.apdu.data),
|
||||
|
Loading…
Reference in New Issue
Block a user