package org.pac4j.core.credentials.password;

import org.apache.shiro.authc.credential.PasswordService;
import org.pac4j.core.util.CommonHelper;

/**
 * A password encoder based on {@link PasswordService} from Apache Shiro
 *
 * Add the <code>shiro-core</code> dependency to use this class.
 *
 * @author Victor Noël
 * @since 1.9.2
 */
public class ShiroPasswordEncoder implements PasswordEncoder {

    private final PasswordService delegate;

    public ShiroPasswordEncoder(final PasswordService delegate) {
        CommonHelper.assertNotNull("delegate", delegate);
        this.delegate = delegate;
    }

    @Override
    public String encode(final String password) {
        return delegate.encryptPassword(password);
    }

    @Override
    public boolean matches(final String plainPassword, final String encodedPassword) {
        return delegate.passwordsMatch(plainPassword, encodedPassword);
    }

    public PasswordService getDelegate() {
        return delegate;
    }
}

@@ -406,22 +406,16 @@
 private 
-final 
 Password
@@ -511,47 +511,20 @@
     
-CommonHelper.assertNotNull(%22d
+setD
 elegate
-%22, 
+(
 dele
@@ -534,42 +534,8 @@
 e);%0A
-        this.delegate = delegate;%0A
     
@@ -912,11 +912,172 @@
 e;%0A    %7D
+%0A%0A    public void setDelegate(final PasswordService delegate) %7B%0A        CommonHelper.assertNotNull(%22delegate%22, delegate);%0A        this.delegate = delegate;%0A    %7D
 %0A%7D%0A

add setter to ShiroPasswordEncoder