Created
January 25, 2013 13:03
-
-
Save eliezio/4634277 to your computer and use it in GitHub Desktop.
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
/** | |
* Artifício para evitar que o CLA do comando seja adulterado pela ChannelImpl.setChannel(). | |
* Thanks Bruno Jesus! | |
* <p/> | |
* Vide: http://www.java2s.com/Open-Source/Java/6.0-JDK-Modules-sun/security/sun/security/smartcardio/ChannelImpl.java.htm | |
* | |
* @param channel Canal | |
* @param cla CLA do comando | |
*/ | |
private static void preventCLACorruption(CardChannel channel, int cla) { | |
final int newChannelNumber = (((cla >= 0) && (cla <= 3)) ? cla : 0); | |
if (channel.getChannelNumber() != newChannelNumber) { | |
try { | |
Field f = channel.getClass().getDeclaredField("channel"); | |
f.setAccessible(true); | |
f.set(channel, newChannelNumber); | |
} catch (Exception e) { | |
throw new RuntimeException(e); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment