Example usage for org.apache.shiro.realm AuthenticatingRealm setCredentialsMatcher

List of usage examples for org.apache.shiro.realm AuthenticatingRealm setCredentialsMatcher

Introduction

In this page you can find the example usage for org.apache.shiro.realm AuthenticatingRealm setCredentialsMatcher.

Prototype

public void setCredentialsMatcher(CredentialsMatcher credentialsMatcher) 

Source Link

Document

Sets the CrendialsMatcher used during an authentication attempt to verify submitted credentials with those stored in the system.

Usage

From source file:org.debux.webmotion.shiro.ShiroListener.java

License:Open Source License

@Override
public void onStart(Mapping mapping, ServerContext context) {
    // Add filter into webapp
    ServletContext servletContext = context.getServletContext();
    FilterRegistration registration = servletContext.addFilter("shiro", filter);
    if (registration != null) {
        registration.addMappingForUrlPatterns(EnumSet.of(DispatcherType.FORWARD, DispatcherType.INCLUDE,
                DispatcherType.REQUEST, DispatcherType.ERROR), true, "/*");
    }//from   w w w .java  2s .c o m

    context.addGlobalController(Shiro.class);

    Realm realm = getRealm();
    if (realm instanceof AuthenticatingRealm) {
        AuthenticatingRealm authenticatingRealm = (AuthenticatingRealm) realm;
        authenticatingRealm.setCredentialsMatcher(getMatcher());
    }

    DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(realm);
    securityManager.setSessionManager(getSessionManager());
    SecurityUtils.setSecurityManager(securityManager);
}

From source file:org.lazulite.boot.autoconfigure.osaam.shiro.ShiroAutoConfiguration.java

License:Apache License

@Bean(name = "realm")
@DependsOn("lifecycleBeanPostProcessor")
@ConditionalOnMissingBean//from  w  w w .ja va2 s.co m
public Realm realm(CacheManager cacheManager) {
    Class<?> realmClass = properties.getRealm();
    Assert.notNull(realmClass, "shiro?Realm");
    Realm realm = (Realm) BeanUtils.instantiate(realmClass);
    if (realm instanceof AuthenticatingRealm) {
        AuthenticatingRealm authenticatingRealm = ((AuthenticatingRealm) realm);
        authenticatingRealm.setCredentialsMatcher(credentialsMatcher());
        authenticatingRealm.setCacheManager(cacheManager);
    }

    return realm;
}