Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sureness
Sureness
提交
4610052a
Sureness
项目概览
sureness
/
Sureness
大约 1 年 前同步成功
通知
32
Star
813
Fork
161
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Sureness
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4610052a
编写于
2月 23, 2019
作者:
sinat_25235033
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
structure
上级
2cbabe4f
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
336 addition
and
6 deletion
+336
-6
core/pom.xml
core/pom.xml
+12
-2
core/src/main/java/com/usthe/sureness/mgt/SecurityManager.java
...src/main/java/com/usthe/sureness/mgt/SecurityManager.java
+20
-0
core/src/main/java/com/usthe/sureness/mgt/support/DefaultSecurityManager.java
...om/usthe/sureness/mgt/support/DefaultSecurityManager.java
+29
-0
core/src/main/java/com/usthe/sureness/subject/Subject.java
core/src/main/java/com/usthe/sureness/subject/Subject.java
+6
-1
core/src/main/java/com/usthe/sureness/subject/SubjectAuToken.java
.../main/java/com/usthe/sureness/subject/SubjectAuToken.java
+19
-0
core/src/main/java/com/usthe/sureness/subject/SubjectContext.java
.../main/java/com/usthe/sureness/subject/SubjectContext.java
+10
-0
core/src/main/java/com/usthe/sureness/subject/SubjectFactory.java
.../main/java/com/usthe/sureness/subject/SubjectFactory.java
+12
-0
core/src/main/java/com/usthe/sureness/subject/support/DefaultSubject.java
...va/com/usthe/sureness/subject/support/DefaultSubject.java
+94
-0
core/src/main/java/com/usthe/sureness/subject/support/DefaultSubjectAuToken.java
...usthe/sureness/subject/support/DefaultSubjectAuToken.java
+89
-0
core/src/main/java/com/usthe/sureness/subject/support/DefaultSubjectFactory.java
...usthe/sureness/subject/support/DefaultSubjectFactory.java
+16
-0
core/src/main/java/com/usthe/sureness/util/SurenessException.java
.../main/java/com/usthe/sureness/util/SurenessException.java
+26
-0
core/src/main/java/com/usthe/sureness/util/TireTreePathMatcher.java
...ain/java/com/usthe/sureness/util/TireTreePathMatcher.java
+1
-1
pom.xml
pom.xml
+1
-1
samples/pom.xml
samples/pom.xml
+1
-1
未找到文件。
core/pom.xml
浏览文件 @
4610052a
...
...
@@ -5,12 +5,22 @@
<parent>
<artifactId>
sureness
</artifactId>
<groupId>
com.usthe
</groupId>
<version>
1.0-SNAPSHOT
</version>
<version>
0.0.1
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
core
</artifactId>
<artifactId>
sureness-
core
</artifactId>
<properties>
<slf4j.version>
1.7.21
</slf4j.version>
</properties>
<dependencies>
<dependency>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-api
</artifactId>
<version>
${slf4j.version}
</version>
</dependency>
</dependencies>
<build>
<finalName>
${project.artifactId}
</finalName>
...
...
core/src/main/java/com/usthe/sureness/mgt/SecurityManager.java
0 → 100644
浏览文件 @
4610052a
package
com.usthe.sureness.mgt
;
import
com.usthe.sureness.subject.Subject
;
import
com.usthe.sureness.subject.SubjectAuToken
;
import
com.usthe.sureness.subject.SubjectContext
;
import
javax.security.sasl.AuthenticationException
;
/* *
* @Author tomsun28
* @Description
* @Date 22:33 2019-01-23
*/
public
interface
SecurityManager
{
Subject
login
(
Subject
var1
,
SubjectAuToken
var2
)
throws
AuthenticationException
;
Subject
createSubject
(
SubjectContext
var1
);
}
core/src/main/java/com/usthe/sureness/mgt/support/DefaultSecurityManager.java
0 → 100644
浏览文件 @
4610052a
package
com.usthe.sureness.mgt.support
;
import
com.usthe.sureness.mgt.SecurityManager
;
import
com.usthe.sureness.subject.Subject
;
import
com.usthe.sureness.subject.SubjectAuToken
;
import
com.usthe.sureness.subject.SubjectContext
;
import
com.usthe.sureness.subject.SubjectFactory
;
import
javax.security.sasl.AuthenticationException
;
/* *
* @Author tomsun28
* @Description
* @Date 00:41 2019-01-24
*/
public
class
DefaultSecurityManager
implements
SecurityManager
{
private
SubjectFactory
subjectFactory
;
public
Subject
login
(
Subject
var1
,
SubjectAuToken
var2
)
throws
AuthenticationException
{
return
null
;
}
public
Subject
createSubject
(
SubjectContext
var1
)
{
return
null
;
}
}
core/src/main/java/com/usthe/sureness/subject/Subject.java
浏览文件 @
4610052a
...
...
@@ -10,7 +10,8 @@ import java.util.Collection;
*/
public
interface
Subject
{
void
login
(
String
var1
)
throws
AuthenticationException
;
void
login
(
SubjectAuToken
var1
)
throws
AuthenticationException
;
void
logout
();
// 是否认证
boolean
isAuthenticated
();
...
...
@@ -23,4 +24,8 @@ public interface Subject {
boolean
hasAllRoles
(
Collection
<
String
>
var1
);
Object
getRoles
();
Object
cloneImage
();
}
core/src/main/java/com/usthe/sureness/subject/SubjectAuToken.java
0 → 100644
浏览文件 @
4610052a
package
com.usthe.sureness.subject
;
/* *
* @Author tomsun28
* @Description AuthenticationToken AuthorizationToken
* @Date 21:58 2019-01-22
*/
public
interface
SubjectAuToken
{
Object
getPrincipal
();
Object
getCredentials
();
Object
getRoles
();
Object
getTargetResource
();
}
core/src/main/java/com/usthe/sureness/subject/SubjectContext.java
0 → 100644
浏览文件 @
4610052a
package
com.usthe.sureness.subject
;
/* *
* @Author tomsun28
* @Description 包含subject的基础信息 可以通过subjectContext创建subject
* @Date 22:57 2019-01-23
*/
public
interface
SubjectContext
{
}
core/src/main/java/com/usthe/sureness/subject/SubjectFactory.java
0 → 100644
浏览文件 @
4610052a
package
com.usthe.sureness.subject
;
/* *
* @Author tomsun28
* @Description
* @Date 00:39 2019-01-24
*/
public
interface
SubjectFactory
{
Subject
createSubject
();
}
core/src/main/java/com/usthe/sureness/subject/support/DefaultSubject.java
0 → 100644
浏览文件 @
4610052a
package
com.usthe.sureness.subject.support
;
import
com.usthe.sureness.subject.Subject
;
import
com.usthe.sureness.subject.SubjectAuToken
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.naming.AuthenticationException
;
import
java.io.Serializable
;
import
java.util.Collection
;
/* *
* @Author tomsun28
* @Description
* @Date 22:03 2019-01-22
*/
public
class
DefaultSubject
implements
Subject
{
private
static
transient
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
DefaultSubject
.
class
);
private
boolean
authenticated
=
false
;
private
String
principal
;
private
String
[]
roles
;
// 当有一次调用onceLogin之后,特指方法才生效
private
boolean
onceLogin
=
false
;
private
boolean
isOnceLogin
()
{
return
onceLogin
;
}
public
void
login
(
SubjectAuToken
var1
)
throws
AuthenticationException
{
onceLogin
=
!
onceLogin
||
onceLogin
;
}
public
void
logout
()
{
authenticated
=
false
;
}
public
boolean
isAuthenticated
()
{
return
authenticated
;
}
public
boolean
isAuthorizated
()
{
return
false
;
}
public
Object
getPrincipal
()
{
return
null
;
}
public
boolean
hasRole
(
String
var1
)
{
return
false
;
}
public
boolean
hasAllRoles
(
Collection
<
String
>
var1
)
{
return
false
;
}
public
Object
getRoles
()
{
return
null
;
}
public
Object
cloneImage
()
{
return
new
ImageDefaultSubject
(
authenticated
,
principal
,
roles
);
}
public
class
ImageDefaultSubject
implements
Serializable
{
private
boolean
authenticated
;
private
String
principal
;
private
String
[]
roles
;
private
ImageDefaultSubject
(
boolean
authenticated
,
String
principal
,
String
[]
roles
)
{
this
.
authenticated
=
authenticated
;
this
.
principal
=
principal
;
this
.
roles
=
roles
;
}
public
boolean
isAuthenticated
()
{
return
authenticated
;
}
public
String
[]
getRoles
()
{
return
roles
;
}
public
String
getPrincipal
()
{
return
principal
;
}
}
}
core/src/main/java/com/usthe/sureness/subject/support/DefaultSubjectAuToken.java
0 → 100644
浏览文件 @
4610052a
package
com.usthe.sureness.subject.support
;
import
com.usthe.sureness.subject.SubjectAuToken
;
import
java.util.LinkedList
;
import
java.util.List
;
/* *
* @Author tomsun28
* @Description
* @Date 23:28 2019-01-23
*/
public
class
DefaultSubjectAuToken
implements
SubjectAuToken
{
private
String
appId
;
private
String
credential
;
private
List
<
String
>
roles
;
// url===httpMethod
private
String
targetUri
;
private
DefaultSubjectAuToken
(
Builder
builder
)
{
this
.
appId
=
builder
.
appId
;
this
.
credential
=
builder
.
credential
;
this
.
roles
=
builder
.
roles
;
this
.
targetUri
=
builder
.
targetUri
;
}
public
Object
getPrincipal
()
{
return
this
.
appId
;
}
public
Object
getCredentials
()
{
return
this
.
credential
;
}
public
Object
getRoles
()
{
return
this
.
roles
;
}
public
Object
getTargetResource
()
{
return
this
.
targetUri
;
}
public
static
Builder
getBuilder
()
{
return
new
Builder
();
}
public
static
class
Builder
{
private
String
appId
;
private
String
credential
;
private
List
<
String
>
roles
;
private
String
targetUri
;
public
Builder
setPrincipal
(
String
appId
)
{
this
.
appId
=
appId
;
return
this
;
}
public
Builder
setCredentials
(
String
credential
)
{
this
.
credential
=
credential
;
return
this
;
}
public
Builder
setTargetResource
(
String
targetUri
)
{
this
.
targetUri
=
targetUri
;
return
this
;
}
public
Builder
addRole
(
String
role
)
{
if
(
roles
==
null
)
{
this
.
roles
=
new
LinkedList
<
String
>();
}
this
.
roles
.
add
(
role
);
return
this
;
}
public
Builder
addRoles
(
List
<
String
>
roles
)
{
if
(
this
.
roles
==
null
)
{
this
.
roles
=
new
LinkedList
<
String
>();
}
this
.
roles
.
addAll
(
roles
);
return
this
;
}
public
DefaultSubjectAuToken
build
()
{
return
new
DefaultSubjectAuToken
(
this
);
}
}
}
core/src/main/java/com/usthe/sureness/subject/support/DefaultSubjectFactory.java
0 → 100644
浏览文件 @
4610052a
package
com.usthe.sureness.subject.support
;
import
com.usthe.sureness.subject.Subject
;
import
com.usthe.sureness.subject.SubjectFactory
;
/* *
* @Author tomsun28
* @Description
* @Date 00:40 2019-01-24
*/
public
class
DefaultSubjectFactory
implements
SubjectFactory
{
public
Subject
createSubject
()
{
return
null
;
}
}
core/src/main/java/com/usthe/sureness/util/SurenessException.java
0 → 100644
浏览文件 @
4610052a
package
com.usthe.sureness.util
;
/* *
* @Author tomsun28
* @Description
* @Date 22:40 2019-01-23
*/
public
class
SurenessException
extends
RuntimeException
{
public
SurenessException
()
{
super
();
}
public
SurenessException
(
String
message
)
{
super
(
message
);
}
public
SurenessException
(
String
message
,
Throwable
cause
)
{
super
(
message
,
cause
);
}
public
SurenessException
(
Throwable
cause
)
{
super
(
cause
);
}
}
core/src/main/java/com/usthe/sureness/util/TireTreePathMatcher.java
浏览文件 @
4610052a
...
...
@@ -200,7 +200,7 @@ public class TireTreePathMatcher {
/* *
* @Description 孩子节点
*/
private
Map
<
String
,
Node
>
children
=
new
HashMap
<>();
private
Map
<
String
,
Node
>
children
=
new
HashMap
<
String
,
Node
>();
public
void
insertChild
(
String
data
)
{
this
.
children
.
put
(
data
,
new
Node
(
data
));
...
...
pom.xml
浏览文件 @
4610052a
...
...
@@ -7,7 +7,7 @@
<groupId>
com.usthe
</groupId>
<artifactId>
sureness
</artifactId>
<packaging>
pom
</packaging>
<version>
1.0-SNAPSHOT
</version>
<version>
0.0.1
</version>
<modules>
<module>
core
</module>
<module>
samples
</module>
...
...
samples/pom.xml
浏览文件 @
4610052a
...
...
@@ -5,7 +5,7 @@
<parent>
<artifactId>
sureness
</artifactId>
<groupId>
com.usthe
</groupId>
<version>
1.0-SNAPSHOT
</version>
<version>
0.0.1
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录