Hi Ray,

The credential instanceof CustomUsernamePasswordCredential returns false. 
But the credential.getClass() returns the same class i.e. 
CustomUsernamePasswordCredential, to which I am trying to typecast.
On Wednesday, September 3, 2025 at 1:31:08 AM UTC+5:45 Ray Bon wrote:

> Prakash,
>
> This sounds more like a java problem.
> You could check with instanceOf before casting.
>
> Ray
> ------------------------------
> *From:* [email protected] <[email protected]> on behalf of Prakash 
> Thapa <[email protected]>
> *Sent:* September 1, 2025 22:14
> *To:* CAS Community <[email protected]>
> *Subject:* [cas-user] Unable to customize UsernamePasswordCredential 
> class in CAS 7.2.4 
>  
> You don't often get email from [email protected]. Learn why this is 
> important <https://aka.ms/LearnAboutSenderIdentification> 
> I am trying to customize the UsernamePasswordCredential class by extending 
> it from the CAS default class. However I am unable to proceed further as I 
> am getting typecast issue in the doAuthentication() of 
> AbstractUsernamePasswordAuthenticationHandler class. I have customized 
> AbstractUsernamePasswordAuthenticationHandler to support the new Custom 
> UsernamePasswordCredential class.
>
>
> *Block of Code: * 
> public abstract class CustomAbstractUsernamePasswordAuthenticationHandler 
> extends 
> AbstractUsernamePasswordAuthenticationHandler {
>
> @Override
> protected final AuthenticationHandlerExecutionResult 
> doAuthentication(Credential 
> credential, final Service service) throws Throwable {
> final CustomUsernamePasswordCredential originalUserPass = 
> (CustomUsernamePasswordCredential) credential;
> ......
> ......
> }
> }
> *Error Message: * 
>    
>    - Cannot cast 
>    
> 'org.apereo.cas.authentication.handler.support.CustomUsernamePasswordCredential'
>  
>    to 
>    
> 'org.apereo.cas.authentication.handler.support.CustomUsernamePasswordCredential'
>
>
> -- 
> - Website: https://apereo.github.io/cas
> - List Guidelines: https://goo.gl/1VRrw7
> - Contributions: https://goo.gl/mh7qDG
> --- 
> You received this message because you are subscribed to the Google Groups 
> "CAS Community" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion visit 
> https://groups.google.com/a/apereo.org/d/msgid/cas-user/70db0edb-2b5e-4f5d-91b4-f603acae3b01n%40apereo.org
>  
> <https://groups.google.com/a/apereo.org/d/msgid/cas-user/70db0edb-2b5e-4f5d-91b4-f603acae3b01n%40apereo.org?utm_medium=email&utm_source=footer>
> .
>

-- 
- Website: https://apereo.github.io/cas
- List Guidelines: https://goo.gl/1VRrw7
- Contributions: https://goo.gl/mh7qDG
--- 
You received this message because you are subscribed to the Google Groups "CAS 
Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/a/apereo.org/d/msgid/cas-user/018f3952-ca34-472c-a719-8e105403258bn%40apereo.org.

Reply via email to