com.github.wzc789376152.shiro.config.ShiroJwtConfiguration Maven / Gradle / Ivy
The newest version!
package com.github.wzc789376152.shiro.config;
import com.github.wzc789376152.shiro.properties.ShiroJwtProperty;
import com.github.wzc789376152.shiro.properties.ShiroRedisProperty;
import com.github.wzc789376152.shiro.realm.ShiroJwtRealm;
import com.github.wzc789376152.shiro.service.IJwtService;
import com.github.wzc789376152.shiro.service.IShiroService;
import com.github.wzc789376152.shiro.service.impl.JwtServiceImpl;
import org.crazycake.shiro.RedisManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
@Configuration
@ConditionalOnProperty(prefix = "spring.shiro.jwt", name = "enable", havingValue = "true")
@EnableConfigurationProperties(ShiroJwtProperty.class)
@ConditionalOnClass(IJwtService.class)
public class ShiroJwtConfiguration {
@Autowired
private ShiroJwtProperty shiroJwtProperty;
@Bean("jwtRealm")
public ShiroJwtRealm realm() {
return new ShiroJwtRealm();
}
@Bean
@ConditionalOnMissingBean(IJwtService.class)
public IJwtService jwtService() {
return new JwtServiceImpl(shiroJwtProperty);
}
}