Git 常用命令详解

Git 是一个很强大的分布式版本管理工具,它不但适用于管理大型开源软件的源代码(如:linux kernel),管理私人的文档和源代码也有很多优势(如:wsi-lgame-pro) Git 的更多介绍,请参考我的上一篇博客:Git 版本管理工具 一、 Git 命令初识 在正式介绍Git命令之前,先介绍一下Git 的基本命令和操作,对Git命令有一个总体的认识 示例:从Git 版本库的初始化,通常有两种方式: 1)git clone:这是一种较为简单的初始化方式,当你已经有一个远程的Git版本库,只需要在本地克隆一份 例如:git  clone  git://github.com/someone/some_project.git   some_project 上面的命令就是将’git://github.com/someone/some_project.git’这个URL地址的远程版本库,完全克隆到本地some_project目录下 2)git init 和 git remote:这种方式稍微复杂一些,当你本地创建了一个工作目录,你可以进入这个目录,使用’git init’命令进行初始化;Git以后就会对该目录下的文件进行版本控制,这时候如果你需要将它放到远程服务器上,可以在远程服务器上创建一个目录,并把可访问的URL记录下来,此时你就可以利用’git remote add’命令来增加一个远程服务器端, 例如:git  remote  add  origin  git://github.com/someone/another_project.git 上面的命令就会增加URL地址为’git: //github.com/someone/another_project.git’,名称为origin的远程服务器,以后提交代码的时候只需要使用 origin别名即可 二、 Git 常用命令 1) 远程仓库相关命令 检出仓库:        $ git clone git://github.com/jquery/jquery.git 查看远程仓库:$ git remote -v 添加远程仓库:$ git …

Spring boot中Redis的使用

redis介绍 Redis是目前业界使用最广泛的内存数据存储。相比memcached,Redis支持更丰富的数据结构,例如hashes, lists, sets等,同时支持数据持久化。除此之外,Redis还提供一些类数据库的特性,比如事务,HA,主从库。可以说Redis兼具了缓存系统和数据库的一些特性,因此有着丰富的应用场景。本文介绍Redis在Spring Boot中两个典型的应用场景。 如何使用 1、引入 spring-boot-starter-redis <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-redis</artifactId> </dependency> 2、添加配置文件 # REDIS (RedisProperties) # Redis数据库索引(默认为0) spring.redis.database=0 # Redis服务器地址 spring.redis.host=192.168.0.58 # Redis服务器连接端口 spring.redis.port=6379 # Redis服务器连接密码(默认为空) spring.redis.password= # 连接池最大连接数(使用负值表示没有限制) spring.redis.pool.max-active=8 # 连接池最大阻塞等待时间(使用负值表示没有限制) spring.redis.pool.max-wait=-1 # 连接池中的最大空闲连接 spring.redis.pool.max-idle=8 # 连接池中的最小空闲连接 spring.redis.pool.min-idle=0 # 连接超时时间(毫秒) spring.redis.timeout=0 3、添加cache的配置类 @Configuration @EnableCaching public class RedisConfig extends CachingConfigurerSupport{ @Bean public KeyGenerator keyGenerator() …

Programming Links

Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne: http://algs4.cs.princeton.edu/home/ MongoDB: http://www.runoob.com/mongodb/mongodb-connections.html Public Research-Quality Datasets – Fish Where The Fish Are: http://rensanning.iteye.com/blog/1601663

spring security 3.1注册后自动登录

网上搜索一大圈,最后发现http://www.ke-cai.net/2010/11/auto-login-after-successful.html里讲述的是最接近答案的,但一测试,发现验证是通过了,session却没有保存,接着再搜,发现了一篇文章说到了这个问题,http://stackoverflow.com/questions/5428654/spring-security-auto-login-not-persisted-in-httpsession,按照它提供的解决方法发现session能保存了。 最后要解决的一件事是验证失败处理,上面两篇文章都没说,参考spring security document解决了,最后代码如下: 在controller里边声明AuthenticationManager变量,这个是关键点: @Autowired @Qualifier(“org.springframework.security.authenticationManager”) protected AuthenticationManager authenticationManager; 然后是当注册成功后的代码: @RequestMapping(value = “/registermyuser”) public ModelAndView registeruser( Locale locale,HttpServletRequest request) { System.out.println(“register user”); UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken( “heda”, “111111”); //request.getSession(); try{ token.setDetails(new WebAuthenticationDetails(request)); Authentication authenticatedUser = authenticationManager .authenticate(token); SecurityContextHolder.getContext().setAuthentication(authenticatedUser); request.getSession().setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY, SecurityContextHolder.getContext()); } catch( AuthenticationException e ){ System.out.println(“Authentication failed: ” + e.getMessage()); return new ModelAndView(new …

CAS单点登录与Springboot的security整合

cas 企业单点登录 Spring Webflow / Spring启动Java服务器组件。 可插拔身份验证支持(LDAP, 数据库,X.509,SPNEGO, JAAS,JWT, RADIUS,MongoDb等) 支持多种协议(CAS,SAML,WS-Federation, OAuth2,OpenID,OpenID Connect) 通过各种提供商(Duo Security,FIDO U2F, YubiKey,Google Authenticator等)支持多因素身份验证 支持授权外部提供商(如ADFS,Facebook,Twitter,SAML2 IdP等)的身份验证 实时监控和跟踪应用程序行为,统计信息和日志。 使用特定的认证策略管理和注册客户端应用程序和服务。 跨平台客户端支持(Java,.Net,PHP,Perl,Apache等)。 与InCommon,Box,Office365,ServiceNow,Salesforce,Workday,WebAdvisor,Drupal, Blackboard,Moodle,Google Apps等集成。 springboot特征 创建独立的Spring应用程序 直接嵌入Tomcat,Jetty或Undertow(不需要部署WAR文件) 提供有意思的“启动”POM来简化您的Maven配置 尽可能自动配置弹簧 提供生产就绪功能,如指标,运行状况检查和外部化配置 绝对没有代码生成,也不需要XML配置 应用新增spring security、spring-security-cas依赖 springboot应用添加安全框架spring security和spring-security-cas客户端。 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-cas</artifactId> </dependency> <dependency> <groupId>javax.inject</groupId> <artifactId>javax.inject</artifactId> <version>1</version> </dependency> spring-security与cas客户端整合 应用实现spring-security权限控制时,需要实现AuthenticationUserDetailsService接口或者UserDetailsService接口,来完成登陆验证。springboot要启用权限控制,必须要启用**@EnableWebSecurity**。如果需要对配置扩展,继承实现WebSecurityConfigurerAdapter配置类。 实现AuthenticationUserDetailsService接口 public class …

Spring Security 自定义 登陆 权限验证

项目简介 基于Spring Cloud 的项目,Spring Cloud是在Spring Boot上搭建的所以按照Spring Boot的方式来写 Spring Security 配置 继承 WebSecurityConfigurerAdapter ,重写configure(HttpSecurity http)配置相关权限以及重写拦截器 http.authorizeRequests() .antMatchers(“/auth/**”).permitAll() .anyRequest().authenticated().and() //证书 认证 自动登陆 .addFilterBefore(authTokenFilter, UsernamePasswordAuthenticationFilter.class) //登陆以及权限控制Filter …… ; 自定义UsernamePasswordAuthenticationFilter 自定义 UsernamePasswordAuthenticationFilter 实现自动登陆 创建Authentication 模拟登陆 Authentication authentication = new UsernamePasswordAuthenticationToken(auth, token); SecurityContextHolder.getContext().setAuthentication(authentication);; 自定义FilterSecurityInterceptor Spring Security 是通过这个过滤器来实现 Http资源安全过滤的。 获取资源权限 FilterSecurityInterceptor继承自 AbstractSecurityInterceptor ,源码中的其中beforeInvocation方法的一段代码是: Collection<ConfigAttribute> attributes = this.obtainSecurityMetadataSource() .getAttributes(object); 这个方法是来获取资源权限 ,可以重写SecurityMetadataSource obtainSecurityMetadataSource(){}方法来实现,传入一个FilterInvocation对象,返回一个Collection<ConfigAttribute>对象。 …

Oct.22,2018 warning IP

2018.6.22,ip:1.204.197.35,(陌生的地址)登陆本机成功 2018.8.3,ip:24.57.112.88,(陌生的地址)登陆本机成功 2018.8.14,ip:27.152.85.148,(陌生的地址)登陆本机成功 2018.8.16,ip:72.139.207.95,(陌生的地址)登陆本机成功