根据sessionId构建Subject的两种方式

 

根据sessionId构建Subject的两种方式:

 

1:

Serializable sessionId = //get from the inbound request or remote method invocation payload

Subject requestSubject = new Subject.Builder().sessionId(sessionId).buildSubject();

 

 

 2:

SecurityManager securityManager = this.securityManager != null ? this.securityManager : SecurityUtils.getSecurityManager();

Subject.Builder builder = new Subject.Builder(securityManager);

builder.host(host);

builder.sessionId(sessionId);

Subject subject = builder.buildSubject();

 

return subject.execute(new Callable() {

public Object call() throws Exception {

   return SecureRemoteInvocationExecutor.super.invoke(invocation, targetObject);

}

});

 

你可能感兴趣的:(session)