51 lines
1.9 KiB
Java
51 lines
1.9 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*
|
|
* Could not load the following classes:
|
|
* com.mojang.authlib.GameProfile
|
|
*/
|
|
package net.minecraft.network.chat;
|
|
|
|
import com.mojang.authlib.GameProfile;
|
|
import java.time.Duration;
|
|
import java.util.UUID;
|
|
import net.minecraft.network.FriendlyByteBuf;
|
|
import net.minecraft.network.chat.SignedMessageChain;
|
|
import net.minecraft.network.chat.SignedMessageValidator;
|
|
import net.minecraft.util.SignatureValidator;
|
|
import net.minecraft.world.entity.player.ProfilePublicKey;
|
|
|
|
public record RemoteChatSession(UUID sessionId, ProfilePublicKey profilePublicKey) {
|
|
public SignedMessageValidator createMessageValidator(Duration gracePeriod) {
|
|
return new SignedMessageValidator.KeyBased(this.profilePublicKey.createSignatureValidator(), () -> this.profilePublicKey.data().hasExpired(gracePeriod));
|
|
}
|
|
|
|
public SignedMessageChain.Decoder createMessageDecoder(UUID profileId) {
|
|
return new SignedMessageChain(profileId, this.sessionId).decoder(this.profilePublicKey);
|
|
}
|
|
|
|
public Data asData() {
|
|
return new Data(this.sessionId, this.profilePublicKey.data());
|
|
}
|
|
|
|
public boolean hasExpired() {
|
|
return this.profilePublicKey.data().hasExpired();
|
|
}
|
|
|
|
public record Data(UUID sessionId, ProfilePublicKey.Data profilePublicKey) {
|
|
public static Data read(FriendlyByteBuf input) {
|
|
return new Data(input.readUUID(), new ProfilePublicKey.Data(input));
|
|
}
|
|
|
|
public static void write(FriendlyByteBuf output, Data data) {
|
|
output.writeUUID(data.sessionId);
|
|
data.profilePublicKey.write(output);
|
|
}
|
|
|
|
public RemoteChatSession validate(GameProfile profile, SignatureValidator serviceSignatureValidator) throws ProfilePublicKey.ValidationException {
|
|
return new RemoteChatSession(this.sessionId, ProfilePublicKey.createValidated(serviceSignatureValidator, profile.id(), this.profilePublicKey));
|
|
}
|
|
}
|
|
}
|
|
|