Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!

Akhil Ranjan

Greenhorn
+ Follow
since Jun 29, 2018
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
2
Received in last 30 days
0
Total given
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Akhil Ranjan

I'm trying to send a GET request with RestTemplate. My code looks like:-



On debugging, my URL looks good. What I have as entity is:-
body = null
headers = <{Accept=[application/json], user-agent=[Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36], _rToken=[2a6ac90f-1dfb-4df3-8d23-6d8d948fb9b5]}>

Since my get method doesn't take a parameter, body is supposed to be null. What am I doing wrong here?
1 year ago

Tim Moores wrote:The code is confusing. Why are you base64-encoding twice? That should not be necessary.

There's also no reason to call getBytes() on a string only to convert the result to a string - it's a string to begin with.



Thank you so much for you help. The problem got resolved
1 year ago

Tim Moores wrote:

Should I do something like String encodedEncryBytes = Base64.getEncoder().encode(encryBytes) instead?


Yes

How do I get the actual encrypted string value


There is no such thing. Encrypted data is not character data, and thus not a string.



Thank you. As you suggested, I tried with the following changes:-

Encryption:-



Decryption:-



Does this look good? Now I get the following exception thrown at this step in the decrypt method:- byte[] decodedDecryptedBytes =  Base64.getDecoder().decode(decryptedBytes);

java.lang.IllegalArgumentException: Illegal base64 character 25
at java.util.Base64$Decoder.decode0(Base64.java:714)
at java.util.Base64$Decoder.decode(Base64.java:526)
at com.hm.um.security.UoloSecurityImpl.decrypt(UoloSecurityImpl.java:104)
at com.hm.um.security.UoloSecurityImpl.main(UoloSecurityImpl.java:30)

1 year ago

Tim Moores wrote:

encryptedStr = new String(encrBytes)


You can't do this - the output of the encryption is not character data, it's binary, and it can't be converted to a String like that. You need to run it through base64 first.



Should I do something like String encodedEncryBytes = Base64.getEncoder().encode(encryBytes) instead? But this string "encodedEncryBytes" will be Base64 encoded, right? How do I get the actual encrypted string value, which I need to concatenate with a separator(: and initVector and then encode?
1 year ago
My original string:- "AkhilRanjanBiharabcdefghijklmnopMovedtoChennai18"
My decrypted string:- "AkhilRanjanBiharÙ †+™¸„À–ýæó@Movedtoñhennai18"

My encryption code:-



My decryption code:-

1 year ago

Rob Spoor wrote:Akhil, some questions - at what point does your string get truncated? Is it somewhere in the middle, or somewhere at the end? Do you correctly URL encode the entire thing?



Hi Rob,  

Apology for replying late. My string was not getting truncated at all. It was getting urldecoded when it reached my endpoint. That's why the data at the end of the string was different. If you pass a data string as @Requestparam, it takes care of urldecoding the data by itself. I didn't have to manually do it.
1 year ago
I'm using Java+Spring framework+Tomcat. I'm sending a request to the server using Postman and I've a huge encrypted string data = "L3dRTmJQcjJrMDUzRi9uQ1FmTTlqN09xcEZqbG1YRmdDazRUd0g2Yy9YRmZ0eDh1SFpYZWpJWmZ1ZTE0WnQ4UkVzbmxlbkhaV1BJZDJDNnJ4TmliZFUvL3VvMTNvc2xKSCsyb1JIRzhoZFdOdjMyelY5c29qU3h4NWxKejdWQk1LMVhjK3VoRUtXcmxWWlcrSVZNRFZlYWhFT0Q5cENyRjdacHVBNnpNSVcwPTo66qPpJx%2Bm4htl6rJeNH%2F4Cw%3D%3D" as my @Requestparam argument. On debugging, I observed that the string on the server side is truncated and loses some character. Is it something to do with tomcat server? I require the entire data string so that I can decrypt it back successfully.
1 year ago
What I want to do is get the timestamp in milliseconds (epoch) for my request when it lands in the interceptor. I have a HttpServletRequest request variable. I thought of invoking request.getDateHeader() but it asks for the name of the header and I'm not sure how to retrieve that from the request.
1 year ago
So I'm trying to launch a jnlp file which is getting blocked by Java security even though I have the website url added in the site-exception list. So I figured that my jar needs to be self signed to work with java web start launcher. Now I tried this command- "jarsigner -keystore mykeys.keystore -tsa http://timestamp.digicert.com http://dev.localwiris.com/Wiris/en/wrs_net_en.jar mywirisapp" and I was prompted for the passphrase for keystore. I want to know how this keystore file works. I have created a blank mykeys.keystore file in C:/Users/akhil_ranjan but I don't understand about how the private keys need to be configured in this file. Also my alias 'mywirisapp' is going to be a private key, right? How do I work with mykeys.keystore? What is the right way to create and configure it?
1 year ago
I'm trying to launch my jnlp file at my development website http://dev.localwiris.com:8097/en/cas.jnlp. I get this Java Application Blocked pop-up with a message saying "For security, applications must now meet the requirements for the High or Very High security settings, or be part of the Exception Site List, to be allowed to run." But I have already added http://dev.localwiris.com:8097/ in my exception site list, and I still get the same Application Blocked pop-up. What else should I try here?
1 year ago
I finally got the problem sorted. Thank you @Tim Moores & @Dev Tolls. Much appreciated
1 year ago

Tim Moores wrote:

Can you help me with that?


Check the link I posted earlier.



Thank you. I looked into it and I think I finally have a hang of the issue. I'm getting the unnecessary jars like older version of xwork-core, ognl and freemarker from struts2-core v2.3.14.3 which is not in my pom. My pom has struts2-core v2.3.32 which is also fetching newer version of those jars, and this is causing the conflict. What I want is to not have those jars from v2.3.14.3. What I tried doing was explicitly have v2.3.14.3 in my pom along with v2.3.32 and use exclusion tags for those dependent jars (xwork-core, ognl etc) of the 2.3.14.3 dependency. I was able to get rid of the jars corresponding to that version (2.3.14.3), but the struts2-core jar of that version takes precedence over the newer version of struts2-core (2.3.32). If only I could have chosen struts2-core v2.3.32 jar over v2.3.14.3. The exclusion tags helped me in getting the correct version of xwork-core, ognl and freemarker (the version that is retrieved from struts2-core v2.3.32).
1 year ago

Dave Tolls wrote:OK.
You shouldn't need to check the other two projects if they are Maven dependencies as their dependencies will appear in the hierarchy of the project you are having an issue with.

How do you build your project?



Thank you. I really appreciate all the help. I finally figured what's happening. Somehow I'm getting those jars from struts2-core version 2.3.14.3. But I've version 2.3.32 in my pom. What I need to do is omit everything I am getting  from v2.3.14.3. Can you help me with that?

I'm building using Jenkins tool/application.
1 year ago

Dave Tolls wrote:Have you checked in the IDE (or the command line, as I think there's a command to get the full dependency list produced)?

For example, if I open a pom file in Eclipse one of the tabs available is the Dependency Hierarchy, which will show me where everything has come from.

If the extra jar files are coming from a Maven build then they will appear here.



I thoroughly checked the Dependency hierarchy for my project and also for the 2 projects that my project depends on, but I'm still stuck
1 year ago
The two projects my project depends on do not have any version of these dependencies in their pom.xml :|
1 year ago