/** * Write contents of this instance as CredentialsProto message to DataOutput. * @param out * @throws IOException */ void writeProto(DataOutput out) throws IOException { CredentialsProto.Builder storage = CredentialsProto.newBuilder(); for (Map.Entry<Text, Token<? extends TokenIdentifier>> e : tokenMap.entrySet()) { CredentialsKVProto.Builder kv = CredentialsKVProto.newBuilder(). setAliasBytes(ByteString.copyFrom( e.getKey().getBytes(), 0, e.getKey().getLength())). setToken(e.getValue().toTokenProto()); storage.addTokens(kv.build()); } for(Map.Entry<Text, byte[]> e : secretKeysMap.entrySet()) { CredentialsKVProto.Builder kv = CredentialsKVProto.newBuilder(). setAliasBytes(ByteString.copyFrom( e.getKey().getBytes(), 0, e.getKey().getLength())). setSecret(ByteString.copyFrom(e.getValue())); storage.addSecrets(kv.build()); } storage.build().writeDelimitedTo((DataOutputStream)out); }
public Builder mergeFrom(org.apache.hadoop.security.proto.SecurityProtos.CredentialsKVProto other) { if (other == org.apache.hadoop.security.proto.SecurityProtos.CredentialsKVProto.getDefaultInstance()) return this; if (other.hasAlias()) { bitField0_ |= 0x00000001; alias_ = other.alias_; onChanged(); } if (other.hasToken()) { mergeToken(other.getToken()); } if (other.hasSecret()) { setSecret(other.getSecret()); } this.mergeUnknownFields(other.getUnknownFields()); return this; }