@Test public void testDumpWithNameAndOptHeader() { String indent = "____"; instance.setScheme(KeyScheme.S); instance.keyBlockVersion = 'D'; instance.keyUsage = KeyUsage.CVK; instance.algorithm = Algorithm.AES; instance.modeOfUse = ModeOfUse.ENCDEC; instance.keyVersion = "c2"; instance.exportability = Exportability.ANY; instance.reserved = "19"; instance.setKeyBytes(KEYBLOCK_ENCKEY); instance.keyBlockMAC = KEYBLOCK_MAC8; instance.setKeyCheckValue(KEYBLOCK_KCV); instance.setKeyName("Test key block key"); LinkedHashMap<String, String> optHdr = new LinkedHashMap<>(); instance.optionalHeaders = optHdr; optHdr.put("KS", "Test KS.12"); optHdr.put("KV", "abcd"); instance.dump(ps, indent); StringBuilder sb = new StringBuilder(128); sb.append(indent).append("<secure-key-block scheme=\"S\" name=\"Test key block key\">").append(NL); sb.append(indent).append(" <header>").append(NL); sb.append(indent).append(" <version>D</version>").append(NL); sb.append(indent).append(" <key-usage>C0</key-usage>").append(NL); sb.append(indent).append(" <algorithm>A</algorithm>").append(NL); sb.append(indent).append(" <mode-of-use>B</mode-of-use>").append(NL); sb.append(indent).append(" <key-version>c2</key-version>").append(NL); sb.append(indent).append(" <exportability>E</exportability>").append(NL); sb.append(indent).append(" <reserved>19</reserved>").append(NL); sb.append(indent).append(" </header>").append(NL); sb.append(indent).append(" <optional-header>").append(NL); sb.append(indent).append(" <entry id=\"KS\" value=\"Test KS.12\"/>").append(NL); sb.append(indent).append(" <entry id=\"KV\" value=\"abcd\"/>").append(NL); sb.append(indent).append(" </optional-header>").append(NL); sb.append(indent).append(" <data>").append(ISOUtil.hexString(KEYBLOCK_ENCKEY)).append("</data>").append(NL); sb.append(indent).append(" <mac>").append(ISOUtil.hexString(KEYBLOCK_MAC8)).append("</mac>").append(NL); sb.append(indent).append(" <check-value>").append(ISOUtil.hexString(KEYBLOCK_KCV)).append("</check-value>").append(NL); sb.append(indent).append("</secure-key-block>").append(NL); assertEquals(sb.toString(), os.toString()); }
@Override public void dump(PrintStream p, String indent) { String inner = indent + " "; String inner2 = inner + " "; p.print(indent + "<secure-key-block"); p.print(" scheme=\"" + scheme + "\""); if (keyName != null) p.print(" name=\"" + keyName + "\""); p.println(">"); p.println(inner + "<header>"); p.println(inner2 + "<version>" + keyBlockVersion + "</version>"); p.println(inner2 + "<key-usage>" + keyUsage.getCode() + "</key-usage>"); p.println(inner2 + "<algorithm>" + algorithm.getCode() + "</algorithm>"); p.println(inner2 + "<mode-of-use>" + modeOfUse.getCode() + "</mode-of-use>"); p.println(inner2 + "<key-version>" + keyVersion + "</key-version>"); p.println(inner2 + "<exportability>" + exportability.getCode() + "</exportability>"); if (reserved != null && !"00".equals(reserved)) p.println(inner2 + "<reserved>" + reserved + "</reserved>"); p.println(inner + "</header>"); if (!optionalHeaders.isEmpty()) { p.println(inner + "<optional-header>"); for (Entry<String, String> ent : optionalHeaders.entrySet()) p.println(inner2 + "<entry id=\""+ ent.getKey() + "\" value=\""+ ent.getValue()+ "\"/>"); p.println(inner + "</optional-header>"); } p.println(inner + "<data>" + ISOUtil.hexString(getKeyBytes()) + "</data>"); p.println(inner + "<mac>" + ISOUtil.hexString(getKeyBlockMAC()) + "</mac>"); p.println(inner + "<check-value>" + ISOUtil.hexString(getKeyCheckValue()) + "</check-value>"); p.println(indent + "</secure-key-block>"); }
SecureKeyBlock extends SecureKey { @Override public void dump(PrintStream p, String indent) { String inner = indent + " "; String inner2 = inner + " "; p.print(indent + "<secure-key-block"); p.print(" scheme=\"" + scheme + "\""); if (keyName != null) p.print(" name=\"" + keyName + "\""); p.println(">"); p.println(inner + "<header>"); p.println(inner2 + "<version>" + keyBlockVersion + "</version>"); p.println(inner2 + "<key-usage>" + keyUsage.getCode() + "</key-usage>"); p.println(inner2 + "<algorithm>" + algorithm.getCode() + "</algorithm>"); p.println(inner2 + "<mode-of-use>" + modeOfUse.getCode() + "</mode-of-use>"); p.println(inner2 + "<key-version>" + keyVersion + "</key-version>"); p.println(inner2 + "<exportability>" + exportability.getCode() + "</exportability>"); if (reserved != null && !"00".equals(reserved)) p.println(inner2 + "<reserved>" + reserved + "</reserved>"); p.println(inner + "</header>"); if (!optionalHeaders.isEmpty()) { p.println(inner + "<optional-header>"); for (Entry<String, String> ent : optionalHeaders.entrySet()) p.println(inner2 + "<entry id=\""+ ent.getKey() + "\" value=\""+ ent.getValue()+ "\"/>"); p.println(inner + "</optional-header>"); } p.println(inner + "<data>" + ISOUtil.hexString(getKeyBytes()) + "</data>"); p.println(inner + "<mac>" + ISOUtil.hexString(getKeyBlockMAC()) + "</mac>"); p.println(inner + "<check-value>" + ISOUtil.hexString(getKeyCheckValue()) + "</check-value>"); p.println(indent + "</secure-key-block>"); } }
SecureKeyBlock extends SecureKey { @Override public void dump(PrintStream p, String indent) { String inner = indent + " "; String inner2 = inner + " "; p.print(indent + "<secure-key-block"); p.print(" scheme=\"" + scheme + "\""); if (keyName != null) p.print(" name=\"" + keyName + "\""); p.println(">"); p.println(inner + "<header>"); p.println(inner2 + "<version>" + keyBlockVersion + "</version>"); p.println(inner2 + "<key-usage>" + keyUsage.getCode() + "</key-usage>"); p.println(inner2 + "<algorithm>" + algorithm.getCode() + "</algorithm>"); p.println(inner2 + "<mode-of-use>" + modeOfUse.getCode() + "</mode-of-use>"); p.println(inner2 + "<key-version>" + keyVersion + "</key-version>"); p.println(inner2 + "<exportability>" + exportability.getCode() + "</exportability>"); if (reserved != null && !"00".equals(reserved)) p.println(inner2 + "<reserved>" + reserved + "</reserved>"); p.println(inner + "</header>"); if (!optionalHeaders.isEmpty()) { p.println(inner + "<optional-header>"); for (Entry<String, String> ent : optionalHeaders.entrySet()) p.println(inner2 + "<entry id=\""+ ent.getKey() + "\" value=\""+ ent.getValue()+ "\"/>"); p.println(inner + "</optional-header>"); } p.println(inner + "<data>" + ISOUtil.hexString(getKeyBytes()) + "</data>"); p.println(inner + "<mac>" + ISOUtil.hexString(getKeyBlockMAC()) + "</mac>"); p.println(inner + "<check-value>" + ISOUtil.hexString(getKeyCheckValue()) + "</check-value>"); p.println(indent + "</secure-key-block>"); } protected  SecureKeyBlock(); }
SecureKeyBlock extends SecureKey { @Override public void dump(PrintStream p, String indent) { String inner = indent + " "; String inner2 = inner + " "; p.print(indent + "<secure-key-block"); p.print(" scheme=\"" + scheme + "\""); if (keyName != null) p.print(" name=\"" + keyName + "\""); p.println(">"); p.println(inner + "<header>"); p.println(inner2 + "<version>" + keyBlockVersion + "</version>"); p.println(inner2 + "<key-usage>" + keyUsage.getCode() + "</key-usage>"); p.println(inner2 + "<algorithm>" + algorithm.getCode() + "</algorithm>"); p.println(inner2 + "<mode-of-use>" + modeOfUse.getCode() + "</mode-of-use>"); p.println(inner2 + "<key-version>" + keyVersion + "</key-version>"); p.println(inner2 + "<exportability>" + exportability.getCode() + "</exportability>"); if (reserved != null && !"00".equals(reserved)) p.println(inner2 + "<reserved>" + reserved + "</reserved>"); p.println(inner + "</header>"); if (!optionalHeaders.isEmpty()) { p.println(inner + "<optional-header>"); for (Entry<String, String> ent : optionalHeaders.entrySet()) p.println(inner2 + "<entry id=\""+ ent.getKey() + "\" value=\""+ ent.getValue()+ "\"/>"); p.println(inner + "</optional-header>"); } p.println(inner + "<data>" + ISOUtil.hexString(getKeyBytes()) + "</data>"); p.println(inner + "<mac>" + ISOUtil.hexString(getKeyBlockMAC()) + "</mac>"); p.println(inner + "<check-value>" + ISOUtil.hexString(getKeyCheckValue()) + "</check-value>"); p.println(indent + "</secure-key-block>"); } protected  SecureKeyBlock(); @Override void setKeyType(String keyType); @Override String getKeyType(); @Override void setKeyLength(short keyLength); @Override short getKeyLength(); @Override KeyScheme getScheme(); char getKeyBlockVersion(); int getKeyBlockLength(); KeyUsage getKeyUsage(); Algorithm getAlgorithm(); ModeOfUse getModeOfUse(); String getKeyVersion(); Exportability getExportability(); String getReserved(); Map<String, String> getOptionalHeaders(); byte[] getKeyBlockMAC(); @Override void dump(PrintStream p, String indent); }
SecureKeyBlock extends SecureKey { @Override public void dump(PrintStream p, String indent) { String inner = indent + " "; String inner2 = inner + " "; p.print(indent + "<secure-key-block"); p.print(" scheme=\"" + scheme + "\""); if (keyName != null) p.print(" name=\"" + keyName + "\""); p.println(">"); p.println(inner + "<header>"); p.println(inner2 + "<version>" + keyBlockVersion + "</version>"); p.println(inner2 + "<key-usage>" + keyUsage.getCode() + "</key-usage>"); p.println(inner2 + "<algorithm>" + algorithm.getCode() + "</algorithm>"); p.println(inner2 + "<mode-of-use>" + modeOfUse.getCode() + "</mode-of-use>"); p.println(inner2 + "<key-version>" + keyVersion + "</key-version>"); p.println(inner2 + "<exportability>" + exportability.getCode() + "</exportability>"); if (reserved != null && !"00".equals(reserved)) p.println(inner2 + "<reserved>" + reserved + "</reserved>"); p.println(inner + "</header>"); if (!optionalHeaders.isEmpty()) { p.println(inner + "<optional-header>"); for (Entry<String, String> ent : optionalHeaders.entrySet()) p.println(inner2 + "<entry id=\""+ ent.getKey() + "\" value=\""+ ent.getValue()+ "\"/>"); p.println(inner + "</optional-header>"); } p.println(inner + "<data>" + ISOUtil.hexString(getKeyBytes()) + "</data>"); p.println(inner + "<mac>" + ISOUtil.hexString(getKeyBlockMAC()) + "</mac>"); p.println(inner + "<check-value>" + ISOUtil.hexString(getKeyCheckValue()) + "</check-value>"); p.println(indent + "</secure-key-block>"); } protected  SecureKeyBlock(); @Override void setKeyType(String keyType); @Override String getKeyType(); @Override void setKeyLength(short keyLength); @Override short getKeyLength(); @Override KeyScheme getScheme(); char getKeyBlockVersion(); int getKeyBlockLength(); KeyUsage getKeyUsage(); Algorithm getAlgorithm(); ModeOfUse getModeOfUse(); String getKeyVersion(); Exportability getExportability(); String getReserved(); Map<String, String> getOptionalHeaders(); byte[] getKeyBlockMAC(); @Override void dump(PrintStream p, String indent);  }