Jump to content

What am i doing wrong when obfuscating this SpringBoot (java) project?

Carlosp17

The code works just fine if i compile & execute it it without obfuscating.

But i came with this problem when trying to obfuscate my code when i implemented JWT on it, where when i test the same login endpoint, the response is

{
"timestamp": "2021-12-29T17:04:41.181+00:00",
"status": 406,
"error": "Not Acceptable",
"path": "/user"
}

As far as i've seen, i can't return an object i declare e.g. User, because if i return a String alone, it has no problem, i don't know what could i be missing, my project is here:

demo.zip

Thanks in advance for your comments! 馃檪

Link to comment
Share on other sites

Link to post
Share on other sites

When obfuscating, you typically need to exclude your POJOs because the names of fields etc. get changed which then no longer match your JSON. Make sure anything API related that must have a certain name (fields, paths, etc.) are excluded from renaming. Same goes for fields that are e.g. mapped into the database. While we're not obfuscating our Spring backend, I've run into such issues when I first enabled obfuscation for our Android client.

Remember to either quote or @mention others, so they are notified of your reply

Link to comment
Share on other sites

Link to post
Share on other sites

12 minutes ago, Eigenvektor said:

When obfuscating, you typically need to exclude your POJOs because the names of fields etc. get changed which then no longer match your JSON. Make sure anything API related that must have a certain name (fields, paths, etc.) are excluded from renaming. Same goes for fields that are e.g. mapped into the database. While we're not obfuscating our Spring backend, I've run into such issues when I first enabled obfuscation for our Android client.

So, if i understand correctly, in this case i need to keep User class of my model from renaming, so that when i use the endpoint it can create the User Object withtout problem and retrieve the same object as the specified User?

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, Carlosp17 said:

So, if i understand correctly, in this case i need to keep User class of my model from renaming, so that when i use the endpoint it can create the User Object withtout problem and retrieve the same object as the specified User?

It's usually not the name of the class itself, but its fields. It doesn't necessarily matter whether you return "new User()" or "new A()", but it does matter whether the object contains the fields "a, b" or "username, password".

Remember to either quote or @mention others, so they are notified of your reply

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now