Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Password change issue in AEM

Avatar

Avatar
Validate 10
Level 2
rahul_kumar11
Level 2

Likes

3 likes

Total Posts

36 posts

Correct Reply

0 solutions
Top badges earned
Validate 10
Validate 1
Boost 3
Boost 1
View profile

Avatar
Validate 10
Level 2
rahul_kumar11
Level 2

Likes

3 likes

Total Posts

36 posts

Correct Reply

0 solutions
Top badges earned
Validate 10
Validate 1
Boost 3
Boost 1
View profile
rahul_kumar11
Level 2

15-10-2015

Hi i got requirement to change password of user profile .

Able to change user password in cq 5.6.1 but while coming to AEM 6.0 getting an error.

I have used below code.

private boolean checkPassword(Authorizable authorizable, String oldPassword) {

        Class<?> oldCredsClass = null;
        try {
            Credentials oldCreds = ((User) authorizable).getCredentials();
            
  
            if (oldCreds instanceof SimpleCredentials) {
                
             char[] oldCredsPwd = ((SimpleCredentials) oldCreds).getPassword();
                
                if (oldPassword.equals(String.valueOf(oldCredsPwd))) {
                    return Boolean.TRUE;
                } 
            } else {  

                // CryptSimpleCredentials.matches(SimpleCredentials credentials)
                oldCredsClass = oldCreds.getClass();

                Method matcher = oldCredsClass.getMethod("matches", SimpleCredentials.class);


                SimpleCredentials newCreds = new SimpleCredentials(authorizable
                    .getPrincipal().getName(), oldPassword.toCharArray());
                
                boolean match = (Boolean) matcher.invoke(oldCreds, newCreds);
                
                     if (match) {
                    return Boolean.TRUE;
                }
            }
        }  
        
        catch (Exception t) {
            log.info(" Catch block  " + t.getClass() );
                

            return Boolean.FALSE;
        }

        log.info(" Not executing any block And the class type1 " + oldCredsClass );
        return Boolean.FALSE;
    }

That would be great helpful.

 

Thanks,

Rahul.

Accepted Solutions (0)

Answers (1)

Answers (1)

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,408 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,408 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

15-10-2015

Can you post the Exception message please.