@Override public int decode(InputStream is, boolean withTag) throws IOException { int codeLength = 0; if (withTag) { codeLength += tag.decodeAndCheck(is); } codeLength += super.decode(is, false); return codeLength; }
@Override public int encode(OutputStream reverseOS, boolean withTag) throws IOException { int codeLength = super.encode(reverseOS, false); if (withTag) { codeLength += tag.encode(reverseOS); } return codeLength; }
@Test public void explicitDecoding() throws IOException { byte[] byteCode = new byte[] { 0x04, 0x00 }; ByteArrayInputStream berInputStream = new ByteArrayInputStream(byteCode); BerOctetString asn1OctetString = new BerOctetString(); asn1OctetString.decode(berInputStream, true); Assert.assertEquals(0, asn1OctetString.value.length); }
private static Fcp createFcp(short fileId, String fileDescriptor, byte arrReference, Short efFileSize, String pinStatusTemplateDo, Short shortEfId, String linkPath) { return new Fcp(new BerOctetString(DatatypeConverter.parseHexBinary(fileDescriptor)), new BerOctetString(unsignedShortToByteArray(fileId)), null, null, new BerOctetString(new byte[] { arrReference }), efFileSize != null ? new BerOctetString(unsignedShortToByteArray(efFileSize)) : null, pinStatusTemplateDo != null ? new BerOctetString(DatatypeConverter.parseHexBinary(pinStatusTemplateDo)) : null, shortEfId != null ? new BerOctetString(new byte[] { shortEfId.byteValue() }) : null, null, linkPath != null ? new BerOctetString(DatatypeConverter.parseHexBinary(linkPath)) : null); } }
@Test public void explicitEncoding() throws IOException { ReverseByteArrayOutputStream berStream = new ReverseByteArrayOutputStream(50); byte[] byteArray = new byte[] { 0x01, 0x02, 0x03 }; BerOctetString asn1OctetString = new BerOctetString(byteArray); int length = asn1OctetString.encode(berStream, true); Assert.assertEquals(5, length); byte[] expectedBytes = new byte[] { 0x04, 0x03, 0x01, 0x02, 0x03 }; Assert.assertArrayEquals(expectedBytes, berStream.getArray()); }
@Test public void toStringTest() { BerOctetString octetString = new BerOctetString(new byte[] { 1, 2, (byte) 0xa0 }); Assert.assertEquals("0102A0", octetString.toString()); }
public int decode(InputStream is, BerTag berTag) throws IOException { int codeLength = 0; BerTag passedTag = berTag; if (berTag == null) { berTag = new BerTag(); codeLength += berTag.decode(is); } if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 0)) { charstring = new BerOctetString(); codeLength += charstring.decode(is, false); return codeLength; } if (berTag.equals(BerTag.CONTEXT_CLASS, BerTag.PRIMITIVE, 1)) { bitstring = new BerBitString(); codeLength += bitstring.decode(is, false); return codeLength; } if (passedTag != null) { return 0; } throw new IOException("Error decoding CHOICE: Tag " + berTag + " matched to no item."); }
public InitiateResponseBuilder setAuthenticationValue(byte[] serverToClientChallenge) { this.serverToClientChallenge = new AuthenticationValue(); this.serverToClientChallenge.setCharstring(new BerOctetString(serverToClientChallenge)); return this; }
BerOctetString element = new BerOctetString(); subCodeLength += element.decode(is, false); seqOf.add(element); BerOctetString element = new BerOctetString(); subCodeLength += element.decode(is, true); seqOf.add(element);
@Override public int encode(OutputStream reverseOS, boolean withTag) throws IOException { int codeLength = super.encode(reverseOS, false); if (withTag) { codeLength += tag.encode(reverseOS); } return codeLength; }
@Override public int decode(InputStream is, boolean withTag) throws IOException { int codeLength = 0; if (withTag) { codeLength += tag.decodeAndCheck(is); } codeLength += super.decode(is, false); return codeLength; }
@Override Data getMmsDataObj() { Data data = new Data(); data.setOctetString(new BerOctetString(value)); return data; }
BerOctetString element = new BerOctetString(); subCodeLength += element.decode(is, false); seqOf.add(element); BerOctetString element = new BerOctetString(); subCodeLength += element.decode(is, true); seqOf.add(element);
@Override public int encode(OutputStream reverseOS, boolean withTag) throws IOException { int codeLength = super.encode(reverseOS, false); if (withTag) { codeLength += tag.encode(reverseOS); } return codeLength; }
@Override public int decode(InputStream is, boolean withTag) throws IOException { int codeLength = 0; if (withTag) { codeLength += tag.decodeAndCheck(is); } codeLength += super.decode(is, false); return codeLength; }
@Override Data getMmsDataObj() { Data data = new Data(); data.setOctetString(new BerOctetString(value)); return data; }
BerOctetString element = new BerOctetString(); subCodeLength += element.decode(is, false); seqOf.add(element); BerOctetString element = new BerOctetString(); subCodeLength += element.decode(is, true); seqOf.add(element);
@Override public int encode(OutputStream reverseOS, boolean withTag) throws IOException { int codeLength = super.encode(reverseOS, false); if (withTag) { codeLength += tag.encode(reverseOS); } return codeLength; }
@Override public int decode(InputStream is, boolean withTag) throws IOException { int codeLength = 0; if (withTag) { codeLength += tag.decodeAndCheck(is); } codeLength += super.decode(is, false); return codeLength; }
private static void setupAarqAuthentication(AARQApdu aarq, byte[] clientToServerChallenge) { aarq.setSenderAcseRequirements(new ACSERequirements(new byte[] { (byte) 0x80 }, 2)); AuthenticationValue authenticationValue = new AuthenticationValue(); authenticationValue.setCharstring(new BerOctetString(clientToServerChallenge)); aarq.setCallingAuthenticationValue(authenticationValue); }