@Test public void testBuildNull() { assertThrows(NullPointerException.class, () -> { instance.build(null); }); }
public SecureKeyBlock build(CharSequence data) throws IllegalArgumentException { Objects.requireNonNull(data, "The key block data cannot be null"); SecureKeyBlock skb = new SecureKeyBlock(); String keyblock = data.toString(); if (keyblock.length() < SIZE_HEADER) throw new IllegalArgumentException("The key block data cannot be shorter than 16"); StringReader sr = new StringReader(data.toString()); skb.keyBlockVersion = readChar(sr); skb.keyBlockLength = Integer.valueOf(readString(sr, SIZE_KEYBLOCK_LENGTH)); String ku = readString(sr, SIZE_KEYUSAGE); skb.keyUsage = ExtKeyUsage.valueOfByCode(ku); skb.algorithm = Algorithm.valueOfByCode(readChar(sr)); skb.modeOfUse = ModeOfUse.valueOfByCode(readChar(sr)); skb.keyVersion = readString(sr, SIZE_KEY_VERSION); skb.exportability = Exportability.valueOfByCode(readChar(sr)); int numOfBlocks = Integer.valueOf(readString(sr, SIZE_NUMOFOPTHDR)); skb.reserved = readString(sr, SIZE_RESERVED); skb.optionalHeaders = parseOptionalHeader(sr, numOfBlocks); int consumed = SIZE_HEADER + calcOptionalHeaderLength(skb.getOptionalHeaders()); if (skb.getKeyBlockLength() <= consumed) return skb; int remain = skb.getKeyBlockLength() - consumed; int macLen = getMACLength(skb); String keyEnc = readString(sr, remain - macLen); if (!keyEnc.isEmpty()) skb.setKeyBytes(ISOUtil.hex2byte(keyEnc)); String mac = readString(sr, macLen); skb.keyBlockMAC = ISOUtil.hex2byte(mac); return skb; }
SecureKeyBlockBuilder { public SecureKeyBlock build(CharSequence data) throws IllegalArgumentException { Objects.requireNonNull(data, "The key block data cannot be null"); SecureKeyBlock skb = new SecureKeyBlock(); String keyblock = data.toString(); if (keyblock.length() < SIZE_HEADER) throw new IllegalArgumentException("The key block data cannot be shorter than 16"); StringReader sr = new StringReader(data.toString()); skb.keyBlockVersion = readChar(sr); skb.keyBlockLength = Integer.valueOf(readString(sr, SIZE_KEYBLOCK_LENGTH)); String ku = readString(sr, SIZE_KEYUSAGE); skb.keyUsage = ExtKeyUsage.valueOfByCode(ku); skb.algorithm = Algorithm.valueOfByCode(readChar(sr)); skb.modeOfUse = ModeOfUse.valueOfByCode(readChar(sr)); skb.keyVersion = readString(sr, SIZE_KEY_VERSION); skb.exportability = Exportability.valueOfByCode(readChar(sr)); int numOfBlocks = Integer.valueOf(readString(sr, SIZE_NUMOFOPTHDR)); skb.reserved = readString(sr, SIZE_RESERVED); skb.optionalHeaders = parseOptionalHeader(sr, numOfBlocks); int consumed = SIZE_HEADER + calcOptionalHeaderLength(skb.getOptionalHeaders()); if (skb.getKeyBlockLength() <= consumed) return skb; int remain = skb.getKeyBlockLength() - consumed; int macLen = getMACLength(skb); String keyEnc = readString(sr, remain - macLen); if (!keyEnc.isEmpty()) skb.setKeyBytes(ISOUtil.hex2byte(keyEnc)); String mac = readString(sr, macLen); skb.keyBlockMAC = ISOUtil.hex2byte(mac); return skb; } }
SecureKeyBlockBuilder { public SecureKeyBlock build(CharSequence data) throws IllegalArgumentException { Objects.requireNonNull(data, "The key block data cannot be null"); SecureKeyBlock skb = new SecureKeyBlock(); String keyblock = data.toString(); if (keyblock.length() < SIZE_HEADER) throw new IllegalArgumentException("The key block data cannot be shorter than 16"); StringReader sr = new StringReader(data.toString()); skb.keyBlockVersion = readChar(sr); skb.keyBlockLength = Integer.valueOf(readString(sr, SIZE_KEYBLOCK_LENGTH)); String ku = readString(sr, SIZE_KEYUSAGE); skb.keyUsage = ExtKeyUsage.valueOfByCode(ku); skb.algorithm = Algorithm.valueOfByCode(readChar(sr)); skb.modeOfUse = ModeOfUse.valueOfByCode(readChar(sr)); skb.keyVersion = readString(sr, SIZE_KEY_VERSION); skb.exportability = Exportability.valueOfByCode(readChar(sr)); int numOfBlocks = Integer.valueOf(readString(sr, SIZE_NUMOFOPTHDR)); skb.reserved = readString(sr, SIZE_RESERVED); skb.optionalHeaders = parseOptionalHeader(sr, numOfBlocks); int consumed = SIZE_HEADER + calcOptionalHeaderLength(skb.getOptionalHeaders()); if (skb.getKeyBlockLength() <= consumed) return skb; int remain = skb.getKeyBlockLength() - consumed; int macLen = getMACLength(skb); String keyEnc = readString(sr, remain - macLen); if (!keyEnc.isEmpty()) skb.setKeyBytes(ISOUtil.hex2byte(keyEnc)); String mac = readString(sr, macLen); skb.keyBlockMAC = ISOUtil.hex2byte(mac); return skb; } private  SecureKeyBlockBuilder(); }
SecureKeyBlockBuilder { public SecureKeyBlock build(CharSequence data) throws IllegalArgumentException { Objects.requireNonNull(data, "The key block data cannot be null"); SecureKeyBlock skb = new SecureKeyBlock(); String keyblock = data.toString(); if (keyblock.length() < SIZE_HEADER) throw new IllegalArgumentException("The key block data cannot be shorter than 16"); StringReader sr = new StringReader(data.toString()); skb.keyBlockVersion = readChar(sr); skb.keyBlockLength = Integer.valueOf(readString(sr, SIZE_KEYBLOCK_LENGTH)); String ku = readString(sr, SIZE_KEYUSAGE); skb.keyUsage = ExtKeyUsage.valueOfByCode(ku); skb.algorithm = Algorithm.valueOfByCode(readChar(sr)); skb.modeOfUse = ModeOfUse.valueOfByCode(readChar(sr)); skb.keyVersion = readString(sr, SIZE_KEY_VERSION); skb.exportability = Exportability.valueOfByCode(readChar(sr)); int numOfBlocks = Integer.valueOf(readString(sr, SIZE_NUMOFOPTHDR)); skb.reserved = readString(sr, SIZE_RESERVED); skb.optionalHeaders = parseOptionalHeader(sr, numOfBlocks); int consumed = SIZE_HEADER + calcOptionalHeaderLength(skb.getOptionalHeaders()); if (skb.getKeyBlockLength() <= consumed) return skb; int remain = skb.getKeyBlockLength() - consumed; int macLen = getMACLength(skb); String keyEnc = readString(sr, remain - macLen); if (!keyEnc.isEmpty()) skb.setKeyBytes(ISOUtil.hex2byte(keyEnc)); String mac = readString(sr, macLen); skb.keyBlockMAC = ISOUtil.hex2byte(mac); return skb; } private  SecureKeyBlockBuilder(); static SecureKeyBlockBuilder newBuilder(); SecureKeyBlockBuilder with4characterMACVersions(String versions); SecureKeyBlock build(CharSequence data); String toKeyBlock(SecureKeyBlock skb); }
SecureKeyBlockBuilder { public SecureKeyBlock build(CharSequence data) throws IllegalArgumentException { Objects.requireNonNull(data, "The key block data cannot be null"); SecureKeyBlock skb = new SecureKeyBlock(); String keyblock = data.toString(); if (keyblock.length() < SIZE_HEADER) throw new IllegalArgumentException("The key block data cannot be shorter than 16"); StringReader sr = new StringReader(data.toString()); skb.keyBlockVersion = readChar(sr); skb.keyBlockLength = Integer.valueOf(readString(sr, SIZE_KEYBLOCK_LENGTH)); String ku = readString(sr, SIZE_KEYUSAGE); skb.keyUsage = ExtKeyUsage.valueOfByCode(ku); skb.algorithm = Algorithm.valueOfByCode(readChar(sr)); skb.modeOfUse = ModeOfUse.valueOfByCode(readChar(sr)); skb.keyVersion = readString(sr, SIZE_KEY_VERSION); skb.exportability = Exportability.valueOfByCode(readChar(sr)); int numOfBlocks = Integer.valueOf(readString(sr, SIZE_NUMOFOPTHDR)); skb.reserved = readString(sr, SIZE_RESERVED); skb.optionalHeaders = parseOptionalHeader(sr, numOfBlocks); int consumed = SIZE_HEADER + calcOptionalHeaderLength(skb.getOptionalHeaders()); if (skb.getKeyBlockLength() <= consumed) return skb; int remain = skb.getKeyBlockLength() - consumed; int macLen = getMACLength(skb); String keyEnc = readString(sr, remain - macLen); if (!keyEnc.isEmpty()) skb.setKeyBytes(ISOUtil.hex2byte(keyEnc)); String mac = readString(sr, macLen); skb.keyBlockMAC = ISOUtil.hex2byte(mac); return skb; } private  SecureKeyBlockBuilder(); static SecureKeyBlockBuilder newBuilder(); SecureKeyBlockBuilder with4characterMACVersions(String versions); SecureKeyBlock build(CharSequence data); String toKeyBlock(SecureKeyBlock skb);  }