The class package matches for both custom and default and for the customized bean too. There is only one CustomUsernamePasswordCredential class. I am running CAS in intellij via bootRun(clean build bootRun --stacktrace).
For now I have decided alternative approach of not customizing UsernamePasswordCredential and adding a POJO in the flowscope for custom attributes. On Thursday, September 4, 2025 at 1:10:10 AM UTC+5:45 Ray Bon wrote: > Prakash, > > Do the full path hierarchies match? > That is, is it possible there is another CustomUsernamePasswordCredential > class? > > This strange casting problem can occur with multiple class loaders (cast > acting in only one loader). How are you running cas? > > Ray > ------------------------------ > *From:* Prakash Thapa <[email protected]> > *Sent:* September 2, 2025 21:01 > *To:* CAS Community <[email protected]> > *Cc:* Ray Bon <[email protected]> > *Subject:* Re: [cas-user] Unable to customize UsernamePasswordCredential > class in CAS 7.2.4 > > 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/11e1cd52-f7a3-421e-be77-dd24284e6c0cn%40apereo.org.
