A
A
artshelom2017-03-17 18:33:14
Spring
artshelom, 2017-03-17 18:33:14

How to fix error in spring security authorization??

@Component
public class SecurityBean 
        implements AuthenticationProvider {

    @Override
    public Authentication authenticate(Authentication authentication) throws AuthenticationException {
        System.out.println("Work securytyBean");
        System.out.println(authentication.toString());
        return null;
    }

    @Override
    public boolean supports(Class<?> aClass) {
        return false;
    }

}

<authentication-manager>
    <authentication-provider ref="securityBean"/>
  </authentication-manager>

I made a class for authorization, when I start it I write an error. I can't figure out what's wrong. Help
This is the error:
WARN : org.springframework.web.context.support.XmlWebApplicationContext - Exception encountered during context initialization - cancelling refresh attempt
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.filterChains': Cannot resolve reference to bean 'org.springframework.security.web.DefaultSecurityFilterChain#0' while setting bean property 'sourceList' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#0': Cannot create inner bean '(inner bean)#1a029c7' of type [org.springframework.security.web.authentication.logout.LogoutFilter] while setting constructor argument with key [4]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#1a029c7': Cannot resolve reference to bean 'org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices#0' while setting constructor argument with key [2]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices#0': Cannot create inner bean '(inner bean)#f956fd' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#f956fd': Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.core.userdetails.UserDetailsService]: Factory method 'cachingUserDetailsService' threw exception; nested exception is org.springframework.context.ApplicationContextException: No UserDetailsService registered.
  at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:359)

etc...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
aol-nnov, 2017-03-17
@artshelom

Well, why does it fall in supports?! that means it's not good for anything!
www.baeldung.com/spring-security-authentication-pr...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question