class MobileAuthenticationProvider extends BaseAuthenticationProvider {
    private UserDetailServiceFactory userDetailsServiceFactory;
    private PasswordEncoder passwordEncoder;

    public MobileAuthenticationProvider(OAuth2AuthorizationService authorizationService
            , OAuth2TokenGenerator<? extends OAuth2Token> tokenGenerator
            , UserDetailServiceFactory userDetailsServiceFactory, PasswordEncoder passwordEncoder) {
        super(authorizationService, tokenGenerator);
        Assert.notNull(userDetailsServiceFactory, "userDetailsServiceFactory cannot be null");
        Assert.notNull(passwordEncoder, "passwordEncoder cannot be null");
        this.userDetailsServiceFactory = userDetailsServiceFactory;
        this.passwordEncoder = passwordEncoder;
    }

    @Override
    public boolean supports(Class<?> authentication) {
        return MobileAuthenticationToken.class.isAssignableFrom(authentication);
    }

    @Override
    protected Authentication getPrincipal(Authentication authentication) {<FILL_FUNCTION_BODY>}

    @Override
    protected AuthorizationGrantType grantType() {
        return MobileAuthenticationToken.GRANT_TYPE;
    }
}

        MobileAuthenticationToken authToken = (MobileAuthenticationToken) authentication;
        String mobile = (String) authToken.getPrincipal();
        String password = authToken.getCredentials();
        UserDetails userDetails;
        try {
            userDetails = userDetailsServiceFactory.getService(authToken).loadUserByMobile(mobile);
        } catch (AuthenticationException e) {
            throw new CustomOAuth2AuthenticationException(e.getMessage());
        }
        if (userDetails == null || !passwordEncoder.matches(password, userDetails.getPassword())) {
            throw new CustomOAuth2AuthenticationException("手机号或密码错误");
        }
        return new MobileAuthenticationToken(userDetails, userDetails.getPassword(), userDetails.getAuthorities());
    
<methods>public void <init>(OAuth2AuthorizationService, OAuth2TokenGenerator<? extends org.springframework.security.oauth2.core.OAuth2Token>) ,public org.springframework.security.core.Authentication authenticate(org.springframework.security.core.Authentication) <variables>private static final java.lang.String ERROR_URI,private static final OAuth2TokenType ID_TOKEN_TOKEN_TYPE,private final non-sealed OAuth2AuthorizationService authorizationService,private final non-sealed OAuth2TokenGenerator<? extends org.springframework.security.oauth2.core.OAuth2Token> tokenGenerator