Giter VIP home page Giter VIP logo

kerberosservice's Introduction

KerberosService

MIT的kerberos、window的AD与Aapche Directory均提供了Kerberos服务器,但是这三者均是面向PC而不是应用的,所以配置与初始化相对来说比较复杂。所以,在这里自己用java实现了一个kerberos服务端与客户端,包含kerberos所有的基本功能。默认的加密方式为AES,默认的序列化方式为kryo,账户密码默认通过文件进行保存。

Example Usage

创建账号密码

  1. 创建服务端账户密码,通过ks-tool中的FileDatabaseProcessor创建(main函数中已注释掉部分)。或者根据命令行来进行创建。创建结果为ks-example中的ks-database.dat
  2. 创建客户端账户密码,通过ks-tool中的FileClientDatabaseProcessor创建。创建结果为ks-example中的ks-client-database.dat

启动服务端

main函数方式启动 ```java BaseTGTHandlerBuilder baseTGTHandlerBuilder = new BaseTGTHandlerBuilder();
	a = new TicketGrantTicketServer(8906);
	a.setTgtHandlerBuilder(baseTGTHandlerBuilder);
	new Thread(a).start();

	// BaseTGSHandlerBuilder baseTGSHandlerBuilder=new
	// BaseTGSHandlerBuilder();
	s = new TicketGrantServer(8907);

	new Thread(s).start();
  servlet listener方式启动,通过配置web.xml实现
```xml
   	<context-param>
		<param-name>tgtServerPort</param-name>
		<param-value>8906</param-value>
	</context-param>
	<context-param>
		<param-name>tgsServerPort</param-name>
		<param-value>8907</param-value>
	</context-param>
	<context-param>
		<param-name>fileDatabase</param-name>
		<param-value>E:/ks-database.dat</param-value>
	</context-param>
	<listener>
		<listener-class>com.cgs.kerberos.server.KerberosServletContextListener</listener-class>
	</listener>

客户端验证

	//创建服务请求的内容(自动获取tgt,st),如在电脑pc1上
	byte[] request = kerberosFacade.getThirdRequestByte("server");
	
	//你请求的服务端验证,并创建回送的信息(),如在电脑pc2上
	byte[] response = kerberosFacade.checkServiceTicket(request);
	
	//验证是否是你请求的服务回送的信息,如在电脑pc1上
	boolean ok = kerberosFacade.checkServiceResponse(response, "server");

Licenses

Copyright [2014] [XuMinhua]

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Remark

E-mail:[email protected]

kerberosservice's People

Contributors

wukenaihe avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.