spring-security登录和权限管理

spring security

spring security 主要的两个功能是认证和授权
认证的大概流程:
Username password AuthenticationFilter(自定义usernamepassword拦截器)
UserDetailService (查询用户密码的service接口)
Userdetails (用户类接口)
AuthenticationProvide (为认证管理器AuthenticationManager 提供验证组件AuthenticationProvider)
授权的大概流程:
(extends)AbstractsecurityInterceptor +(implements)Filter(资源访问过滤器,拦截访问请求,封装成安全对象FilterInvocation,调用前两个实例进行鉴权)
FilterInvocationSecurityMetadataSource(自定义权限数据源,提供所有URL资源与对应角色权限的映射集合)
AccessDecisionManager (自定义鉴权管理器,根据URL资源权限和用户角色权限进行鉴权)

用户登陆
会被AuthenticationProcessingFilter拦截,调用AuthenticationManager的实现,而且AuthenticationManager会调用ProviderManager来获取用户验证信息(不同的Provider调用的服务不同,因为这些信息可以是在数据库上,可以是在LDAP服务器上,可以是xml配置文件上等),如果验证通过后会将用户的权限信息封装一个User放到spring的全局缓存SecurityContextHolder中,以备后面访问资源时使用。
访问资源(即授权管理
访问url时,会通过AbstractSecurityInterceptor拦截器拦截,其中会调用FilterInvocationSecurityMetadataSource的方法来获取被拦截url所需的全部权限,在调用授权管理器AccessDecisionManager,这个授权管理器会通过spring的全局缓存SecurityContextHolder获取用户的权限信息,还会获取被拦截的url和被拦截url所需的全部权限,然后根据所配的策略(有:一票决定,一票否定,少数服从多数等),如果权限足够,则返回,权限不够则报错并调用权限不足页面。

项目结构:
在这里插入图片描述
数据库设计:
在这里插入图片描述
model:
Permission

package com.example.arcgisdemo.model;import com.sun.javafx.beans.IDProperty;import javax.persistence.*;
import java.util.List;@Entity
@Table(name = "SYS_PERMISSION")
public class Permission {@Id@GeneratedValue(strategy = GenerationType.AUTO)@Column(name = "ID")private int id;@Column(name = "NAME")private String name;@Column(name = "DESCRIPTION")private String description;@Column(name = "URL")private String url;@Column(name = "PID")private String pid;public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}public String getDescription() {return description;}public void setDescription(String description) {this.description = description;}public String getUrl() {return url;}public void setUrl(String url) {this.url = url;}public String getPid() {return pid;}public void setPid(String pid) {this.pid = pid;}}

User:
这里是在User中实现了UserDetails

package com.example.arcgisdemo.model;import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;import javax.persistence.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;@Entity
@Table(name = "SYS_USER")
public class User implements UserDetails {@Id@GeneratedValue(strategy = GenerationType.AUTO)@Column(name = "ID")private int id;@Column(name = "USERNAME")private String username;@Column(name = "PASSWORD")private String password;@ManyToMany(fetch = FetchType.EAGER)@JoinTable(name = "SYS_ROLE_USER",joinColumns = {@JoinColumn(name = "SYS_USER_ID",referencedColumnName = "ID")},inverseJoinColumns = {@JoinColumn(name = "SYS_ROLE_ID",referencedColumnName = "ID")})private List<Role> roles;@Overridepublic Collection<? extends GrantedAuthority> getAuthorities() {if (roles == null || roles.size() < 1) {return AuthorityUtils.commaSeparatedStringToAuthorityList("");}StringBuilder rolestring = new StringBuilder();for (Role role : roles) {rolestring.append(role.getName()).append(",");}List<GrantedAuthority> authorityList = AuthorityUtils.commaSeparatedStringToAuthorityList(rolestring.substring(0, rolestring.length() - 1));return authorityList;}public int getId() {return id;}public void setId(int id) {this.id = id;}public String getUsername() {return username;}public void setUsername(String username) {this.username = username;}public String getPassword() {return password;}public void setPassword(String password) {this.password = password;}@Overridepublic boolean isAccountNonExpired() {return true;}@Overridepublic boolean isAccountNonLocked() {return true;}@Overridepublic boolean isCredentialsNonExpired() {return true;}@Overridepublic boolean isEnabled() {return true;}public List<Role> getRoles() {return roles;}public void setRoles(List<Role> roles) {this.roles = roles;}}

Role

package com.example.arcgisdemo.model;import javax.persistence.*;
import java.util.List;@Entity
@Table(name = "SYS_ROLE")
public class Role {@Id@GeneratedValue(strategy = GenerationType.AUTO)@Column(name = "ID")private int id;@Column(name = "NAME")private String name;@ManyToMany(fetch = FetchType.EAGER)@JoinTable(name = "SYS_PERMISSION_ROLE",joinColumns = {@JoinColumn(name = "ROLE_ID",referencedColumnName = "ID")},inverseJoinColumns = {@JoinColumn(name = "PERMISSION_ID",referencedColumnName = "ID")})private List<Permission> permissions;public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}public List<Permission> getPermissions() {return permissions;}public void setPermissions(List<Permission> permissions) {this.permissions = permissions;}
}

security:
WebSecurityConfig 配置

package com.example.arcgisdemo.security;import com.example.arcgisdemo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.password.NoOpPasswordEncoder;
import org.springframework.security.web.access.intercept.FilterSecurityInterceptor;
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;@Configuration
@EnableWebSecurity //注解开启Spring Security的功能
@EnableGlobalMethodSecurity(prePostEnabled = true) //开启Spring Security注解功能
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {@Autowiredprivate UserService userService;@Autowiredprivate SysFilterSecurityInterceptor sysFilterSecurityInterceptor;protected void configure(AuthenticationManagerBuilder auth) throws Exception {auth.userDetailsService(userService).passwordEncoder(passwordEncoder());
//        auth.authenticationProvider(new SysDaoAuthenticationProvider());}protected void configure(HttpSecurity http) throws Exception {http.authorizeRequests().antMatchers("/js/layui/**").permitAll() //定义不需要认证就可以访问的资源.anyRequest().authenticated().and().formLogin().loginPage("/login")  //定义当需要用户登录时候,转到的登录页面.loginProcessingUrl("/login").defaultSuccessUrl("/", true).failureUrl("/login?error").permitAll().and().logout().logoutUrl("/logout")//退出登录后的默认Url是login.logoutSuccessUrl("/login").permitAll();//解决非thymeleaf的form表单提交被拦截问题http.csrf().disable();http.addFilter(customUsernamePasswordAuthenticationFilter());http.addFilterBefore(sysFilterSecurityInterceptor, FilterSecurityInterceptor.class).csrf().disable();http.headers().frameOptions().sameOrigin();}
/*,"https://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Hydrography/Watershed173811/MapServer/1","https://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Hydrography/Watershed173811/MapServer/0","http://192.168.101.4:8080/agapi/**"*/@Beanpublic static NoOpPasswordEncoder passwordEncoder() {return (NoOpPasswordEncoder) NoOpPasswordEncoder.getInstance();}@Beanpublic UserDetailsService systemUserService() {return new UserService();}@Beanpublic SysUsernamePasswordF customUsernamePasswordAuthenticationFilter() throws Exception {SysUsernamePasswordF customUsernamePasswordAuthenticationFilter = new SysUsernamePasswordF();customUsernamePasswordAuthenticationFilter.setRequiresAuthenticationRequestMatcher(new AntPathRequestMatcher("/login", "POST"));customUsernamePasswordAuthenticationFilter.setAuthenticationManager(authenticationManagerBean());customUsernamePasswordAuthenticationFilter.setAuthenticationSuccessHandler(new SavedRequestAwareAuthenticationSuccessHandler());customUsernamePasswordAuthenticationFilter.setAuthenticationFailureHandler(new SimpleUrlAuthenticationFailureHandler("/login?error"));return customUsernamePasswordAuthenticationFilter;}
}

SysUsernamePasswordF

package com.example.arcgisdemo.security;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.authentication.AuthenticationServiceException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;public class SysUsernamePasswordF extends UsernamePasswordAuthenticationFilter {public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException {if (!request.getMethod().equals("POST")) {throw new AuthenticationServiceException("Authentication method not supported: " + request.getMethod());} else {String username = this.obtainUsername(request);String password = this.obtainPassword(request);if (username == null) {username = "";}else {}if (password == null) {password = "";}else {}username = username.trim();UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken(username, password);this.setDetails(request, authRequest);return this.getAuthenticationManager().authenticate(authRequest);}}
}

SysUserDetailsService

package com.example.arcgisdemo.security;import ch.qos.logback.core.joran.conditional.ElseAction;
import com.example.arcgisdemo.model.Permission;import com.example.arcgisdemo.model.User;
import com.example.arcgisdemo.service.PermissionService;
import com.example.arcgisdemo.service.SysUserService;
import com.example.arcgisdemo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;import java.util.ArrayList;
import java.util.List;public class SysUserDetailsService implements UserDetailsService {@Autowiredprivate SysUserService sysUserService;@Autowiredprivate PermissionService permissionService;@Overridepublic UserDetails loadUserByUsername(String username)  {User user = sysUserService.findByUserName(username);if (user != null) {List<Permission> permissions = permissionService.findById(user.getId());List<GrantedAuthority> grantedAuthorities = new ArrayList<>();for (Permission permission : permissions) {if (permission != null && permission.getName() != null) {GrantedAuthority grantedAuthority = new SimpleGrantedAuthority(permission.getName());//将此处权限信息添加到GrantedAuthority对象中,在后面进行全权限验证时会使用GrantedAuthoritygrantedAuthorities.add(grantedAuthority);}}return new org.springframework.security.core.userdetails.User(user.getUsername(), user.getPassword(), grantedAuthorities);}else {throw new UsernameNotFoundException("do not exist");}}
}

SysInvocationSecurityMetadataSourceService

package com.example.arcgisdemo.security;import com.example.arcgisdemo.model.Permission;
import com.example.arcgisdemo.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.ConfigAttribute;
import org.springframework.security.access.SecurityConfig;
import org.springframework.security.web.FilterInvocation;
import org.springframework.security.web.access.intercept.FilterInvocationSecurityMetadataSource;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
import org.springframework.stereotype.Service;
import sun.security.krb5.Config;import javax.servlet.http.HttpServletRequest;
import java.util.*;@Service
public class SysInvocationSecurityMetadataSourceService implements FilterInvocationSecurityMetadataSource {@Autowiredprivate PermissionService permissionService;private HashMap<String,Collection<ConfigAttribute>> map=null;//加载权限表中所有权限public void loadResourceDefine(){map=new HashMap<>();Collection<ConfigAttribute> array;ConfigAttribute cfg;List<Permission> permissions=permissionService.findAll();for (Permission permission:permissions){array=new ArrayList<>();cfg=new SecurityConfig(permission.getName());//此处指添加用户的名字,其实可以添加更多权限信息。例如请求方法到ConfigAttributr的集合中array.add(cfg);//用权限的getUrl。作为map的key。用ConfigAttribute的集合作为valuemap.put(permission.getUrl(),array);}}
//此方法是为了判定用户请求的url是否在权限表中,如果在权限表中,则返回给decide()方法,
// 用来判断用户是否有此权限,如果不在权限表中则放行@Overridepublic Collection<ConfigAttribute> getAttributes(Object object) throws IllegalArgumentException {if(map ==null)loadResourceDefine();//object中包含用户请求的request信息HttpServletRequest request=((FilterInvocation)object).getHttpRequest();AntPathRequestMatcher matcher;String resUrl;for (Iterator<String> iter=map.keySet().iterator();iter.hasNext();){resUrl=iter.next();matcher=new AntPathRequestMatcher(resUrl);if (matcher.matches(request)){return map.get(resUrl);}}return null;}@Overridepublic Collection<ConfigAttribute> getAllConfigAttributes() {return null;}@Overridepublic boolean supports(Class<?> aClass) {return true;}
}

SysFilterSecurityInterceptor

package com.example.arcgisdemo.security;import org.apache.catalina.connector.Request;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.security.access.SecurityMetadataSource;
import org.springframework.security.access.intercept.AbstractSecurityInterceptor;
import org.springframework.security.access.intercept.InterceptorStatusToken;
import org.springframework.security.web.FilterInvocation;
import org.springframework.stereotype.Service;
import javax.servlet.*;import javax.servlet.*;
import java.io.IOException;
@Service(value = "sysFilterSecurityInterceptor")
public class SysFilterSecurityInterceptor extends AbstractSecurityInterceptor implements Filter {@Autowired@Qualifier(value = "sysInvocationSecurityMetadataSourceService")private SysInvocationSecurityMetadataSourceService sysInvocationSecurityMetadataSourceService;@Autowired@Qualifier(value = "sysAccessDecisionManager")public void setSysAccessDecisionManager(SysAccessDecisionManager sysAccessDecisionManager){super.setAccessDecisionManager(sysAccessDecisionManager);}@Overridepublic void init(FilterConfig filterConfig) throws ServletException {}@Overridepublic void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {FilterInvocation fi=new FilterInvocation(servletRequest,servletResponse,filterChain);invoke(fi);}public void invoke(FilterInvocation fi)throws IOException,ServletException{//fi里面有一个被拦截的url//里面调用SysInvocationSecurityMetadataSource的getAttributes(Object object)这个方法获取fi对应的所有权限//在调用SysAccessDecisionManager的decide方法来校验用户的权限是否足够InterceptorStatusToken token=super.beforeInvocation(fi);try {//执行下一个拦截器fi.getChain().doFilter(fi.getRequest(),fi.getResponse());}finally {super.afterInvocation(token,null);}}@Overridepublic void destroy() {}@Overridepublic Class<?> getSecureObjectClass() {return FilterInvocation.class;}@Overridepublic SecurityMetadataSource obtainSecurityMetadataSource() {return this.sysInvocationSecurityMetadataSourceService;}
}

SysAccessDecisionManager

package com.example.arcgisdemo.security;import org.springframework.security.access.AccessDecisionManager;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.access.ConfigAttribute;
import org.springframework.security.authentication.InsufficientAuthenticationException;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.stereotype.Service;import java.util.Collection;
import java.util.Iterator;
@Service(value = "sysAccessDecisionManager")
public class SysAccessDecisionManager implements AccessDecisionManager {//decide方法是判定是否拥有权限的决策方法//authentication  是释SysUserDetailsService中循环添加到GrantedAuthority对象中的权限信息集合//object 包含客户端发起的请求的request信息。可转换为HttpServlerRequest request=((FilterInvocation) object).getHttpRequest();//configAttributes 为InvocationSecurityMetadataSource的getAttributes(Object)这个方法返回的结果//此方法是为了判定用户请求的url,是否在权限表中,如果在权限表中,则返回给decide方法,//用来判定用户是否有此权限,如果不在权限表中则放行。@Overridepublic void decide(Authentication authentication, Object object, Collection<ConfigAttribute> configAttributes) throws AccessDeniedException, InsufficientAuthenticationException {if (null==configAttributes || configAttributes.size()<=0){return;}ConfigAttribute configAttribute;String needRole;for (Iterator<ConfigAttribute> iter=configAttributes.iterator();iter.hasNext();){configAttribute=iter.next();needRole=configAttribute.getAttribute();for (GrantedAuthority ga:authentication.getAuthorities()){if (needRole.trim().equals(ga.getAuthority())){return;}}}throw new AccessDeniedException("no right");}@Overridepublic boolean supports(ConfigAttribute configAttribute) {return true;}@Overridepublic boolean supports(Class<?> aClass) {return true;}
}

Service:
PermissionService

package com.example.arcgisdemo.service;import com.example.arcgisdemo.dao.PermissionDao;
import com.example.arcgisdemo.model.Permission;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;import java.util.List;@Service(value = "permissionService")
public class PermissionService {@Autowired@Qualifier(value = "permissionDao")private PermissionDao permissionDao;public List<Permission> findAll(){return permissionDao.findAll();}public List<Permission> findById(int id){return permissionDao.findById(id);}
}

SysUserService

package com.example.arcgisdemo.service;import com.example.arcgisdemo.dao.UserMapper;
import com.example.arcgisdemo.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;import java.util.List;@Service(value = "sysUserService")
public class SysUserService {@Autowired@Qualifier(value = "userMapper")private UserMapper userMapper;public User queryByUserName(String username) {return userMapper.queryByUsername(username);}public User findByUserName(String username){return userMapper.findByUsername(username);}
}

UserService

package com.example.arcgisdemo.service;import com.example.arcgisdemo.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
@Service(value = "userService")
public class UserService implements UserDetailsService {@Autowiredprivate SysUserService systemUserService;@Overridepublic UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {//根据用户名从数据库查询对应记录User user=systemUserService.queryByUserName(s);if (user ==null){throw new UsernameNotFoundException("username is not exists");}System.out.println("username:"+user.getUsername()+",password:"+user.getPassword());return user;}
}

dao:
PermissionDao

package com.example.arcgisdemo.dao;import com.example.arcgisdemo.model.Permission;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;import java.util.List;@Repository(value = "permissionDao")
public interface PermissionDao extends JpaRepository<Permission,Long> {List<Permission> findAll();List<Permission> findById(int id);
}

UserMapper

package com.example.arcgisdemo.dao;import com.example.arcgisdemo.model.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;import java.util.List;@Repository(value = "userMapper")
public interface UserMapper extends JpaRepository<User,Long> {User queryByUsername(String username);User findByUsername(String username);
}

controller

package com.example.arcgisdemo.controller;import org.springframework.security.access.annotation.Secured;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;@Controller
public class DemoController {@RequestMapping("/login")public String login() {return "login";}@RequestMapping("/")public String index1() {return "index-ui";}/*@Secured({"ROLE_ADMIN"})*/@RequestMapping("/user")public String user(){return "user";}@RequestMapping("/map")public String map(){return "map";}
}

也可以在页面上设置权限,让没有权限的用户看不到该功能

<div sec:authorize="hasRole('ADMIN')"><!--设置权限--><ul class="layui-nav layui-layout-left"><li class="layui-nav-item"><a href="">控制台</a></li><li class="layui-nav-item"><a href="">管理</a></li><li class="layui-nav-item"><a href="/user">用户</a></li><li class="layui-nav-item"><a href="javascript:;">其它系统</a><dl class="layui-nav-child"><dd><a href="">邮件管理</a></dd><dd><a href="">消息管理</a></dd><dd><a href="">授权管理</a></dd></dl></li></ul></div>

在这里遇到个问题 刚开始的时候没有效果,经过找资料需要将spring 版本降到2.0.7以下
再加上:

<htmlxmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">

pom.xml 需要配置secutiry扩展包

<dependency><groupId>org.thymeleaf.extras</groupId><artifactId>thymeleaf-extras-springsecurity4</artifactId><version>3.0.2.RELEASE</version></dependency>

参考文档:链接:https://www.jianshu.com/p/bcbbf16610fb

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/519805.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

官宣!阿里Blink和Flink合并计划出炉

apache已公开合并计划&#xff0c;点击可阅读原文《Batch as a Special Case of Streaming and Alibabas contribution of Blink》&#xff0c;由AI前线进行了翻译。 **春节前一周&#xff0c;经过社区内部讨论&#xff0c;阿里巴巴大数据引擎 Blink 作为 Flink 的分支 正式开源…

第四章、项目整合管理【PMP】

文章目录1. 简介2. 项目整合管理涉及的方面3. 项目整合管理的过程包括2. 制定项目章程3. 制定项目章程&#xff1a;输入4. 制定项目管理计划5. 指导和管理项目工作6. 管理项目知识7. 监督项目工作8. 监控项目工作9. 实施整体变更控制10. 结束项目或阶段1. 简介 项目整合管理是…

龙芯新款处理器发布;Citrix 产品曝“惊天漏洞”,影响全球 8 万家公司; AMD发布年度5大里程碑 ……...

关注并标星星CSDN云计算 速递、最新、绝对有料。这里有企业新动、这里有业界要闻&#xff0c;打起十二分精神&#xff0c;紧跟fashion你可以的&#xff01;每周两次&#xff0c;打卡即read更快、更全了解泛云圈精彩newsgo go go铠侠&#xff08;东芝&#xff09;开发新型闪存&a…

开源SQL-on-Hadoop系统一览

引言 查询分析是大数据要解决的核心问题之一&#xff0c;而SQL作为查询分析中使用最简单、最广泛的的语言之一&#xff0c;必然而然的催生了许多支持在Hadoop上使用SQL的系统&#xff0c;这就是所谓的SQL-on-Hadoop系统&#xff0c;其中大众熟知的Hive就是最早的SQL-on-Hadoop…

PL/SQL中查询Oracle大数(17位以上)时显示科学计数法的解决方法

PL/SQL查询时&#xff0c;如果Number(17)以上的大数&#xff0c;会显示为科学计数法 解决方法&#xff1a; TOOLS->PREFERENCES->WINDOW TYPE->SQL WINDOW下选中Number fields to_char即可。

虎牙直播在微服务改造方面的实践和总结

相比文字和图片&#xff0c;直播提供了人与人之间更丰富的沟通形式&#xff0c;其对平台稳定性的考验很大&#xff0c;那么倡导“以技术驱动娱乐”的虎牙直播&#xff08;以下简称“虎牙”&#xff09;是如何在技术上赋能娱乐&#xff0c;本文将为您介绍虎牙在DNS、服务注册、C…

区块链人才缺口明年将达顶峰,核心开发者年入百万很正常

区块链技术一直备受争议&#xff0c;庞氏骗局、泡沫明显、去中心化无意义&#xff0c;技术无法真正建立信任、区块链技术并不能真正履行货币职能、比特币矿机耗电量大、浪费资源等等。2018年&#xff0c;加密货币市场总价值损失超过80%&#xff0c;链圈就此进入阴影。区块链技术…

阿里云移动端播放器高级功能---截图和音频波形

基本介绍 如果用户对视频播放中的某一帧画面特别感兴趣&#xff0c;可以使用截图功能将这一帧视频保存起来。另外有一种场景想知道是否有声音&#xff0c;或者想感知声音的大小震动频率等&#xff0c;可以通过显示一个声音的波形来形象的表示。如下图所示&#xff1a; 那么播放…

AES和RSA前后端加解密

先了解AES和RSA加密算法 AES算法 1、运算速度快&#xff0c;在有反馈模式、无反馈模式的软硬件中&#xff0c;Rijndael都表现出非常好的性能。 2、对内存的需求非常低,适合于受限环境。 3、Rijndael 是一个分组迭代密码&#xff0c; 分组长度和密钥长度设计灵活。 4、AES标…

PMBOK第六版最新十大大知识领域ITTO思维导图-干货!

PMBOK学习过程中&#xff0c;ITTO&#xff08;输入、工具、技术、输出&#xff09;是每年必考的内容&#xff0c;掌握ITTO的脉络&#xff0c;对学习和梳理PMP非常有帮助。知道这个过程要做什么&#xff0c;为什么做&#xff0c;做完有什么成果。也是项目经理必备的技能之一。 …

这个情人节,工程师用阿里云来试着表达不一样的爱意

年轻的时候谈的恋爱就像TCP链接&#xff0c;恋爱时三次握手即可&#xff0c;可分手时却分了四次。而常常久久的爱情&#xff0c;更像是icmp协议&#xff0c;无论对方身在何处&#xff0c;无论是否是可靠连接&#xff0c;无论你何时去ping她/他&#xff0c;她/他都默默地响应你。…

云+X案例展 | 金融类:金山云为新网银行重塑金融服务提供云计算动力

本案例由金山云投递并参与评选&#xff0c;CSDN云计算独家全网首发&#xff1b;更多关于【云X 案例征集】的相关信息&#xff0c;点击了解详情丨挖掘展现更多优秀案例&#xff0c;为不同行业领域带来启迪&#xff0c;进而推动整个“云行业”的健康发展。作为国内第三家、中西部…

对于AES和RSA算法的结合使用以及MD5加盐注册登录时的密码加密

RSA和AES结合使用 接上篇的RSA和AES算法加密之后&#xff0c;AES对称算法对数据量大的加密比较快&#xff0c;而RSA公私钥加密的话会影响加密效率&#xff0c;但是AES的加密与解密的密钥是一致的&#xff0c;导致密钥不能外泄&#xff0c;密钥在网络传输过程中&#xff0c;很有…

Unity人物移动的几种方法

Unity人物移动的几种方法 方法一&#xff1a;transform.Translate世界坐标系移动自身移动的案例 方法二&#xff1a;CharacterController.Move&#xff08;vector dir&#xff09;按照世界坐标轴移动按照自身坐标轴移动 方法三&#xff1a;CharacterController.SimpleMove&…

可应用于实际的14个NLP突破性研究成果(四)

可应用于实际的14个NLP突破性研究成果&#xff08;一&#xff09; 可应用于实际的14个NLP突破性研究成果&#xff08;二&#xff09; 可应用于实际的14个NLP突破性研究成果&#xff08;三&#xff09; 11.对序列建模的通用卷积和递归网络的实证评估作者&#xff1a;SHAOJIE …

量子通信,到底是什么工作原理?

戳蓝字“CSDN云计算”关注我们哦&#xff01;作者 | 小枣君责编 | 阿秃今天&#xff0c;小枣君要和大家聊的是“量子通信”。最开始计划写这个专题的时候&#xff0c;小枣君的内心是很纠结的。鲜枣课堂的目的&#xff0c;就是传递“普通人都能听懂”的知识。每一个知识点专题&a…

图(关系网络)数据分析及阿里应用

2019年1月18日&#xff0c;由阿里巴巴MaxCompute开发者社区和阿里云栖社区联合主办的“阿里云栖开发者沙龙大数据技术专场”走近北京联合大学&#xff0c;本次技术沙龙上&#xff0c;阿里巴巴资深技术专家钱正平为大家分享了大数据技术背景下图数据的应用前景&#xff0c;以及阿…

架构的“一小步”,业务的一大步

前言&#xff1a; 谈到“架构”这两个字&#xff0c;会有好多的名词闪现&#xff0c;比如:分层架构、事件驱动架构、DDD、CQRS等。亦或者一堆的软件设计原则&#xff0c;如&#xff1a;KISS原则&#xff08;Keep it Simple and Stupid&#xff09;、SOLID原则(单一责任原则、开…

牵手大企,关于图形计算、HPC与AI,NVIDIA言有尽而意无穷!

戳蓝字“CSDN云计算”关注我们哦&#xff01;作者 | 晶少出品 | CSDN云计算&#xff08;ID&#xff1a;CSDNcloud&#xff09;在黄仁勋看来&#xff0c;随着摩尔定律消亡&#xff0c;GPU加速才是撬动未来高性能计算发展的有力杠杆。有数据显示&#xff0c;目前NVIDIA已经销售了…

如何合理的规划jvm性能调优

JVM性能调优涉及到方方面面的取舍&#xff0c;往往是牵一发而动全身&#xff0c;需要全盘考虑各方面的影响。但也有一些基础的理论和原则&#xff0c;理解这些理论并遵循这些原则会让你的性能调优任务将会更加轻松。为了更好的理解本篇所介绍的内容。你需要已经了解和遵循以下内…