• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Pac4jConstants类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: validate

import org.pac4j.core.context.Pac4jConstants; //导入依赖的package包/类
@Override
public void validate(final UsernamePasswordCredentials credentials, final WebContext context) throws HttpAction {
    if (credentials == null) {
        throwsException("No credential");
    }
    String username = credentials.getUsername();
    String password = credentials.getPassword();
    if (CommonHelper.isBlank(username)) {
        throwsException("Username cannot be blank");
    }
    if (CommonHelper.isBlank(password)) {
        throwsException("Password cannot be blank");
    }
    if (CommonHelper.areNotEquals(username, password)) {
        throwsException("Username : '" + username + "' does not match password");
    }
    final CommonProfile profile = new CommonProfile();
    profile.setId(username);
    profile.addAttribute(Pac4jConstants.USERNAME, username);
    credentials.setUserProfile(profile);
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:22,代码来源:SimpleTestUsernamePasswordAuthenticator.java


示例2: matches

import org.pac4j.core.context.Pac4jConstants; //导入依赖的package包/类
@Override
public CompletableFuture<Boolean> matches(AsyncWebContext context, String matcherNames, Map<String, AsyncMatcher> matchersMap) {

    // if we have a matcher name (which may be a list of matchers names)
    if (CommonHelper.isNotBlank(matcherNames)) {

        // we must have matchers
        CommonHelper.assertNotNull("matchersMap", matchersMap);
        final String[] names = matcherNames.split(Pac4jConstants.ELEMENT_SEPRATOR);

        final List<AsyncMatcher> matchers = Arrays.stream(names)
                .map(n -> matchersMap.entrySet().stream()
                        .filter(e -> CommonHelper.areEqualsIgnoreCaseAndTrim(e.getKey(), n))
                        .peek(e -> CommonHelper.assertNotNull("matchersMap['" + n + "']", e))
                        .findFirst().map(e -> e.getValue()).orElse(null))
                .collect(Collectors.toList());

        return shortCircuitedFuture(matchers.stream()
                    .map(m -> () -> m.matches(context)), false);
    }

    return CompletableFuture.completedFuture(true);
}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:24,代码来源:DefaultAsyncMatchingChecker.java


示例3: DefaultAsyncLogoutLogic

import org.pac4j.core.context.Pac4jConstants; //导入依赖的package包/类
public DefaultAsyncLogoutLogic(final AsyncConfig<R, U, WC> config,
                               final HttpActionAdapter<R, WC> httpActionAdapter,
                               final String defaultUrl,
                               final String logoutUrlPattern,
                               boolean localLogout,
                               boolean destroySession,
                               boolean centralLogout) {

    assertNotNull("config", config);
    assertNotNull("clients", config.getClients());
    assertNotNull("httpActionAdapter", httpActionAdapter);
    this.logoutUrlPattern = Optional.ofNullable(logoutUrlPattern).orElse(DEFAULT_LOGOUT_URL_PATTERN_VALUE);
    assertNotBlank(Pac4jConstants.LOGOUT_URL_PATTERN, this.logoutUrlPattern);

    this.config = config;
    this.httpActionAdapter = httpActionAdapter;
    this.defaultUrl = defaultUrl;
    sessionDestructionStrategy = getSessionDestructionStrategy(destroySession);
    this.localLogoutStrategy = getLocalLogoutStrategy(localLogout);
    this.centralLogoutStrategy = getCentralLogoutStrategy(centralLogout);

}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:23,代码来源:DefaultAsyncLogoutLogic.java


示例4: perform

import org.pac4j.core.context.Pac4jConstants; //导入依赖的package包/类
@Override
public CompletableFuture<R> perform(WC context) {
    assertNotNull("context", context);

    // compute redirection URL
    final String url = context.getRequestParameter(Pac4jConstants.URL);
    final String redirectUrl = (url != null && Pattern.matches(logoutUrlPattern, url)) ? url : defaultUrl;

    logger.debug("redirectUrl: {}", redirectUrl);

    final AsyncProfileManager manager = getProfileManager(context, config);

    final CompletableFuture<List<? extends U>> loggedOutProfilesFuture = localLogoutStrategy.logout(manager, sessionDestructionStrategy, context);

    return loggedOutProfilesFuture.thenApply(profiles -> centralLogoutStrategy.getCentralLogoutAction(config.getClients(),
            profiles,
            redirectUrl,
            context))
            .thenApply(o -> o.map(s -> s.get())
                    .orElseGet(() -> redirectUrl == null ? ok("ok", context) : redirect("redirect", context, redirectUrl)))
            .thenApply(action -> httpActionAdapter.adapt(action.getCode(), context));

}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:24,代码来源:DefaultAsyncLogoutLogic.java


示例5: testCallback

import org.pac4j.core.context.Pac4jConstants; //导入依赖的package包/类
@Test
public void testCallback(final TestContext testContext) throws Exception {
    final TestProfile expectedProfile = TestProfile.from(TEST_CREDENTIALS);
    when(webContext.getRequestParameter(Clients.DEFAULT_CLIENT_NAME_PARAMETER)).thenReturn(NAME);
    final Clients<AsyncClient<? extends Credentials, ? extends TestProfile>, AsyncAuthorizationGenerator<TestProfile>> clients = clientsWithOneIndirectClient();
    when(config.getClients()).thenReturn(clients);
    asyncCallbackLogic = new DefaultAsyncCallbackLogic<>(false, false, config, httpActionAdapter);
    final Async async = testContext.async();
    final CompletableFuture<Object> future = asyncCallbackLogic.perform(webContext, null);
    final CompletableFuture<Map<String, TestProfile>> profilesFuture = future.thenAccept(o -> {
        assertThat(o, is(nullValue()));
        assertThat(status.get(), is(302));
        assertThat(responseHeaders.get(LOCATION_HEADER), is(Pac4jConstants.DEFAULT_URL_VALUE));
        verify(sessionStore, never()).renewSession(any(AsyncWebContext.class));
    }).thenCompose((Void v) ->  webContext.getSessionStore().get(webContext, Pac4jConstants.USER_PROFILES));

    assertSuccessfulEvaluation(profilesFuture, profiles -> {
        assertThat(profiles.containsValue(expectedProfile), is(true));
        assertThat(profiles.size(), is(1));
    }, async);

}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:23,代码来源:DefaultAsyncCallbackLogicTest.java


示例6: assertSuccessfulLoginWithProfiles

import org.pac4j.core.context.Pac4jConstants; //导入依赖的package包/类
private CompletableFuture<Void> assertSuccessfulLoginWithProfiles(final CompletableFuture<Object> future,
                                                                  final Async async,
                                                                  final TestProfile ... expectedProfiles) {
    return assertSuccessfulEvaluation(future, ExceptionSoftener.softenConsumer(o -> {
        assertThat(o, is(nullValue()));
        assertThat(status.get(), is(-1));

        verify(accessGrantedAdapter, times(1)).adapt(webContext);
        final LinkedHashMap<String, TestProfile> profiles = (LinkedHashMap<String, TestProfile>) webContext.getRequestAttribute(Pac4jConstants.USER_PROFILES);
        assertThat(profiles.size(), is(profiles.size()));
        Arrays.stream(expectedProfiles).forEach(profile -> {
            assertThat(profiles.values(), hasItem(profile));
        });

    }), async);

}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:18,代码来源:DefaultAsyncSecurityLogicTest.java


示例7: indirectClientAvailable

import org.pac4j.core.context.Pac4jConstants; //导入依赖的package包/类
@Test(timeout = 2000)
public void indirectClientAvailable(final TestContext testContext) {

    final Map<String, String> responseHeaders = new HashMap<>();
    final AsyncWebContext context = MockAsyncWebContextBuilder.from(rule.vertx(), asynchronousComputationAdapter)
            .withRecordedResponseHeaders(responseHeaders)
            .build();
    final List<AsyncClient<? extends Credentials, CommonProfile>> clients = Arrays.asList(getIndirectClient());
    final Async async = testContext.async();
    authInitiator.initiateIndirectFlow(context, clients)
            .whenComplete((a, t) -> {
                assertThat(t, is(nullValue()));
                assertThat(a, is(notNullValue()));
                assertThat(a.getCode(), is(HttpConstants.TEMP_REDIRECT));
                assertThat(responseHeaders.get(HttpConstants.LOCATION_HEADER), is(AUTH_REDIRECT_URL));
            })
            // Now validate session is as we expect
            .thenCompose(v -> context.getSessionStore().get(context, Pac4jConstants.REQUESTED_URL))
            .whenComplete((v, t) -> {
                assertThat(t, is(nullValue()));
                assertThat(v, is(MockAsyncWebContextBuilder.DEFAULT_FULL_REQUEST_URL));
                async.complete();
            });

}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:26,代码来源:AsyncIndirectAuthenticationInitiatorTest.java


示例8: testCentralLogout

import org.pac4j.core.context.Pac4jConstants; //导入依赖的package包/类
@Test
public void testCentralLogout(final TestContext testContext) {
    final Map<String, TestProfile> profiles = new HashMap<>();
    final TestProfile profile = TestProfile.from(TEST_CREDENTIALS);
    profile.setClientName(NAME);
    profiles.put(NAME, profile);
    final AsyncClient<TestCredentials, TestProfile> client = indirectClient(NAME, CALLBACK_URL,
            targetUrl -> RedirectAction.redirect(CALLBACK_URL + "?p=" + targetUrl));

    final Clients<AsyncClient<? extends Credentials, ? extends TestProfile>, AsyncAuthorizationGenerator<TestProfile>> clients = new Clients<>(client);
    when(config.getClients()).thenReturn(clients);
    asyncLogoutLogic = new DefaultAsyncLogoutLogic<>(config, httpActionAdapter, null, ".*", true, false, true);
    when(webContext.getRequestParameter(eq(Pac4jConstants.URL))).thenReturn(CALLBACK_URL);
    final Async async = testContext.async();
    final CompletableFuture<Object> resultFuture = addProfilesToContext(profiles)
            .thenCompose(v -> asyncLogoutLogic.perform(webContext));

    assertSuccessfulEvaluation(assertProfilesCount(resultFuture, 0), o -> {
        assertThat(buffer.toString(), is(""));
        assertThat(status.get(), is(302));
        assertThat(responseHeaders.get(HttpConstants.LOCATION_HEADER), is(CALLBACK_URL + "?p=" + CALLBACK_URL));
    }, async);
}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:24,代码来源:DefaultAsyncLogoutLogicTest.java


示例9: testCentralLogoutWithRelativeUrl

import org.pac4j.core.context.Pac4jConstants; //导入依赖的package包/类
@Test
public void testCentralLogoutWithRelativeUrl(final TestContext testContext) {
    final Map<String, TestProfile> profiles = new HashMap<>();
    final TestProfile profile = TestProfile.from(TEST_CREDENTIALS);
    profile.setClientName(NAME);
    profiles.put(NAME, profile);
    final AsyncClient<TestCredentials, TestProfile> client = indirectClient(NAME, PAC4J_BASE_URL, targetUrl -> RedirectAction.redirect(CALLBACK_URL + "?p=" + targetUrl));

    final Clients<AsyncClient<? extends Credentials, ? extends TestProfile>, AsyncAuthorizationGenerator<TestProfile>> clients = new Clients<>(client);
    when(config.getClients()).thenReturn(clients);
    asyncLogoutLogic = new DefaultAsyncLogoutLogic<>(config, httpActionAdapter, null, ".*", true, false, true);
    when(webContext.getRequestParameter(eq(Pac4jConstants.URL))).thenReturn(PATH);
    final Async async = testContext.async();
    final CompletableFuture<Object> resultFuture = addProfilesToContext(profiles)
            .thenCompose(v -> asyncLogoutLogic.perform(webContext));

    assertSuccessfulEvaluation(assertProfilesCount(resultFuture, 0), o -> {
        assertThat(buffer.toString(), is(""));
        assertThat(status.get(), is(302));
        assertThat(responseHeaders.get(HttpConstants.LOCATION_HEADER), is(CALLBACK_URL + "?p=null"));
    }, async);

}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:24,代码来源:DefaultAsyncLogoutLogicTest.java


示例10: testLogoutWithGoodUrl

import org.pac4j.core.context.Pac4jConstants; //导入依赖的package包/类
@Test
public void testLogoutWithGoodUrl(final TestContext testContext) {
    final Map<String, TestProfile> profiles = new HashMap<>();
    profiles.put(NAME, TestProfile.from(TEST_CREDENTIALS));
    final Clients<AsyncClient<? extends Credentials, ? extends TestProfile>, AsyncAuthorizationGenerator<TestProfile>> clients = new Clients<>();
    when(config.getClients()).thenReturn(clients);
    when(webContext.getRequestParameter(eq(Pac4jConstants.URL))).thenReturn(PATH);

    final Async async = testContext.async();
    asyncLogoutLogic = new DefaultAsyncLogoutLogic<>(config, httpActionAdapter, CALLBACK_URL, null, true, false, false);
    final CompletableFuture<Object> resultFuture = addProfilesToContext(profiles)
            .thenCompose(v -> asyncLogoutLogic.perform(webContext));

    assertSuccessfulEvaluation(assertProfilesCount(resultFuture, 0), o -> {
        assertThat(buffer.toString(), is(""));
        assertThat(status.get(), is(302));
        assertThat(responseHeaders.get(HttpConstants.LOCATION_HEADER), is(PATH));
    }, async);
}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:20,代码来源:DefaultAsyncLogoutLogicTest.java


示例11: testLogoutWithBadUrlNoDefaultUrl

import org.pac4j.core.context.Pac4jConstants; //导入依赖的package包/类
@Test
public void testLogoutWithBadUrlNoDefaultUrl(final TestContext testContext) {
    final Map<String, TestProfile> profiles = new HashMap<>();
    profiles.put(NAME, TestProfile.from(TEST_CREDENTIALS));
    final Clients<AsyncClient<? extends Credentials, ? extends TestProfile>, AsyncAuthorizationGenerator<TestProfile>> clients = new Clients<>();
    when(config.getClients()).thenReturn(clients);
    when(webContext.getRequestParameter(eq(Pac4jConstants.URL))).thenReturn(PATH);

    final Async async = testContext.async();
    asyncLogoutLogic = new DefaultAsyncLogoutLogic<>(config, httpActionAdapter, null, VALUE, true, false, false);
    final CompletableFuture<Object> resultFuture = addProfilesToContext(profiles)
            .thenCompose(v -> asyncLogoutLogic.perform(webContext));

    assertSuccessfulEvaluation(assertProfilesCount(resultFuture, 0), o -> {
        assertThat(buffer.toString(), is(""));
        assertThat(status.get(), is(200));
    }, async);

}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:20,代码来源:DefaultAsyncLogoutLogicTest.java


示例12: testLogoutWithBadUrlButDefaultUrl

import org.pac4j.core.context.Pac4jConstants; //导入依赖的package包/类
@Test
public void testLogoutWithBadUrlButDefaultUrl(final TestContext testContext) {
    final Map<String, TestProfile> profiles = new HashMap<>();
    profiles.put(NAME, TestProfile.from(TEST_CREDENTIALS));
    final Clients<AsyncClient<? extends Credentials, ? extends TestProfile>, AsyncAuthorizationGenerator<TestProfile>> clients = new Clients<>();
    when(config.getClients()).thenReturn(clients);
    when(webContext.getRequestParameter(eq(Pac4jConstants.URL))).thenReturn(PATH);

    final Async async = testContext.async();
    asyncLogoutLogic = new DefaultAsyncLogoutLogic<>(config, httpActionAdapter, CALLBACK_URL, VALUE, true, false, false);
    final CompletableFuture<Object> resultFuture = addProfilesToContext(profiles)
            .thenCompose(v -> asyncLogoutLogic.perform(webContext));

    assertSuccessfulEvaluation(assertProfilesCount(resultFuture, 0), o -> {
        assertThat(buffer.toString(), is(""));
        assertThat(status.get(), is(302));
        assertThat(responseHeaders.get(HttpConstants.LOCATION_HEADER), is(CALLBACK_URL));
    }, async);

}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:21,代码来源:DefaultAsyncLogoutLogicTest.java


示例13: retrieveAll

import org.pac4j.core.context.Pac4jConstants; //导入依赖的package包/类
/**
 * Retrieve the map of profiles from the session or the request.
 *
 * @param readFromSession if the user profiles must be read from session
 * @return the map of profiles
 */
protected LinkedHashMap<String, U> retrieveAll(final boolean readFromSession) {
    final LinkedHashMap<String, U> profiles = new LinkedHashMap<>();
    final Object request = this.context.getRequestAttribute(Pac4jConstants.USER_PROFILES);
    if (request != null) {
        if  (request instanceof LinkedHashMap) {
            profiles.putAll((LinkedHashMap<String, U>) request);
        }
        if (request instanceof CommonProfile) {
            profiles.put(retrieveClientName((U) request), (U) request);
        }
    }
    if (readFromSession) {
        final Object sessionAttribute = this.context.getSessionAttribute(Pac4jConstants.USER_PROFILES);
        if  (sessionAttribute instanceof LinkedHashMap) {
            profiles.putAll((LinkedHashMap<String, U>) sessionAttribute);
        }
        if (sessionAttribute instanceof CommonProfile) {
            profiles.put(retrieveClientName((U) sessionAttribute), (U) sessionAttribute);
        }
    }
    return profiles;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:29,代码来源:ProfileManager.java


示例14: save

import org.pac4j.core.context.Pac4jConstants; //导入依赖的package包/类
/**
 * Save the given user profile (replace the current one if multi profiles are not supported, add it otherwise).
 *
 * @param saveInSession if the user profile must be saved in session
 * @param profile a given user profile
 * @param multiProfile whether multiple profiles are supported
 */
public void save(final boolean saveInSession, final U profile, final boolean multiProfile) {
    final LinkedHashMap<String, U> profiles;

    final String clientName = retrieveClientName(profile);
    if (multiProfile) {
        profiles = retrieveAll(saveInSession);
        profiles.remove(clientName);
    } else {
        profiles = new LinkedHashMap<>();
    }
    profiles.put(clientName, profile);

    if (saveInSession) {
        this.context.setSessionAttribute(Pac4jConstants.USER_PROFILES, profiles);
    }
    this.context.setRequestAttribute(Pac4jConstants.USER_PROFILES, profiles);
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:25,代码来源:ProfileManager.java


示例15: isAuthorized

import org.pac4j.core.context.Pac4jConstants; //导入依赖的package包/类
@Override
public boolean isAuthorized(final WebContext context, final List<CommonProfile> profiles) throws HttpAction {
    CommonHelper.assertNotNull("csrfTokenGenerator", csrfTokenGenerator);
    final String token = csrfTokenGenerator.get(context);
    context.setRequestAttribute(Pac4jConstants.CSRF_TOKEN, token);
    final Cookie cookie = new Cookie(Pac4jConstants.CSRF_TOKEN, token);
    if (domain != null) {
        cookie.setDomain(domain);
    } else {
        cookie.setDomain(context.getServerName());
    }
    if (path != null) {
        cookie.setPath(path);
    }
    if (httpOnly != null) {
        cookie.setHttpOnly(httpOnly.booleanValue());
    }
    if (secure != null) {
        cookie.setSecure(secure.booleanValue());
    }
    context.addResponseCookie(cookie);
    return true;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:24,代码来源:CsrfTokenGeneratorAuthorizer.java


示例16: testDoubleDirectClient

import org.pac4j.core.context.Pac4jConstants; //导入依赖的package包/类
@Test
public void testDoubleDirectClient() throws Exception {
    final CommonProfile profile = new CommonProfile();
    profile.setId(NAME);
    final CommonProfile profile2 = new CommonProfile();
    profile2.setId(VALUE);
    final DirectClient directClient = new MockDirectClient(NAME, new MockCredentials(), profile);
    final DirectClient directClient2 = new MockDirectClient(VALUE, new MockCredentials(), profile2);
    config.setClients(new Clients(CALLBACK_URL, directClient, directClient2));
    clients = NAME + "," + VALUE;
    call();
    assertEquals(-1, context.getResponseStatus());
    assertEquals(1, nbCall);
    final LinkedHashMap<String, CommonProfile> profiles = (LinkedHashMap<String, CommonProfile>) context.getRequestAttribute(Pac4jConstants.USER_PROFILES);
    assertEquals(1, profiles.size());
    assertTrue(profiles.containsValue(profile));
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:18,代码来源:DefaultSecurityLogicTests.java


示例17: testDoubleDirectClientSupportingMultiProfile

import org.pac4j.core.context.Pac4jConstants; //导入依赖的package包/类
@Test
public void testDoubleDirectClientSupportingMultiProfile() throws Exception {
    final CommonProfile profile = new CommonProfile();
    profile.setId(NAME);
    final CommonProfile profile2 = new CommonProfile();
    profile2.setId(VALUE);
    final DirectClient directClient = new MockDirectClient(NAME, new MockCredentials(), profile);
    final DirectClient directClient2 = new MockDirectClient(VALUE, new MockCredentials(), profile2);
    config.setClients(new Clients(CALLBACK_URL, directClient, directClient2));
    clients = NAME + "," + VALUE;
    multiProfile = true;
    call();
    assertEquals(-1, context.getResponseStatus());
    assertEquals(1, nbCall);
    final LinkedHashMap<String, CommonProfile> profiles = (LinkedHashMap<String, CommonProfile>) context.getRequestAttribute(Pac4jConstants.USER_PROFILES);
    assertEquals(2, profiles.size());
    assertTrue(profiles.containsValue(profile));
    assertTrue(profiles.containsValue(profile2));
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:20,代码来源:DefaultSecurityLogicTests.java


示例18: testDoubleDirectClientChooseDirectClient

import org.pac4j.core.context.Pac4jConstants; //导入依赖的package包/类
@Test
public void testDoubleDirectClientChooseDirectClient() throws Exception {
    final CommonProfile profile = new CommonProfile();
    profile.setId(NAME);
    final CommonProfile profile2 = new CommonProfile();
    profile2.setId(VALUE);
    final DirectClient directClient = new MockDirectClient(NAME, new MockCredentials(), profile);
    final DirectClient directClient2 = new MockDirectClient(VALUE, new MockCredentials(), profile2);
    config.setClients(new Clients(CALLBACK_URL, directClient, directClient2));
    clients = NAME + "," + VALUE;
    context.addRequestParameter(Clients.DEFAULT_CLIENT_NAME_PARAMETER, VALUE);
    multiProfile = true;
    call();
    assertEquals(-1, context.getResponseStatus());
    assertEquals(1, nbCall);
    final LinkedHashMap<String, CommonProfile> profiles = (LinkedHashMap<String, CommonProfile>) context.getRequestAttribute(Pac4jConstants.USER_PROFILES);
    assertEquals(1, profiles.size());
    assertTrue(profiles.containsValue(profile2));
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:20,代码来源:DefaultSecurityLogicTests.java


示例19: testCallback

import org.pac4j.core.context.Pac4jConstants; //导入依赖的package包/类
@Test
public void testCallback() throws Exception {
    final String originalSessionId = request.getSession().getId();
    request.setParameter(Clients.DEFAULT_CLIENT_NAME_PARAMETER, NAME);
    final CommonProfile profile = new CommonProfile();
    final IndirectClient indirectClient = new MockIndirectClient(NAME, null, new MockCredentials(), profile);
    config.setClients(new Clients(CALLBACK_URL, indirectClient));
    call();
    final HttpSession session = request.getSession();
    final String newSessionId = session.getId();
    final LinkedHashMap<String, CommonProfile> profiles = (LinkedHashMap<String, CommonProfile>) session.getAttribute(Pac4jConstants.USER_PROFILES);
    assertTrue(profiles.containsValue(profile));
    assertEquals(1, profiles.size());
    assertNotEquals(newSessionId, originalSessionId);
    assertEquals(302, response.getStatus());
    assertEquals(Pac4jConstants.DEFAULT_URL_VALUE, response.getRedirectedUrl());
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:18,代码来源:J2ERenewSessionCallbackLogicTests.java


示例20: testCallbackWithOriginallyRequestedUrl

import org.pac4j.core.context.Pac4jConstants; //导入依赖的package包/类
@Test
public void testCallbackWithOriginallyRequestedUrl() throws Exception {
    HttpSession session = request.getSession();
    final String originalSessionId = session.getId();
    session.setAttribute(Pac4jConstants.REQUESTED_URL, PAC4J_URL);
    request.setParameter(Clients.DEFAULT_CLIENT_NAME_PARAMETER, NAME);
    final CommonProfile profile = new CommonProfile();
    final IndirectClient indirectClient = new MockIndirectClient(NAME, null, new MockCredentials(), profile);
    config.setClients(new Clients(CALLBACK_URL, indirectClient));
    call();
    session = request.getSession();
    final String newSessionId = session.getId();
    final LinkedHashMap<String, CommonProfile> profiles = (LinkedHashMap<String, CommonProfile>) session.getAttribute(Pac4jConstants.USER_PROFILES);
    assertTrue(profiles.containsValue(profile));
    assertEquals(1, profiles.size());
    assertNotEquals(newSessionId, originalSessionId);
    assertEquals(302, response.getStatus());
    assertEquals(PAC4J_URL, response.getRedirectedUrl());
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:20,代码来源:J2ERenewSessionCallbackLogicTests.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TicketCreationException类代码示例发布时间:2022-05-23
下一篇:
Java PatternFilterable类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap