Comments (5)
I need clarification on what you are asking.
https://stackoverflow.com/help/how-to-ask
What line throws an exception?
from jpaseto.
java.lang.ClassCastException: java.lang.String cannot be cast to dev.paseto.jpaseto.Paseto
I tried using instanceof keyword in java it did not work:
public Integer pasetoclaims(Object clientToken, String param) { Integer result = null; Paseto token = null; try { if(clientToken instanceof Paseto) token = (Paseto) clientToken; if (param.contains("name")) result = token.getClaims().get("name", Integer.class); else result = token.getClaims().get(param, Integer.class); } catch (Exception e) { e.printStackTrace(); } return result; }I also tried using getclass but it did not work,
public Integer pasetoclaims(Object clientToken, String param) { Integer result = null; Paseto token = null; try { if(clientToken.getClass().equals(Paseto.class)) //This is where i have used getclass token = (Paseto) clientToken; if (param.contains("name")) result = token.getClaims().get("name", Integer.class); else result = token.getClaims().get(param, Integer.class); } catch (Exception e) { e.printStackTrace(); } return result; }Can anyone suggest how to cast it in a proper way . Thanks in advance.
In this method i have getting paseto token in clientToken as a String datatype and i am casting the clientToken to Paseto for getting the Paseto Token claims. when checking in if condition with instanceof that is skipped.without if condition classcastexception in 6 line
token = (Paseto) clientToken
from jpaseto.
Sorry @anand-mm, I think I'm missing something.
Are you trying to cast a String
to a Paseto
object directly?
If so please look at: https://github.com/paseto-toolkit/jpaseto#paseto-read
Otherwise, can you create an example project on GitHub that demos the problem and link it here?
from jpaseto.
Yes I am trying to cast String to Paseto Object directly. It is Possible or not??
from jpaseto.
No, that is not possible Java.
Take a look at this section of the docs to learn how to parse a [String] PASETO token: https://github.com/paseto-toolkit/jpaseto#paseto-read
from jpaseto.
Related Issues (9)
- Can't run jpaseto artifact in ubuntu server HOT 3
- Generante token HOT 7
- java.lang.SecurityException: JVM does not provide a strong secure random number generator HOT 2
- Can't use KeyResolver with DefaultPasetoParserBuilder HOT 5
- PASETO Versions 3 and 4
- Support PASERK: Platform-Agnostic Serialized Keys HOT 3
- Use Official Paseto Test Vectors HOT 1
- Long Time Taken for Token Creation HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jpaseto.