void store(KeytabOutputStream kos) throws IOException { byte[] body = null; // compute entry body content first so that to get and write the size ByteArrayOutputStream baos = new ByteArrayOutputStream(); KeytabOutputStream subKos = new KeytabOutputStream(baos); writeBody(subKos, 0); // todo: consider the version subKos.flush(); body = baos.toByteArray(); kos.writeInt(body.length); kos.write(body); }
void writeBody(KeytabOutputStream kos, int version) throws IOException { kos.writePrincipal(principal, version); kos.writeTime(timestamp); kos.writeByte(kvno); kos.writeKey(key, version); }
@Override public void writeCountedOctets(byte[] data) throws IOException { writeShort(data.length); write(data); } }
public void writePrincipal(PrincipalName principal, int version) throws IOException { List<String> nameStrings = principal.getNameStrings(); int numComponents = principal.getNameStrings().size(); String realm = principal.getRealm(); writeShort(numComponents); writeCountedString(realm); for (String nameCom : nameStrings) { writeCountedString(nameCom); } writeInt(principal.getNameType().getValue()); // todo: consider the version }
@Override public void writeKey(EncryptionKey key, int version) throws IOException { writeShort(key.getKeyType().getValue()); writeCountedOctets(key.getKeyData()); }
private void writeVersion(KeytabOutputStream kos) throws IOException { byte[] bytes = new byte[2]; bytes[0] = (byte) 0x05; bytes[1] = version == V502 ? (byte) 0x02 : (byte) 0x01; kos.write(bytes); }
@Override public void store(OutputStream outputStream) throws IOException { if (outputStream == null) { throw new IllegalArgumentException("Invalid and null output stream"); } KeytabOutputStream kos = new KeytabOutputStream(outputStream); writeVersion(kos); writeEntries(kos); }
public void writePrincipal(PrincipalName principal, int version) throws IOException { List<String> nameStrings = principal.getNameStrings(); int numComponents = principal.getNameStrings().size(); String realm = principal.getRealm(); writeShort(numComponents); writeCountedString(realm); for (String nameCom : nameStrings) { writeCountedString(nameCom); } writeInt(principal.getNameType().getValue()); // todo: consider the version }
@Override public void writeKey(EncryptionKey key, int version) throws IOException { writeShort(key.getKeyType().getValue()); writeCountedOctets(key.getKeyData()); }
private void writeVersion(KeytabOutputStream kos) throws IOException { byte[] bytes = new byte[2]; bytes[0] = (byte) 0x05; bytes[1] = version == V502 ? (byte) 0x02 : (byte) 0x01; kos.write(bytes); }
@Override public void store(OutputStream outputStream) throws IOException { if (outputStream == null) { throw new IllegalArgumentException("Invalid and null output stream"); } KeytabOutputStream kos = new KeytabOutputStream(outputStream); writeVersion(kos); writeEntries(kos); }
void store(KeytabOutputStream kos) throws IOException { byte[] body = null; // compute entry body content first so that to get and write the size ByteArrayOutputStream baos = new ByteArrayOutputStream(); KeytabOutputStream subKos = new KeytabOutputStream(baos); writeBody(subKos, 0); // todo: consider the version subKos.flush(); body = baos.toByteArray(); kos.writeInt(body.length); kos.write(body); }
void writeBody(KeytabOutputStream kos, int version) throws IOException { kos.writePrincipal(principal, version); kos.writeTime(timestamp); kos.writeByte(kvno); kos.writeKey(key, version); }
@Override public void writeCountedOctets(byte[] data) throws IOException { writeShort(data.length); write(data); } }