本文整理汇总了Java中org.pac4j.core.engine.DefaultSecurityLogic类的典型用法代码示例。如果您正苦于以下问题:Java DefaultSecurityLogic类的具体用法?Java DefaultSecurityLogic怎么用?Java DefaultSecurityLogic使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DefaultSecurityLogic类属于org.pac4j.core.engine包,在下文中一共展示了DefaultSecurityLogic类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: filter
import org.pac4j.core.engine.DefaultSecurityLogic; //导入依赖的package包/类
@Override
protected void filter(JaxRsContext context) throws IOException {
Config config = getConfig();
String cs;
// no client was set
if (clients == null && config instanceof JaxRsConfig) {
cs = ((JaxRsConfig) config).getDefaultClients();
} else {
cs = clients;
}
// Note: basically, there is two possible outcomes:
// either the access is granted or there was an error or a redirect!
// For the former, we do nothing (see SecurityGrantedAccessOutcome comments)
// For the later, we interpret the error and abort the request using jax-rs abstractions
SecurityLogic<Object, JaxRsContext> logic = buildLogic(config);
AuthorizationCheckerWrapper wrapper = null;
if (logic instanceof DefaultSecurityLogic) {
wrapper = new AuthorizationCheckerWrapper(((DefaultSecurityLogic) logic).getAuthorizationChecker());
((DefaultSecurityLogic) logic).setAuthorizationChecker(wrapper);
}
logic.perform(context, config, new SecurityGrantedAccessOutcome(wrapper), adapter(config), cs, authorizers,
matchers, multiProfile);
}
开发者ID:pac4j,项目名称:jax-rs-pac4j,代码行数:27,代码来源:SecurityFilter.java
示例2: SecurityHandler
import org.pac4j.core.engine.DefaultSecurityLogic; //导入依赖的package包/类
public SecurityHandler(final Vertx vertx,
final SessionStore<VertxWebContext> sessionStore,
final Config config, final Pac4jAuthProvider authProvider,
final SecurityHandlerOptions options) {
super(authProvider);
CommonHelper.assertNotNull("vertx", vertx);
CommonHelper.assertNotNull("sessionStore", sessionStore);
CommonHelper.assertNotNull("config", config);
CommonHelper.assertNotNull("config.getClients()", config.getClients());
CommonHelper.assertNotNull("authProvider", authProvider);
CommonHelper.assertNotNull("options", options);
clientNames = options.getClients();
authorizerName = options.getAuthorizers();
matcherName = options.getMatchers();
multiProfile = options.isMultiProfile();
this.vertx = vertx;
this.sessionStore = sessionStore;
this.config = config;
final DefaultSecurityLogic<Void, VertxWebContext> securityLogic = new DefaultSecurityLogic<>();
securityLogic.setProfileManagerFactory(VertxProfileManager::new);
this.securityLogic = securityLogic;
}
开发者ID:pac4j,项目名称:vertx-pac4j,代码行数:25,代码来源:SecurityHandler.java
示例3: buildLogic
import org.pac4j.core.engine.DefaultSecurityLogic; //导入依赖的package包/类
protected SecurityLogic<Object, JaxRsContext> buildLogic(Config config) {
if (securityLogic != null) {
return securityLogic;
} else if (config.getSecurityLogic() != null) {
return config.getSecurityLogic();
} else {
DefaultSecurityLogic<Object, JaxRsContext> logic = new DefaultSecurityLogic<>();
logic.setProfileManagerFactory(JaxRsProfileManager::new);
return logic;
}
}
开发者ID:pac4j,项目名称:jax-rs-pac4j,代码行数:12,代码来源:SecurityFilter.java
示例4: withSecurityLogic
import org.pac4j.core.engine.DefaultSecurityLogic; //导入依赖的package包/类
@Test
public void withSecurityLogic() throws Exception {
Config config = config("/");
SecurityLogic action = new DefaultSecurityLogic();
new MockUnit(Env.class, Binder.class, Router.class, WebContext.class, Registry.class,
Function.class)
.expect(newLoginFormClient())
.expect(newClients("http://localhost:8080/callback"))
.expect(pac4jConfig)
.expect(sessionStore(null))
.expect(profile(CommonProfile.class))
.expect(profile(UserProfile.class))
.expect(router)
.expect(setClients(FormClient.class))
.expect(webContext)
.expect(profileManager)
.expect(profileManagerFactory(null))
.expect(loginForm("/callback"))
.expect(callback(null, "/", "/callback", false, false))
.expect(
securityLogic(action, "/**", null, null, false, Clients.DEFAULT_CLIENT_NAME_PARAMETER,
ImmutableSet.of("/callback", "/**"), FormClient.class))
.expect(logoutLogic(null, "/", "/.*", true, true, false))
.expect(guiceAuthorizers())
.expect(setupGuiceAuthorizers())
.run(unit -> {
new Pac4j()
.doWith(pac4j -> {
pac4j.setSecurityLogic(action);
})
.configure(unit.get(Env.class), config, unit.get(Binder.class));
}, setupGuiceAuthorizers());
}
开发者ID:jooby-project,项目名称:jooby,代码行数:34,代码来源:Pac4jTest.java
示例5: securityLogic
import org.pac4j.core.engine.DefaultSecurityLogic; //导入依赖的package包/类
private MockUnit.Block securityLogic(SecurityLogic action, String pattern, String authorizers,
String matchers, boolean multiProfile, String clientName, Set<String> excludes,
Class<? extends Client>... clientTypes) {
return unit -> {
List<Client> clientList = Arrays.asList(clientTypes).stream()
.map(type -> unit.get(type))
.collect(Collectors.toList());
clientList.forEach(client -> {
expect(client.getName()).andReturn(client.getClass().getSuperclass().getSimpleName());
});
org.pac4j.core.config.Config config = unit.get(org.pac4j.core.config.Config.class);
expect(config.getSecurityLogic()).andReturn(action);
if (action != null) {
config.setSecurityLogic(action);
}
if (action == null) {
DefaultSecurityLogic logic = unit.constructor(DefaultSecurityLogic.class)
.build();
unit.registerMock(SecurityLogic.class, logic);
config.setSecurityLogic(logic);
}
Router router = unit.get(Router.class);
List<String> clients = clientList.stream()
.map(it -> it.getClass().getSuperclass().getSimpleName())
.collect(Collectors.toList());
Pac4jSecurityFilter filter = unit.constructor(Pac4jSecurityFilter.class)
.args(org.pac4j.core.config.Config.class, String.class, String.class, String.class,
boolean.class, String.class, Set.class)
.build(unit.get(org.pac4j.core.config.Config.class), clients.get(0), authorizers,
matchers, multiProfile, clientName, excludes);
clients.stream().skip(1)
.forEach(it -> {
expect(filter.addClient(it)).andReturn(filter);
});
Route.Definition route = unit.mock(Route.Definition.class);
expect(route.name("pac4j(" + filter + ")")).andReturn(route);
expect(route.excludes(Arrays.asList("/favicon.ico", "/callback"))).andReturn(route);
expect(router.use("*", pattern, filter)).andReturn(route);
};
}
开发者ID:jooby-project,项目名称:jooby,代码行数:50,代码来源:Pac4jTest.java
注:本文中的org.pac4j.core.engine.DefaultSecurityLogic类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论