当前位置: 首页 > news >正文

JDBCRealm Http Digest

2019独角兽企业重金招聘Python工程师标准>>> hot3.png


JDBCRealm
授权信息存在关系数据库中, 通过JDBC驱动访问
数据库中必须至少有两张表,表示用户及角色
用户表必须至少有两个字段,用户名及密码
角色表必须至少有两个字段,用户名及角色
[html] view plaincopy
CREATE TABLE users (  
  user_name         VARCHAR(15) NOT NULL PRIMARY KEY,  
  user_pass         VARCHAR(15) NOT NULL  
);  
   
CREATE TABLE user_roles (  
  user_name         VARCHAR(15) NOT NULL,  
  role_name         VARCHAR(15) NOT NULL,  
  PRIMARY KEY (user_name, role_name)  
);  
[html] view plaincopy
<Realm className="org.apache.catalina.realm.JDBCRealm"  
  driverName="org.gjt.mm.mysql.Driver"  
  connectionURL="jdbc:mysql://localhost/authority?user=dbuser&password=dbpass"  
  userTable="users" userNameCol="user_name" userCredCol="user_pass"  
  userRoleTable="user_roles" roleNameCol="role_name"/>  
 
Password to be recognized by Tomcat when the user logs in. This value may in cleartext or digested - see below for more information.


create table users (
  user_name         varchar(15) not null primary key,
  user_pass         varchar(15) not null
);

create table user_roles (
  user_name         varchar(15) not null,
  role_name         varchar(15) not null,
  primary key (user_name, role_name)
);

$CATALINA_BASE/conf/server.xml

<Realm className="org.apache.catalina.realm.JDBCRealm"
      driverName="org.gjt.mm.mysql.Driver"
   connectionURL="jdbc:mysql://localhost/test?user=root&amp;password=root"
       userTable="users" userNameCol="user_name" userCredCol="user_pass"
   userRoleTable="user_roles" roleNameCol="role_name"/>
   
   
   
   
   ost Tomcat packages include a script ($TOMCAT_HOME/bin/digest.shor .bat for Windows)that can be used to create a one-way digest of a
password.I use this, in conjunction with file permissions, to protect
the Tomcat manager password in$TOMCAT_HOME/conf/tomcat-users.xmlfrom prying eyes.
1.To use SHA, update$TOMCAT_HOME/conf/server.xmlso that:
resourceName="UserDatabase"/>
reads
digest="SHA" resourceName="UserDatabase"/>
2.Then create your digest by running (replacingcredentialswith the password you want to digest):$TOMCAT_HOME/bin/digest -a SHA credentials
This will output the plaintext and then the digested form of the credentials separated by a colon – e.g. for ‘foo’:foo:0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33
3.Take the second part and place this into thepasswordattribute of theuserelement intomcat-users.xml– e.g.:
password="0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33"
roles="admin,manager"/>
4.Restart Tomcat for it to take effect.
Fromhttp://leanjavaengineering.wordpress.



D:\Ken\httpauth\bin>digest.bat -a  md5 654123
654123:bf9f8d1f05dc08cc3b02e8fcf2c2ba57
D:\Ken\httpauth\bin>digest.bat -a  md5 123456
123456:e10adc3949ba59abbe56e057f20f883e
D:\Ken\httpauth\bin>digest.bat -a  md5 t:Realm:123456
t:Realm:123456:6a6f14de4691b088f3deb84b14fa0612
D:\Ken\httpauth\bin>


D:\Ken\httpauth\bin>digest.bat -a  md5 654123
654123:bf9f8d1f05dc08cc3b02e8fcf2c2ba57
D:\Ken\httpauth\bin>digest.bat -a  md5 123456
123456:e10adc3949ba59abbe56e057f20f883e
D:\Ken\httpauth\bin>digest.bat -a  md5 t:Realm:123456
t:Realm:123456:6a6f14de4691b088f3deb84b14fa0612
D:\Ken\httpauth\bin>digest.bat -a  md5 t:WebApi:123456
t:WebApi:123456:bb80940c5ff834aef1b2652eddcef09c
D:\Ken\httpauth\bin>
 
Http Digest认证中
1.Java/Android可以通过httpcomponents组件完成Digest认证
2.认证相关的角色及用户信息 可配置在数据库中存储,且密码字段可加密。

转载于:https://my.oschina.net/kenzheng/blog/548533

相关文章:

  • 开始nodejs+express的学习+实践(1)
  • 计算器,电话号,button输入时如何不会出现后一个替换覆盖前一个
  • Raid5磁盘阵列修复方法介绍
  • 手机自动化测试:Appium源码分析之跟踪代码分析五
  • 解决vsftpd日志时间问题
  • adb install INSTALL_FAILED_ALREADY_EXISTS
  • jQuery 参考手册 - 选择器
  • 数数苹果手机中的不科学
  • Ipsec transport mode and turnnel mode
  • 【探索】无形验证码 —— PoW 算力验证
  • SQL Join的一些总结
  • Cordova 问题点备忘
  • poj 1011 Sticks ,剪枝神题
  • 删除缓存
  • java 深拷贝
  • [PHP内核探索]PHP中的哈希表
  • Asm.js的简单介绍
  • mongodb--安装和初步使用教程
  • MyEclipse 8.0 GA 搭建 Struts2 + Spring2 + Hibernate3 (测试)
  • mysql 数据库四种事务隔离级别
  • Node.js 新计划:使用 V8 snapshot 将启动速度提升 8 倍
  • node学习系列之简单文件上传
  • Xmanager 远程桌面 CentOS 7
  • 创建一种深思熟虑的文化
  • 大主子表关联的性能优化方法
  • 通过npm或yarn自动生成vue组件
  • 小而合理的前端理论:rscss和rsjs
  • 移动端高清、多屏适配方案
  • #162 (Div. 2)
  • $.proxy和$.extend
  • (2)STL算法之元素计数
  • (AngularJS)Angular 控制器之间通信初探
  • (附源码)spring boot校园健康监测管理系统 毕业设计 151047
  • (附源码)计算机毕业设计ssm-Java网名推荐系统
  • (转) RFS+AutoItLibrary测试web对话框
  • .NET / MSBuild 扩展编译时什么时候用 BeforeTargets / AfterTargets 什么时候用 DependsOnTargets?
  • .NET Framework杂记
  • .NET 中创建支持集合初始化器的类型
  • .NET/C# 的字符串暂存池
  • .NET是什么
  • .net与java建立WebService再互相调用
  • .py文件应该怎样打开?
  • @JSONField或@JsonProperty注解使用
  • @JsonSerialize注解的使用
  • @SpringBootApplication 包含的三个注解及其含义
  • []T 还是 []*T, 这是一个问题
  • [100天算法】-每个元音包含偶数次的最长子字符串(day 53)
  • [HNOI2006]鬼谷子的钱袋
  • [IOI2007 D1T1]Miners 矿工配餐
  • [k8s系列]:kubernetes·概念入门
  • [linux运维] 利用zabbix监控linux高危命令并发送告警(基于Zabbix 6)
  • [NOI 2016]优秀的拆分
  • [osgearth]通过API创建一个earth模型
  • [PHP] 代码重用与函数
  • [POJ2446] Chessboard(二分图最大匹配-匈牙利算法)