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

Java HttpAction类代码示例

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

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



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

示例1: isAuthorized

import org.pac4j.core.exception.HttpAction; //导入依赖的package包/类
@Override
public boolean isAuthorized(final WebContext context, final List<CommonProfile> profiles) throws HttpAction {
    final String url = context.getFullRequestURL().toLowerCase();
    if (!url.endsWith(".css")
            && !url.endsWith(".js")
            && !url.endsWith(".png")
            && !url.endsWith(".jpg")
            && !url.endsWith(".ico")
            && !url.endsWith(".jpeg")
            && !url.endsWith(".bmp")
            && !url.endsWith(".gif")) {
        context.setResponseHeader("Cache-Control", "no-cache, no-store, max-age=0, must-revalidate");
        context.setResponseHeader("Pragma", "no-cache");
        context.setResponseHeader("Expires", "0");
    }
    return true;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:18,代码来源:CacheControlHeader.java


示例2: getUserProfile

import org.pac4j.core.exception.HttpAction; //导入依赖的package包/类
@Override
public final U getUserProfile(final C credentials, final WebContext context) throws HttpAction {
    init(context);
    logger.debug("credentials : {}", credentials);
    if (credentials == null) {
        return null;
    }

    final U profile = retrieveUserProfile(credentials, context);
    if (profile != null) {
        profile.setClientName(getName());
        if (this.authorizationGenerators != null) {
            for (AuthorizationGenerator<U> authorizationGenerator : this.authorizationGenerators) {
                authorizationGenerator.generate(profile);
            }
        }
    }
    return profile;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:20,代码来源:BaseClient.java


示例3: testOk

import org.pac4j.core.exception.HttpAction; //导入依赖的package包/类
@Test
public void testOk() throws HttpAction {
    final OAuth10Credentials credentials = (OAuth10Credentials) getClient()
            .getCredentials(MockWebContext
                    .create()
                    .addRequestParameter(BaseOAuth10Client.OAUTH_VERIFIER, VERIFIER)
                    .addRequestParameter(BaseOAuth10Client.OAUTH_TOKEN, TOKEN)
                    .addSessionAttribute(getClient().getName() + "#" + BaseOAuth10Client.REQUEST_TOKEN,
                            new OAuth1RequestToken(TOKEN, SECRET)));
    assertNotNull(credentials);
    assertEquals(TOKEN, credentials.getToken());
    assertEquals(VERIFIER, credentials.getVerifier());
    final OAuth1RequestToken tokenRequest = (OAuth1RequestToken) credentials.getRequestToken();
    assertEquals(TOKEN, tokenRequest.getToken());
    assertEquals(SECRET, tokenRequest.getTokenSecret());
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:17,代码来源:BaseOAuth10ClientTests.java


示例4: computeRedirectionToServerIfNecessary

import org.pac4j.core.exception.HttpAction; //导入依赖的package包/类
private void computeRedirectionToServerIfNecessary(final WebContext context) throws HttpAction {
    final String relayStateValue = context.getRequestParameter(CasConfiguration.RELAY_STATE_PARAMETER);
    // if we have a state value -> redirect to the CAS server to continue the logout process
    if (CommonUtils.isNotBlank(relayStateValue)) {
        final StringBuilder buffer = new StringBuilder();
        buffer.append(configuration.getPrefixUrl());
        if (!configuration.getPrefixUrl().endsWith("/")) {
            buffer.append("/");
        }
        buffer.append("logout?_eventId=next&");
        buffer.append(CasConfiguration.RELAY_STATE_PARAMETER);
        buffer.append("=");
        buffer.append(CommonUtils.urlEncode(relayStateValue));
        final String redirectUrl = buffer.toString();
        logger.debug("Redirection url to the CAS server: {}", redirectUrl);
        throw HttpAction.redirect("Force redirect to CAS server for front channel logout", context, redirectUrl);
    }
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:19,代码来源:TicketAndLogoutRequestExtractor.java


示例5: testFullAuthentication

import org.pac4j.core.exception.HttpAction; //导入依赖的package包/类
@Test
public void testFullAuthentication() throws HttpAction {
    // luminous-smoke1
    final StormpathAuthenticator authenticator = new StormpathAuthenticator("77NW47MHGJV5DA8R5UA5YORE0",
            "nPCDRYPPxhBNpq1HT9Gr85hB7fCACQXSHx0aCuG6D/Q", "2MahZGmC0Rcl7gYkVIea94");

    final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials("leleuj", "Pac4jtest", CLIENT_NAME);
    authenticator.validate(credentials, null);
    final StormpathProfile profile = (StormpathProfile) credentials.getUserProfile();
    assertNotNull(profile);

    assertEquals("leleuj", profile.getId());
    assertEquals("LELEU", profile.getFamilyName());
    assertEquals("Jerome", profile.getFirstName());
    assertEquals("Jr", profile.getMiddleName());
    final GroupList groups = profile.getGroups();
    assertEquals("https://api.stormpath.com/v1/accounts/33t9mYagXIJyddNMZV5489/groups", groups.getHref());
    final GroupMembershipList groupMemberships = profile.getGroupMemberships();
    assertEquals("https://api.stormpath.com/v1/accounts/33t9mYagXIJyddNMZV5489/groupMemberships", groupMemberships.getHref());
    assertEquals("[email protected]", profile.getEmail());
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:22,代码来源:StormpathAuthenticatorIT.java


示例6: extractUserProfile

import org.pac4j.core.exception.HttpAction; //导入依赖的package包/类
@Override
protected FoursquareProfile extractUserProfile(String body) throws HttpAction {
    FoursquareProfile profile = new FoursquareProfile();
    JsonNode json = JsonHelper.getFirstNode(body);
    if (json == null) {
        return profile;
    }
    JsonNode response = (JsonNode) JsonHelper.getElement(json, "response");
    if (response == null) {
        return profile;
    }
    JsonNode user = (JsonNode) JsonHelper.getElement(response, "user");
    if (user != null) {
        profile.setId(JsonHelper.getElement(user, "id"));

        for (final String attribute : profile.getAttributesDefinition().getPrimaryAttributes()) {
            profile.addAttribute(attribute, JsonHelper.getElement(user, attribute));
        }
    }
    return profile;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:22,代码来源:FoursquareClient.java


示例7: retrieveCredentials

import org.pac4j.core.exception.HttpAction; //导入依赖的package包/类
/**
 * Retrieve the credentials.
 *
 * @param context the web context
 * @return the credentials
 * @throws HttpAction whether an additional HTTP action is required
 */
protected CompletableFuture<C> retrieveCredentials(final AsyncWebContext context) throws HttpAction {
    return this.credentialsExtractor.extract(context)
            .thenCompose(creds -> {
                return Optional.ofNullable(creds)
                        .map(c -> this.authenticator.validate(creds, context).thenApply(v -> creds))
                        .orElse(CompletableFuture.completedFuture(creds)); // The orElse leaves any null returns
            })
            // Now translate a CredentialsException to null
            .handle(ExceptionSoftener.softenBiFunction((creds, throwable) -> {
                // throwable being non-null means creds will be null, so we can make this check here
                logger.info("In handle call");
                if (throwable == null || throwable instanceof CredentialsException) {
                    return creds;
                } else {
                    throw throwable;
                }
            }));
}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:26,代码来源:AsyncBaseClient.java


示例8: retrieveRedirectAction

import org.pac4j.core.exception.HttpAction; //导入依赖的package包/类
@Override
protected RedirectAction retrieveRedirectAction(final WebContext wc) throws HttpAction {
    final SAML2MessageContext context = this.contextProvider.buildContext(wc);
    final String relayState = getStateParameter(wc);

    final AuthnRequest authnRequest = this.saml2ObjectBuilder.build(context);
    this.profileHandler.send(context, authnRequest, relayState);

    final Pac4jSAMLResponse adapter = context.getProfileRequestContextOutboundMessageTransportResponse();
    if (this.configuration.getDestinationBindingType().equalsIgnoreCase(SAMLConstants.SAML2_POST_BINDING_URI)) {
        final String content = adapter.getOutgoingContent();
        return RedirectAction.success(content);
    }
    final String location = adapter.getRedirectUrl();
    return RedirectAction.redirect(location);

}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:18,代码来源:SAML2Client.java


示例9: firstProfileNoResultSecondProfileResult

import org.pac4j.core.exception.HttpAction; //导入依赖的package包/类
@Test
public void firstProfileNoResultSecondProfileResult() {
    when(firstProfile.getClientName()).thenReturn("client1");
    when(secondProfile.getClientName()).thenReturn("client1");
    when(clients.findClient(eq("client1"))).thenReturn(client);
    when(client.getLogoutAction(any(AsyncWebContext.class), eq(firstProfile), anyString())).thenReturn(null);
    when(client.getLogoutAction(any(AsyncWebContext.class), eq(secondProfile), anyString())).thenReturn(RedirectAction.redirect(LOGOUT_URL_2));

    final HttpAction centralLogoutAction = CENTRAL_LOGOUT.getCentralLogoutAction(clients, Arrays.asList(firstProfile, secondProfile), null, webContext)
            .map(o -> o.get())
            .orElse(null);
    assertThat(centralLogoutAction, is(notNullValue()));
    assertThat(centralLogoutAction.getCode(), is(HttpConstants.TEMP_REDIRECT));
    assertThat(status.get(), is(HttpConstants.TEMP_REDIRECT));
    assertThat(responseHeaders.get(HttpConstants.LOCATION_HEADER), is(LOGOUT_URL_2));
}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:17,代码来源:AsyncCentralLogoutTest.java


示例10: testReturnNewProfile

import org.pac4j.core.exception.HttpAction; //导入依赖的package包/类
@Test
public void testReturnNewProfile() throws HttpAction {
    final CommonProfile profile = new CommonProfile();
    profile.setId(ID);
    profile.addAttribute(KEY, VALUE);
    profile.setRemembered(false);
    profile.addRole(NAME);
    profile.addPermission(VALUE);
    profile.setClientName(CLIENT_NAME);
    final Credentials credentials = new TokenCredentials(TOKEN, CLIENT_NAME);
    credentials.setUserProfile(profile);
    final AuthenticatorProfileCreator creator = new AuthenticatorProfileCreator();
    creator.setProfileFactory(MyCommonProfile::new);
    final CommonProfile profile2 = creator.create(credentials, null);
    assertTrue(profile2 instanceof MyCommonProfile);
    assertEquals(profile.getId(), profile2.getId());
    assertEquals(profile.getAttributes(), profile2.getAttributes());
    assertEquals(profile.getRoles(), profile2.getRoles());
    assertEquals(profile.getPermissions(), profile2.getPermissions());
    assertEquals(profile.isRemembered(), profile2.isRemembered());
    assertEquals(profile.getClientName(), profile2.getClientName());
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:23,代码来源:AuthenticatorProfileCreatorTests.java


示例11: validate

import org.pac4j.core.exception.HttpAction; //导入依赖的package包/类
@Override
public void validate(final T credentials, final WebContext context) throws HttpAction {
    init(context);

    try {
        final CommonProfile profile = this.cache.get(credentials, () -> {
            logger.debug("Delegating authentication to {}...", delegate);
            delegate.validate(credentials, context);
            return credentials.getUserProfile();
        });
        credentials.setUserProfile(profile);
        logger.debug("Found cached credential. Using cached profile {}...", profile);
    } catch (Exception e) {
        throw new CredentialsException(e);
    }

}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:18,代码来源:LocalCachingAuthenticator.java


示例12: testPlainJwtWithSignatureConfigurations

import org.pac4j.core.exception.HttpAction; //导入依赖的package包/类
@Test(expected = CredentialsException.class)
public void testPlainJwtWithSignatureConfigurations() throws HttpAction {
    final JwtGenerator<FacebookProfile> generator = new JwtGenerator<>();
    final FacebookProfile profile = createProfile();
    final String token = generator.generate(profile);
    assertToken(profile, token);
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:8,代码来源:JwtTests.java


示例13: retrieveUserProfile

import org.pac4j.core.exception.HttpAction; //导入依赖的package包/类
@Override
protected GaeUserServiceProfile retrieveUserProfile(GaeUserCredentials credentials, WebContext context) throws HttpAction {
	User user = credentials.getUser();
	if (user != null) {
		GaeUserServiceProfile gaeUserProfile = new GaeUserServiceProfile();
		gaeUserProfile.setId(user.getEmail());
		gaeUserProfile.addAttribute(GaeUserServiceAttributesDefinition.EMAIL, user.getEmail());
		gaeUserProfile.addAttribute(GaeUserServiceAttributesDefinition.DISPLAYNAME, user.getNickname());
		if (service.isUserAdmin()) {
			gaeUserProfile.addRole(GaeUserServiceProfile.PAC4J_GAE_GLOBAL_ADMIN_ROLE);
		}
		return gaeUserProfile;
	}
	return null;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:16,代码来源:GaeUserServiceClient.java


示例14: testNoCode

import org.pac4j.core.exception.HttpAction; //导入依赖的package包/类
@Test
public void testNoCode() throws HttpAction {
    try {
        getClient().getCredentials(MockWebContext.create());
        fail("should not get credentials");
    } catch (final TechnicalException e) {
        assertEquals("No credential found", e.getMessage());
    }
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:10,代码来源:BaseOAuth20ClientTests.java


示例15: testGetCredentialsMissingSemiColon

import org.pac4j.core.exception.HttpAction; //导入依赖的package包/类
@Test
public void testGetCredentialsMissingSemiColon() throws HttpAction, UnsupportedEncodingException {
    final IndirectBasicAuthClient basicAuthClient = getBasicAuthClient();
    final MockWebContext context = getContextWithAuthorizationHeader(
            "Basic " + Base64.getEncoder().encodeToString("fake".getBytes(HttpConstants.UTF8_ENCODING)));
    verifyGetCredentialsFailsWithAuthenticationRequired(basicAuthClient, context);
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:8,代码来源:IndirectBasicAuthClientTests.java


示例16: matches

import org.pac4j.core.exception.HttpAction; //导入依赖的package包/类
@Override
public boolean matches(final WebContext context) throws HttpAction {
    CommonHelper.assertNotNull("methods", methods);
    final String requestMethod = context.getRequestMethod();

    for (final HTTP_METHOD method : methods) {
        if (method.name().equalsIgnoreCase(requestMethod)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:13,代码来源:HttpMethodMatcher.java


示例17: testAuthentication

import org.pac4j.core.exception.HttpAction; //导入依赖的package包/类
@Test
public void testAuthentication() throws HttpAction, UnsupportedEncodingException {
    final DirectBasicAuthClient client = new DirectBasicAuthClient(new SimpleTestUsernamePasswordAuthenticator());
    final MockWebContext context = MockWebContext.create();
    final String header = USERNAME + ":" + USERNAME;
    context.addRequestHeader(HttpConstants.AUTHORIZATION_HEADER,
            "Basic " + Base64.getEncoder().encodeToString(header.getBytes(HttpConstants.UTF8_ENCODING)));
    final UsernamePasswordCredentials credentials = client.getCredentials(context);
    final CommonProfile profile = client.getUserProfile(credentials, context);
    assertEquals(USERNAME, profile.getId());
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:12,代码来源:DirectBasicAuthClientTests.java


示例18: testTwoExistingAuthorizerProfileDoesNotMatch

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


示例19: testReturnProfile

import org.pac4j.core.exception.HttpAction; //导入依赖的package包/类
@Test
public void testReturnProfile() throws HttpAction {
    final CommonProfile profile = new CommonProfile();
    final Credentials credentials = new TokenCredentials(TOKEN, CLIENT_NAME);
    credentials.setUserProfile(profile);
    final CommonProfile profile2 = AuthenticatorProfileCreator.INSTANCE.create(credentials, null);
    assertEquals(profile, profile2);
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:9,代码来源:AuthenticatorProfileCreatorTests.java


示例20: extractUserProfile

import org.pac4j.core.exception.HttpAction; //导入依赖的package包/类
@Override
protected QQProfile extractUserProfile(final String body) throws HttpAction {
    final QQProfile profile = new QQProfile();
    final JsonNode json = JsonHelper.getFirstNode(body);
    if (json != null) {
        profile.setId(JsonHelper.getElement(json, "id"));
        for (final String attribute : profile.getAttributesDefinition().getPrimaryAttributes()) {
            profile.addAttribute(attribute, JsonHelper.getElement(json, attribute));
        }
    }
    return profile;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:13,代码来源:QQClient.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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