提交 4610052a 编写于 作者: sinat_25235033's avatar sinat_25235033

structure

上级 2cbabe4f
......@@ -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>
......
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);
}
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;
}
}
......@@ -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();
}
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();
}
package com.usthe.sureness.subject;
/* *
* @Author tomsun28
* @Description 包含subject的基础信息 可以通过subjectContext创建subject
* @Date 22:57 2019-01-23
*/
public interface SubjectContext {
}
package com.usthe.sureness.subject;
/* *
* @Author tomsun28
* @Description
* @Date 00:39 2019-01-24
*/
public interface SubjectFactory {
Subject createSubject();
}
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;
}
}
}
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);
}
}
}
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;
}
}
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);
}
}
......@@ -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));
......
......@@ -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>
......
......@@ -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.
先完成此消息的编辑!
想要评论请 注册