未验证 提交 7f5e4752 编写于 作者: sinat_25235033's avatar sinat_25235033 提交者: GitHub

only match subject supportRoles once (#47)

上级 ae0de660
......@@ -14,15 +14,6 @@ import java.util.List;
*/
public interface SecurityManager {
/**
* auth entrance, put the subject in authentication and authorization process
* @param subject subject
* @return com.usthe.sureness.subject.Subject
* @throws BaseSurenessException sureness exception
*/
SubjectSum checkIn(Subject subject) throws BaseSurenessException;
/**
* auth entrance, put the request in authentication and authorization process
* @param var1 request
......
......@@ -57,17 +57,6 @@ public class SurenessSecurityManager implements SecurityManager {
}
}
@Override
public SubjectSum checkIn(Subject subject) throws BaseSurenessException {
// Determine whether the requested resource is a filtered resource
// if yes, pass directly
if (pathRoleMatcher.isExcludedResource(subject)) {
return null;
}
pathRoleMatcher.matchRole(subject);
return processorManager.process(subject);
}
@Override
public SubjectSum checkIn(Object var1) throws BaseSurenessException {
checkComponentInit();
......@@ -75,13 +64,27 @@ public class SurenessSecurityManager implements SecurityManager {
// Create a subject list to try auth one by one
List<Subject> subjectList = createSubject(var1);
RuntimeException lastException = new UnsupportedSubjectException("this request can not " +
"create subject by creators");
"create subject by creators,please config no subject creator by default");
// for the subject keys, try one by one
// if one success, pass and return directly
boolean noTryExcluded = true;
Subject preSubject = null;
for (Subject thisSubject : subjectList) {
try {
return checkIn(thisSubject);
// Determine whether the requested resource is a filtered resource
// if yes, pass directly
if (noTryExcluded && pathRoleMatcher.isExcludedResource(thisSubject)) {
return null;
}
noTryExcluded = false;
if (preSubject == null) {
pathRoleMatcher.matchRole(thisSubject);
preSubject = thisSubject;
} else {
thisSubject.setSupportRoles(preSubject.getSupportRoles());
}
return processorManager.process(thisSubject);
} catch (BaseSurenessException e) {
lastException = e;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册