Guest User

Untitled

a guest
Jun 22nd, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. @Override
  2. public Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> getTextures(final GameProfile profile, final boolean requireSecure) {
  3. final Property textureProperty = Iterables.getFirst(profile.getProperties().get("textures"), null);
  4.  
  5. if (textureProperty == null) {
  6. return new HashMap<MinecraftProfileTexture.Type, MinecraftProfileTexture>();
  7. }
  8.  
  9. final MinecraftTexturesPayload result;
  10. try {
  11. final String json = new String(Base64.decodeBase64(textureProperty.getValue()), Charsets.UTF_8);
  12. result = gson.fromJson(json, MinecraftTexturesPayload.class);
  13. } catch (final JsonParseException e) {
  14. LOGGER.error("Could not decode textures payload", e);
  15. return new HashMap<MinecraftProfileTexture.Type, MinecraftProfileTexture>();
  16. }
  17.  
  18. if (result == null || result.getTextures() == null) {
  19. return new HashMap<MinecraftProfileTexture.Type, MinecraftProfileTexture>();
  20. }
  21.  
  22. for (final Map.Entry<MinecraftProfileTexture.Type, MinecraftProfileTexture> entry : result.getTextures().entrySet()) {
  23. if (!isWhitelistedDomain(entry.getValue().getUrl())) {
  24. LOGGER.error("Textures payload has been tampered with (non-whitelisted domain)");
  25. return new HashMap<MinecraftProfileTexture.Type, MinecraftProfileTexture>();
  26. }
  27. }
  28.  
  29. return result.getTextures();
  30. }
Add Comment
Please, Sign In to add comment