forked from martinpaljak/GlobalPlatformPro
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
martinpaljak#153: Refactor DAP properties assignment to separate clas…
…s. Handle DAP in --install. Extract duplicated CAP loading to separate method. Declare DM token in GlobalPlatform and load it in transitDM. Refactoring.
- Loading branch information
1 parent
d3ba331
commit d480e4e
Showing
5 changed files
with
158 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package pro.javacard.gp; | ||
|
||
import joptsimple.OptionSet; | ||
import pro.javacard.AID; | ||
|
||
import javax.smartcardio.CardException; | ||
|
||
import static pro.javacard.gp.GPCommandLineInterface.OPT_DAP_DOMAIN; | ||
import static pro.javacard.gp.GPCommandLineInterface.OPT_TO; | ||
import static pro.javacard.gp.GPTool.fail; | ||
|
||
public class DAPProperties { | ||
private AID targetDomain = null; | ||
private AID dapDomain = null; | ||
private boolean required = false; | ||
|
||
public DAPProperties(OptionSet args, GlobalPlatform gp) throws CardException, GPException { | ||
// Override target and check for DAP | ||
if (args.has(OPT_TO)) { | ||
targetDomain = AID.fromString(args.valueOf(OPT_TO)); | ||
if (gp.getRegistry().getDomain(targetDomain).getPrivileges().has(GPRegistryEntry.Privilege.DAPVerification)) | ||
required = true; | ||
} | ||
|
||
// Check if DAP block is required | ||
for (GPRegistryEntryApp e : gp.getRegistry().allDomains()) { | ||
if (e.getPrivileges().has(GPRegistryEntry.Privilege.MandatedDAPVerification)) | ||
required = true; | ||
} | ||
|
||
// Check if DAP is overriden | ||
if (args.has(OPT_DAP_DOMAIN)) { | ||
dapDomain = AID.fromString(args.valueOf(OPT_DAP_DOMAIN)); | ||
GPRegistryEntry.Privileges p = gp.getRegistry().getDomain(dapDomain).getPrivileges(); | ||
if (!(p.has(GPRegistryEntry.Privilege.DAPVerification) || p.has(GPRegistryEntry.Privilege.MandatedDAPVerification))) { | ||
fail("Specified DAP domain does not have (Mandated)DAPVerification privilege: " + p.toString()); | ||
} | ||
} | ||
} | ||
|
||
public AID getTargetDomain() { | ||
return targetDomain; | ||
} | ||
|
||
public void setTargetDomain(AID targetDomain) { | ||
this.targetDomain = targetDomain; | ||
} | ||
|
||
public AID getDapDomain() { | ||
return dapDomain; | ||
} | ||
|
||
public void setDapDomain(AID dapDomain) { | ||
this.dapDomain = dapDomain; | ||
} | ||
|
||
public boolean isRequired() { | ||
return required; | ||
} | ||
|
||
public void setRequired(boolean required) { | ||
this.required = required; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.