本文整理汇总了Java中org.pac4j.core.authorization.authorizer.Authorizer类的典型用法代码示例。如果您正苦于以下问题:Java Authorizer类的具体用法?Java Authorizer怎么用?Java Authorizer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Authorizer类属于org.pac4j.core.authorization.authorizer包,在下文中一共展示了Authorizer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: clientInternal
import org.pac4j.core.authorization.authorizer.Authorizer; //导入依赖的package包/类
private <C extends Credentials, U extends CommonProfile> Pac4j clientInternal(String pattern,
Function<Config, Client<C, U>> provider, Authorizer<U> authorizer) {
clients.add((conf, binder) -> {
Client<C, U> client = provider.apply(conf);
String authorizerName = null;
if (authorizer != null) {
authorizerName = authorizerName(authorizer);
pac4j.addAuthorizer(authorizerName, authorizer);
}
Pac4jClientType.profileTypes(Pac4jClientType.clientType(client.getClass()), profile -> {
if (profileTypes.add(profile)) {
binder
.bind(profile)
.toProvider(Providers.outOfScope(profile))
.in(RequestScoped.class);
}
});
return new ClientConfig(pattern, authorizerName, client);
});
return this;
}
开发者ID:jooby-project,项目名称:jooby,代码行数:22,代码来源:Pac4j.java
示例2: guiceAuthorizers
import org.pac4j.core.authorization.authorizer.Authorizer; //导入依赖的package包/类
private MockUnit.Block guiceAuthorizers(Class<? extends Authorizer>... authorizers) {
return unit -> {
Map<String, Authorizer> hash = Arrays.asList(authorizers).stream()
.map(it -> unit.get(it))
.collect(Collectors.toMap(it -> it.getClass().getSimpleName(), Function.identity()));
org.pac4j.core.config.Config pac4j = unit.get(org.pac4j.core.config.Config.class);
expect(pac4j.getAuthorizers()).andReturn(hash);
Env env = unit.get(Env.class);
expect(env.onStart(unit.capture(Throwing.Consumer.class))).andReturn(env);
hash.values().stream()
.filter(Pac4jAuthorizer.class::isInstance)
.map(Pac4jAuthorizer.class::cast)
.forEach(it -> expect(it.setRegistry(unit.get(Registry.class))).andReturn(it));
};
}
开发者ID:jooby-project,项目名称:jooby,代码行数:17,代码来源:Pac4jTest.java
示例3: testOneExistingAuthorizerProfileMatch
import org.pac4j.core.authorization.authorizer.Authorizer; //导入依赖的package包/类
@Test
public void testOneExistingAuthorizerProfileMatch() throws HttpAction {
profile.setId(VALUE);
final Map<String, Authorizer> authorizers = new HashMap<>();
authorizers.put(NAME, new IdAuthorizer());
assertTrue(checker.isAuthorized(null, profiles, NAME, authorizers));
}
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:8,代码来源:DefaultAuthorizationCheckerTests.java
示例4: testTwoExistingAuthorizerProfileMatch
import org.pac4j.core.authorization.authorizer.Authorizer; //导入依赖的package包/类
@Test
public void testTwoExistingAuthorizerProfileMatch() throws HttpAction {
profile.setId(VALUE);
profile.addRole(ROLE);
final Map<String, Authorizer> authorizers = new HashMap<>();
authorizers.put(NAME, new IdAuthorizer());
authorizers.put(VALUE, new RequireAnyRoleAuthorizer(ROLE));
assertTrue(checker.isAuthorized(null, profiles, NAME + Pac4jConstants.ELEMENT_SEPRATOR + VALUE, authorizers));
}
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:10,代码来源:DefaultAuthorizationCheckerTests.java
示例5: testTwoExistingAuthorizerProfileDoesNotMatch
import org.pac4j.core.authorization.authorizer.Authorizer; //导入依赖的package包/类
@Test
public void testTwoExistingAuthorizerProfileDoesNotMatch() throws HttpAction {
profile.addRole(ROLE);
final Map<String, Authorizer> authorizers = new HashMap<>();
authorizers.put(NAME, new IdAuthorizer());
authorizers.put(VALUE, new RequireAnyRoleAuthorizer(ROLE));
assertFalse(checker.isAuthorized(null, profiles, NAME + Pac4jConstants.ELEMENT_SEPRATOR + VALUE, authorizers));
}
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:9,代码来源:DefaultAuthorizationCheckerTests.java
示例6: testOneExistingAuthorizerProfileMatch2
import org.pac4j.core.authorization.authorizer.Authorizer; //导入依赖的package包/类
@Test
public void testOneExistingAuthorizerProfileMatch2() throws HttpAction {
profile.setId(VALUE);
final List<Authorizer> authorizers = new ArrayList<>();
authorizers.add(new IdAuthorizer());
assertTrue(checker.isAuthorized(null, profiles, authorizers));
}
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:8,代码来源:DefaultAuthorizationCheckerTests.java
示例7: testTwoExistingAuthorizerProfileMatch2
import org.pac4j.core.authorization.authorizer.Authorizer; //导入依赖的package包/类
@Test
public void testTwoExistingAuthorizerProfileMatch2() throws HttpAction {
profile.setId(VALUE);
profile.addRole(ROLE);
final List<Authorizer> authorizers = new ArrayList<>();
authorizers.add(new IdAuthorizer());
authorizers.add(new RequireAnyRoleAuthorizer(ROLE));
assertTrue(checker.isAuthorized(null, profiles, authorizers));
}
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:10,代码来源:DefaultAuthorizationCheckerTests.java
示例8: testTwoExistingAuthorizerProfileDoesNotMatch2
import org.pac4j.core.authorization.authorizer.Authorizer; //导入依赖的package包/类
@Test
public void testTwoExistingAuthorizerProfileDoesNotMatch2() throws HttpAction {
profile.addRole(ROLE);
final List<Authorizer> authorizers = new ArrayList<>();
authorizers.add(new IdAuthorizer());
authorizers.add(new RequireAnyRoleAuthorizer(ROLE));
assertFalse(checker.isAuthorized(null, profiles, authorizers));
}
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:9,代码来源:DefaultAuthorizationCheckerTests.java
示例9: setup
import org.pac4j.core.authorization.authorizer.Authorizer; //导入依赖的package包/类
@Override
public void setup(Bootstrap<?> bootstrap) {
ObjectMapper om = bootstrap.getObjectMapper();
// for Config
om.addMixIn(SessionStore.class, sessionStoreMixin());
om.addMixIn(Authorizer.class, authorizerMixin());
om.addMixIn(HttpActionAdapter.class, httpActionAdapterMixin());
om.addMixIn(Matcher.class, matcherMixin());
om.addMixIn(SecurityLogic.class, securityLogicMixin());
om.addMixIn(CallbackLogic.class, callbackLogicMixin());
om.addMixIn(LogoutLogic.class, logoutLogicMixin());
// for Clients
om.addMixIn(Client.class, clientMixin());
om.addMixIn(BaseClient.class, baseClientMixin());
// for Clients and Client subsclasses
om.addMixIn(AjaxRequestResolver.class, ajaxRequestResolverMixin());
om.addMixIn(UrlResolver.class, urlResolverMixin());
om.addMixIn(AuthorizationGenerator.class,
authorizationGeneratorMixin());
// for Client/BaseClient
om.addMixIn(Authenticator.class, authenticatorMixin());
om.addMixIn(CredentialsExtractor.class, credentialExtractorMixin());
om.addMixIn(ProfileCreator.class, profileCreatorMixin());
// for IndirectClient
om.addMixIn(RedirectActionBuilder.class, redirectActionBuilderMixin());
om.addMixIn(LogoutActionBuilder.class, logoutActionBuilderMixin());
// for some of the Authenticators
om.addMixIn(PasswordEncoder.class, passwordEncoderMixin());
}
开发者ID:pac4j,项目名称:dropwizard-pac4j,代码行数:36,代码来源:DefaultFeatureSupport.java
示例10: handle
import org.pac4j.core.authorization.authorizer.Authorizer; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Override
public void handle(final Request req, final Response rsp) throws Exception {
CommonProfile user = req.require(CommonProfile.class);
Config config = req.require(Config.class);
WebContext ctx = req.require(WebContext.class);
AuthorizationChecker authorizationChecker = req.require(AuthorizationChecker.class);
Map<String, Authorizer> authorizers = config.getAuthorizers();
log.debug("checking access for: {}", user);
if (!authorizationChecker.isAuthorized(ctx, Arrays.asList(user), this.authorizer, authorizers)) {
log.debug("forbidden: {}", user);
throw new Err(Status.FORBIDDEN);
}
log.debug("authorized: {}", user);
}
开发者ID:jooby-project,项目名称:jooby,代码行数:16,代码来源:AuthorizerFilter.java
示例11: ConfigProvider
import org.pac4j.core.authorization.authorizer.Authorizer; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
@Inject
public ConfigProvider(final Clients clients, final Map<String, Authorizer> authorizers) {
config = new Config(clients);
for (Entry<String, Authorizer> entry : authorizers.entrySet()) {
config.addAuthorizer(entry.getKey(), entry.getValue());
}
}
开发者ID:jooby-project,项目名称:jooby,代码行数:9,代码来源:ConfigProvider.java
示例12: requireAnyRoleAuthorizer
import org.pac4j.core.authorization.authorizer.Authorizer; //导入依赖的package包/类
@Bean
public Authorizer requireAnyRoleAuthorizer() {
return new RequireAnyRoleAuthorizer(casProperties.getMgmt().getAdminRoles());
}
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:5,代码来源:CasManagementWebAppConfiguration.java
示例13: addSingleAuthorizerToConfig
import org.pac4j.core.authorization.authorizer.Authorizer; //导入依赖的package包/类
private void addSingleAuthorizerToConfig(Authorizer<WebContext, CommonProfile> syncAuthorizer) {
final Map<String, AsyncAuthorizer<CommonProfile>> authorizersMap = new HashMap<>();
authorizersMap.put(NAME, AsyncAuthorizer.fromNonBlockingAuthorizer(syncAuthorizer));
when(config.getAuthorizers()).thenReturn(authorizersMap);
}
开发者ID:millross,项目名称:pac4j-async,代码行数:6,代码来源:DefaultAsyncSecurityLogicTest.java
示例14: Config
import org.pac4j.core.authorization.authorizer.Authorizer; //导入依赖的package包/类
public Config(final Map<String, Authorizer> authorizers) {
setAuthorizers(authorizers);
}
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:4,代码来源:Config.java
示例15: getAuthorizers
import org.pac4j.core.authorization.authorizer.Authorizer; //导入依赖的package包/类
public Map<String, Authorizer> getAuthorizers() {
return authorizers;
}
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:4,代码来源:Config.java
示例16: setAuthorizer
import org.pac4j.core.authorization.authorizer.Authorizer; //导入依赖的package包/类
public void setAuthorizer(final Authorizer authorizer) {
CommonHelper.assertNotNull("authorizer", authorizer);
this.authorizers.put(authorizer.getClass().getSimpleName(), authorizer);
}
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:5,代码来源:Config.java
示例17: setAuthorizers
import org.pac4j.core.authorization.authorizer.Authorizer; //导入依赖的package包/类
public void setAuthorizers(final Map<String, Authorizer> authorizers) {
CommonHelper.assertNotNull("authorizers", authorizers);
this.authorizers = authorizers;
}
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:5,代码来源:Config.java
示例18: addAuthorizer
import org.pac4j.core.authorization.authorizer.Authorizer; //导入依赖的package包/类
public void addAuthorizer(final String name, final Authorizer authorizer) {
authorizers.put(name, authorizer);
}
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:4,代码来源:Config.java
示例19: internalTestOneExistingAuthorizerProfileDoesNotMatch
import org.pac4j.core.authorization.authorizer.Authorizer; //导入依赖的package包/类
private void internalTestOneExistingAuthorizerProfileDoesNotMatch(final String name) throws HttpAction {
final Map<String, Authorizer> authorizers = new HashMap<>();
authorizers.put(NAME, new IdAuthorizer());
assertFalse(checker.isAuthorized(null, profiles, name, authorizers));
}
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:6,代码来源:DefaultAuthorizationCheckerTests.java
示例20: testOneAuthorizerDoesNotExist
import org.pac4j.core.authorization.authorizer.Authorizer; //导入依赖的package包/类
@Test(expected = TechnicalException.class)
public void testOneAuthorizerDoesNotExist() throws HttpAction {
final Map<String, Authorizer> authorizers = new HashMap<>();
authorizers.put(NAME, new IdAuthorizer());
checker.isAuthorized(null, profiles, VALUE, authorizers);
}
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:7,代码来源:DefaultAuthorizationCheckerTests.java
注:本文中的org.pac4j.core.authorization.authorizer.Authorizer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论