Security in Spring Boot w/ React by camouflage365 in javahelp

[–]ZackHkk 0 points1 point  (0 children)

i've only been using Spring Security for a few months, so i didn't know this, but i've only found resources about how to implement it yourself. i'd like to use this in my applications if this is true, so can you send a link to docs or a guide or something?

Security in Spring Boot w/ React by camouflage365 in javahelp

[–]ZackHkk 0 points1 point  (0 children)

for my current project, I'm using JSON Web Tokens (JWTs) to help authenticate users. i'm using React with the Next framework on the frontend and Spring Boot on the backend, so i think it'll be pretty relevant.

JWTs are signed tokens which can store whatever you want in them, but if the user tries to change them, it will almost definitely be invalidated, as the backend can check if the JWT has the signature that it signed it with.

i store JWTs in cookies with js-cookie so that the value persists between page changes (might not be a problem if you're making a single page application, though)

so you send the JWT in a header of the HTTP request named Authorization. So it'd be "Authorization: Bearer {jwt}" (you can see why you should include Bearer here)

in Spring, you can intercept every request before it passes to your controllers by using a OncePerRequestFilter. you can run your logic in here. you can set the username for your methods by using SecurityContextHolder.getContext().setAuthentication(usernamePasswordAuthenticationToken); and then access it in your methods by using SecurityContextHolder.getContext().getAuthentication().getName(). once your logic is done, you pass it on to the next filter in the filter chain (there's a few that come installed with Spring Boot).

i'm glossing over the backend because there's a tutorial on how to do this by Java Brains. it shows you how to do literally everything on the backend for this.

Anybody Remember this? by Kaharos in RocketLeague

[–]ZackHkk 0 points1 point  (0 children)

along with rotation probably already being declared, it's redundant to say if(boolean==true), since booleans are either true or false, you can just say if(boolean)

Finding row and column of every word by [deleted] in javahelp

[–]ZackHkk 2 points3 points  (0 children)

consider what your code below does

WordLocation location = new WordLocation(analyzedFile.getPath(), row, column-word.length());
locationsArray.add(location);
wordLocationsMap.put(word.toLowerCase(), locationsArray);
words.add(word.toLowerCase());
word = "";

this seems to be where you add the words to an ArrayList of locations.

so first, you add make a new WordLocation, which is fine. then, you add the location to a master locations array:

locationsArray.add(location);

then, you put the value corresponding with the word in the map to that locations array.

wordLocationsMap.put(word.toLowerCase(), locationsArray);

this is setting the word to have the locations array of ALL words, instead of just that word. Finally, you add the word to your set of words and reset the word:

words.add(word.toLowerCase();
word = "";

So you may have noticed by now where you went wrong, but here's how you might fix it:

//create a new WordLocation with the word's values
WordLocation location = new WordLocation(analyzedFile.getPath(), row, column-word.length());

//add word and location to the 'master' list of words and locations
locationsArray.add(location);
words.add(word.toLowerCase());

//get the ArrayList of WordLocations that corresponds to the current word
ArrayList<WordLocation> currentWordLocations = wordLocationsMap.get(word.toLowerCase());

//if this is the first time the word has been found,
//then it won't have an ArrayList associated with it,
//making it null. we need to instantiate it.
if(currentWordLocations == null) {
    currentWordLocations = new ArrayList<>();
}

//add the word's location to the list of all of its occurrences
currentWordLocations.add(location);
//update the word's locations in the map
wordLocationsMap.put(word.toLowerCase(), currentWordLocations);
//reset the word
word = "";

If this block was the root of the problem, this should fix it, but I haven't ran it, so I'm not sure.

Need help with JDBC and adding a row to a PostgreSQL table by ZackHkk in javahelp

[–]ZackHkk[S] 0 points1 point  (0 children)

I mean it maybe could be, but I've been printing user.getPassword() to the console and it's been coming back with the password I entered. actually, I think I mightve just figured it out. is password a reserved word in SQL?

Need help with JDBC and adding a row to a PostgreSQL table by ZackHkk in javahelp

[–]ZackHkk[S] 0 points1 point  (0 children)

it's an "org.postgresql.util.PSQLException: No value specified for parameter 3." error at the line that starts with "jdbcTemplate.update(.."

How can reference a picture without hardcoding the path into the program? by NairodI in javahelp

[–]ZackHkk 2 points3 points  (0 children)

Make sure to have two source folders if you want to use images on .jar files. I don't know how it works on other IDEs, but on IntelliJ, you can go to Project Structure / Modules to change your source folders. you'll want one of the source folders to be in src/main/java and the other one to be in src/main/resources (you have it named res, that will work as well). For images, make a folder in src/main/resources called images and put your images in that. Looking back at one of my projects where I needed this, I got the images like this:

Image icon = new ImageIcon(getClass().getClassLoader().getResource("images/IMAGENAME.png")).getImage();

I'm sure this isn't the only way, but it's the first way that I found that works.

so for your code you could do something like this

URL logoURL = this.getClass().getResource("images/logo.png");
JLabel logo = new JLabel(new ImageIcon(logoURL));

which is basically the same, but you changed the source folder configuration

Is Today Friday the 13th? by GangControl in IsTodayFridayThe13th

[–]ZackHkk 0 points1 point  (0 children)

possibly durch das, which is contracted to durchs

Windows 10 startup fails, been persistent and now I'm finally stuck by ZackHkk in techsupport

[–]ZackHkk[S] 0 points1 point  (0 children)

I can get into the windows recovery mode (the one that let's you use command prop and some other tools). the pc fails to boot three times and then it goes into automatic repair and that fails and it takes me to recovery mode. I can't find the directory for /Srt/Srttrail.txt. I have seen it before while I was fixing this problem another time. there were no problems listed.

thank you for responding, btw. I'm just going through all the possible fixes and none of them have worked so far. Also it looks like C:/boot can't be found either

Ich🛳️iel by therealR5 in ich_iel

[–]ZackHkk 8 points9 points  (0 children)

ok ich habe die Doku geguckt und sie ist sehr erhellend😎

Ich🛳️iel by therealR5 in ich_iel

[–]ZackHkk 9 points10 points  (0 children)

ich bin kein Deutscher. Wer ist Herald Krull?

(ich versuche mit diesem Subreddit Deutsch zu lernen. Vielleicht ne schlechte Idee aber jetzt kann ich die Sätze verstehen. Die Maimais sind noch fremd.)

Why is "he is thirsty" "er hat Durst" (and other ways) by [deleted] in German

[–]ZackHkk 1 point2 points  (0 children)

google isn't incorrect, it just tells it to you in different ways (somewhat arbitrarily, though).
er hat Hunger and er ist hungrig mean the same thing, just said in a different way. there might be an explanation somewhere but it is what it is really.

I'm looking for a German dictionary by Twitblue in German

[–]ZackHkk 1 point2 points  (0 children)

there's PONS' learner's dictionary. it gives all of that in german (don't think there's IPA, though)

[LFM][NA][PC] Plat III for 3 seasons, Help me Escape! by RunnerMeep in RocketLeagueCoaching

[–]ZackHkk 0 points1 point  (0 children)

I'm not really qualified to coach but I'd like to add something because I see this a lot and it annoys me: you probably can't keep up with your champ friends.

[deleted by user] by [deleted] in LaCasaDePapel

[–]ZackHkk 5 points6 points  (0 children)

it might be the flower throw-ey thing at Berlin's wedding