当前位置: 首页>>代码示例>>Java>>正文


Java SecurityLogic类代码示例

本文整理汇总了Java中org.pac4j.core.engine.SecurityLogic的典型用法代码示例。如果您正苦于以下问题:Java SecurityLogic类的具体用法?Java SecurityLogic怎么用?Java SecurityLogic使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SecurityLogic类属于org.pac4j.core.engine包,在下文中一共展示了SecurityLogic类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: filter

import org.pac4j.core.engine.SecurityLogic; //导入依赖的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: shouldRethrowTechnicalException

import org.pac4j.core.engine.SecurityLogic; //导入依赖的package包/类
@Test(expected = TechnicalException.class)
public void shouldRethrowTechnicalException() throws Exception {
  String clients = "FormClient";
  String authorizers = null;
  String matchers = null;
  boolean multiProfile = false;
  String clientParameterName = Clients.DEFAULT_CLIENT_NAME_PARAMETER;
  Set<String> excludes = new HashSet<>();
  TechnicalException x = new TechnicalException("intentional err");
  new MockUnit(Request.class, Response.class, Config.class, WebContext.class, SecurityLogic.class,
      HttpActionAdapter.class, Route.Chain.class)
      .expect(webContext)
      .expect(getSecurityLogic)
      .expect(getActionAdapter)
      .expect(clientParameterName(clientParameterName, clients, clients))
      .expect(getSessionAttribute(Pac4jConstants.REQUESTED_URL, null))
      .expect(executeCallback(clients, authorizers, matchers, multiProfile, x))
      .run(unit -> {
        Pac4jSecurityFilter action = new Pac4jSecurityFilter(unit.get(Config.class), clients,
            authorizers, matchers, multiProfile, clientParameterName, excludes);

        action.handle(unit.get(Request.class), unit.get(Response.class),
            unit.get(Route.Chain.class));
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:26,代码来源:Pac4jSecurityFilterTest.java

示例3: shouldThrowJoobyErrWhenTechnicalExceptionWrapsIt

import org.pac4j.core.engine.SecurityLogic; //导入依赖的package包/类
@Test(expected = Err.class)
public void shouldThrowJoobyErrWhenTechnicalExceptionWrapsIt() throws Exception {
  String clients = "FormClient";
  String authorizers = null;
  String matchers = null;
  boolean multiProfile = false;
  String clientParameterName = Clients.DEFAULT_CLIENT_NAME_PARAMETER;
  Set<String> excludes = new HashSet<>();
  TechnicalException x = new TechnicalException(new Err(Status.UNAUTHORIZED, "intentional err"));
  new MockUnit(Request.class, Response.class, Config.class, WebContext.class, SecurityLogic.class,
      HttpActionAdapter.class, Route.Chain.class)
      .expect(webContext)
      .expect(getSecurityLogic)
      .expect(getActionAdapter)
      .expect(clientParameterName(clientParameterName, clients, clients))
      .expect(getSessionAttribute(Pac4jConstants.REQUESTED_URL, null))
      .expect(executeCallback(clients, authorizers, matchers, multiProfile, x))
      .run(unit -> {
        Pac4jSecurityFilter action = new Pac4jSecurityFilter(unit.get(Config.class), clients,
            authorizers, matchers, multiProfile, clientParameterName, excludes);

        action.handle(unit.get(Request.class), unit.get(Response.class),
            unit.get(Route.Chain.class));
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:26,代码来源:Pac4jSecurityFilterTest.java

示例4: setup

import org.pac4j.core.engine.SecurityLogic; //导入依赖的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

示例5: buildLogic

import org.pac4j.core.engine.SecurityLogic; //导入依赖的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

示例6: withSecurityLogic

import org.pac4j.core.engine.SecurityLogic; //导入依赖的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

示例7: shouldExecuteCallback

import org.pac4j.core.engine.SecurityLogic; //导入依赖的package包/类
@Test
public void shouldExecuteCallback() throws Exception {
  String clients = "FormClient";
  String authorizers = null;
  String matchers = null;
  String clientParameterName = Clients.DEFAULT_CLIENT_NAME_PARAMETER;
  Set<String> excludes = Sets.newHashSet("/profile");
  boolean multiProfile = false;
  new MockUnit(Request.class, Response.class, Config.class, WebContext.class, SecurityLogic.class,
      HttpActionAdapter.class, Route.Chain.class)
      .expect(webContext)
      .expect(getSecurityLogic)
      .expect(getActionAdapter)
      .expect(clientParameterName(clientParameterName, clients, clients))
      .expect(getSessionAttribute(Pac4jConstants.REQUESTED_URL, null))
      .expect(requestMatches("/profile", false))
      .expect(executeCallback(clients, authorizers, matchers, multiProfile))
      .run(unit -> {
        Pac4jSecurityFilter action = new Pac4jSecurityFilter(unit.get(Config.class), clients,
            authorizers, matchers, multiProfile, clientParameterName, excludes);

        assertEquals("FormClient", action.toString());

        action.handle(unit.get(Request.class), unit.get(Response.class),
            unit.get(Route.Chain.class));
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:28,代码来源:Pac4jSecurityFilterTest.java

示例8: shouldResetRequestedUrl

import org.pac4j.core.engine.SecurityLogic; //导入依赖的package包/类
@Test
public void shouldResetRequestedUrl() throws Exception {
  String clients = "FormClient";
  String authorizers = null;
  String matchers = null;
  String clientParameterName = Clients.DEFAULT_CLIENT_NAME_PARAMETER;
  Set<String> excludes = ImmutableSet.of("/**", "/facebook");
  boolean multiProfile = false;
  new MockUnit(Request.class, Response.class, Config.class, WebContext.class, SecurityLogic.class,
      HttpActionAdapter.class, Route.Chain.class, Session.class)
      .expect(webContext)
      .expect(getSecurityLogic)
      .expect(getActionAdapter)
      .expect(clientParameterName(clientParameterName, clients, clients))
      .expect(getSessionAttribute(Pac4jConstants.REQUESTED_URL, "/previous"))
      .expect(requestMatches("/facebook", true))
      .expect(executeCallback(clients, authorizers, matchers, multiProfile))
      .expect(ifSession(true))
      .expect(setSessionAttribute(Pac4jConstants.REQUESTED_URL, "/previous"))
      .run(unit -> {
        Pac4jSecurityFilter action = new Pac4jSecurityFilter(unit.get(Config.class), clients,
            authorizers, matchers, multiProfile, clientParameterName, excludes);

        assertEquals("FormClient", action.toString());

        action.handle(unit.get(Request.class), unit.get(Response.class),
            unit.get(Route.Chain.class));
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:30,代码来源:Pac4jSecurityFilterTest.java

示例9: shouldIgnoreResetRequestedUrlIfNoSession

import org.pac4j.core.engine.SecurityLogic; //导入依赖的package包/类
@Test
public void shouldIgnoreResetRequestedUrlIfNoSession() throws Exception {
  String clients = "FormClient";
  String authorizers = null;
  String matchers = null;
  String clientParameterName = Clients.DEFAULT_CLIENT_NAME_PARAMETER;
  Set<String> excludes = ImmutableSet.of("/**", "/facebook");
  boolean multiProfile = false;
  new MockUnit(Request.class, Response.class, Config.class, WebContext.class, SecurityLogic.class,
      HttpActionAdapter.class, Route.Chain.class, Session.class)
      .expect(webContext)
      .expect(getSecurityLogic)
      .expect(getActionAdapter)
      .expect(clientParameterName(clientParameterName, clients, clients))
      .expect(getSessionAttribute(Pac4jConstants.REQUESTED_URL, "/previous"))
      .expect(requestMatches("/facebook", true))
      .expect(executeCallback(clients, authorizers, matchers, multiProfile))
      .expect(ifSession(false))
      .run(unit -> {
        Pac4jSecurityFilter action = new Pac4jSecurityFilter(unit.get(Config.class), clients,
            authorizers, matchers, multiProfile, clientParameterName, excludes);

        assertEquals("FormClient", action.toString());

        action.handle(unit.get(Request.class), unit.get(Response.class),
            unit.get(Route.Chain.class));
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:29,代码来源:Pac4jSecurityFilterTest.java

示例10: shouldExecuteCallbackWithClients

import org.pac4j.core.engine.SecurityLogic; //导入依赖的package包/类
@Test
public void shouldExecuteCallbackWithClients() throws Exception {
  String clients = "FormClient";
  String authorizers = null;
  String matchers = null;
  boolean multiProfile = false;
  String clientParameterName = Clients.DEFAULT_CLIENT_NAME_PARAMETER;
  Set<String> excludes = new HashSet<>();
  new MockUnit(Request.class, Response.class, Config.class, WebContext.class, SecurityLogic.class,
      HttpActionAdapter.class, Route.Chain.class)
      .expect(webContext)
      .expect(getSecurityLogic)
      .expect(getActionAdapter)
      .expect(clientParameterName(clientParameterName, clients + ",FacebookClient",
          clients + ",FacebookClient"))
      .expect(getSessionAttribute(Pac4jConstants.REQUESTED_URL, null))
      .expect(executeCallback(clients + ",FacebookClient", authorizers, matchers, multiProfile))
      .run(unit -> {
        Pac4jSecurityFilter action = new Pac4jSecurityFilter(unit.get(Config.class), clients,
            authorizers, matchers, multiProfile, clientParameterName, excludes)
            .addClient("FacebookClient");

        assertEquals("FormClient,FacebookClient", action.toString());

        action.handle(unit.get(Request.class), unit.get(Response.class),
            unit.get(Route.Chain.class));
      });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:29,代码来源:Pac4jSecurityFilterTest.java

示例11: executeCallback

import org.pac4j.core.engine.SecurityLogic; //导入依赖的package包/类
private MockUnit.Block executeCallback(String defaultUrl, String logoutUrlPattern,
    String matchers, boolean multiProfile, Throwable x) {
  return unit -> {
    SecurityLogic action = unit.get(SecurityLogic.class);

    IExpectationSetters<Object> expect = expect(
        action.perform(eq(unit.get(WebContext.class)), eq(unit.get(Config.class)),
            isA(Pac4jGrantAccessAdapter.class), eq(unit.get(HttpActionAdapter.class)),
            eq(defaultUrl), eq(logoutUrlPattern), eq(matchers), eq(multiProfile)));
    if (x == null)
      expect.andReturn(null);
    else
      expect.andThrow(x);
  };
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:16,代码来源:Pac4jSecurityFilterTest.java

示例12: getSecurityLogic

import org.pac4j.core.engine.SecurityLogic; //导入依赖的package包/类
public SecurityLogic getSecurityLogic() {
    return securityLogic;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:4,代码来源:Config.java

示例13: setSecurityLogic

import org.pac4j.core.engine.SecurityLogic; //导入依赖的package包/类
public void setSecurityLogic(final SecurityLogic securityLogic) {
    this.securityLogic = securityLogic;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:4,代码来源:Config.java

示例14: getSecurityLogic

import org.pac4j.core.engine.SecurityLogic; //导入依赖的package包/类
@JsonProperty
public SecurityLogic getSecurityLogic() {
    return securityLogic;
}
 
开发者ID:pac4j,项目名称:dropwizard-pac4j,代码行数:5,代码来源:Pac4jFactory.java

示例15: getSecurityLogic

import org.pac4j.core.engine.SecurityLogic; //导入依赖的package包/类
public SecurityLogic<Object, JaxRsContext> getSecurityLogic() {
    return securityLogic;
}
 
开发者ID:pac4j,项目名称:jax-rs-pac4j,代码行数:4,代码来源:SecurityFilter.java


注:本文中的org.pac4j.core.engine.SecurityLogic类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。