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


Java CommonProfile类代码示例

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


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

示例1: validate

import org.pac4j.core.profile.CommonProfile; //导入依赖的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: verifyProfile

import org.pac4j.core.profile.CommonProfile; //导入依赖的package包/类
@Override
protected void verifyProfile(final CommonProfile userProfile) {
    final OidcProfile profile = (OidcProfile) userProfile;
    assertEquals("90342.ASDFJWFA", profile.getId());
    assertEquals(OidcProfile.class.getName() + CommonProfile.SEPARATOR + "90342.ASDFJWFA",
            profile.getTypedId());
    assertNotNull(profile.getAccessToken());
    assertNotNull(profile.getIdToken());
    assertTrue(ProfileHelper.isTypedIdOf(profile.getTypedId(), OidcProfile.class));
    assertNotNull(profile.getIdTokenString());
    assertCommonProfile(profile, "[email protected]", null, null, "Demo Admin", "admin",
            Gender.UNSPECIFIED, null, null, null, null);
    assertTrue((Boolean) profile.getAttribute("email_verified"));
    assertEquals("https://mitreid.org/", profile.getIssuer());
    assertEquals("acdf79d7-0129-4ba3-bc61-a52486cf82ff", profile.getAudience().get(0));
    assertNotNull(profile.getAuthTime());
    assertNotNull(profile.getExpirationDate());
    assertNotNull(profile.getIssuedAt());
    assertNotNull(profile.getAttribute("jti"));
    assertEquals(13, profile.getAttributes().size());
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:22,代码来源:RunMitreIdOrg.java

示例3: testDoubleDirectClientSupportingMultiProfile

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

示例4: generateAuthorizationForLdapEntry

import org.pac4j.core.profile.CommonProfile; //导入依赖的package包/类
@Override
protected CommonProfile generateAuthorizationForLdapEntry(final CommonProfile profile, final LdapEntry userEntry) {
    try {
        LOGGER.debug("Attempting to get roles for user [{}].", userEntry.getDn());
        final Response<SearchResult> response = this.groupSearchExecutor.search(
                this.connectionFactory,
                Beans.newLdaptiveSearchFilter(this.groupSearchExecutor.getSearchFilter().getFilter(),
                        Beans.LDAP_SEARCH_FILTER_DEFAULT_PARAM_NAME, Arrays.asList(userEntry.getDn())));
        LOGGER.debug("LDAP role search response: [{}]", response);
        final SearchResult groupResult = response.getResult();

        for (final LdapEntry entry : groupResult.getEntries()) {
            final LdapAttribute groupAttribute = entry.getAttribute(this.groupAttributeName);
            if (groupAttribute == null) {
                LOGGER.warn("Role attribute not found on entry [{}]", entry);
                continue;
            }
            addProfileRolesFromAttributes(profile, groupAttribute, this.groupPrefix);
        }
    } catch (final LdapException e) {
        throw new RuntimeException("LDAP error fetching roles for user.", e);
    }
    return profile;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:25,代码来源:LdapUserGroupsToRolesAuthorizationGenerator.java

示例5: testCallbackNoRenew

import org.pac4j.core.profile.CommonProfile; //导入依赖的package包/类
@Test
public void testCallbackNoRenew() 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));
    renewSession = false;
    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());
    assertEquals(newSessionId, originalSessionId);
    assertEquals(302, response.getStatus());
    assertEquals(Pac4jConstants.DEFAULT_URL_VALUE, response.getRedirectedUrl());
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:19,代码来源:J2ERenewSessionCallbackLogicTests.java

示例6: testRolePermissionChangeSplit

import org.pac4j.core.profile.CommonProfile; //导入依赖的package包/类
@Test
public void testRolePermissionChangeSplit() {
    final String[] roleAttributes = new String[] {
        ATTRIB1
    };
    final String[] permissionAttributes = new String[] {
        ATTRIB2
    };
    final FromAttributesAuthorizationGenerator<CommonProfile> generator = new FromAttributesAuthorizationGenerator<CommonProfile>(
                                                                                                                                  roleAttributes,
                                                                                                                                  permissionAttributes);
    generator.setSplitChar("|");
    generator.generate(this.profile);
    final Set<String> roles = this.profile.getRoles();
    assertEquals(1, roles.size());
    assertTrue(roles.contains(VALUE1));
    final Set<String> permissions = this.profile.getPermissions();
    assertEquals(1, permissions.size());
    assertTrue(permissions.contains(VALUE2));
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:21,代码来源:FromAttributesAuthorizationGeneratorTests.java

示例7: testAuthentication

import org.pac4j.core.profile.CommonProfile; //导入依赖的package包/类
@Test
public void testAuthentication() throws HttpAction {
    final DirectDigestAuthClient client = new DirectDigestAuthClient(new SimpleTestDigestAuthenticator());
    client.setRealm(REALM);
    final MockWebContext context = MockWebContext.create();
    context.addRequestHeader(HttpConstants.AUTHORIZATION_HEADER,
            DIGEST_AUTHORIZATION_HEADER_VALUE);
    context.setRequestMethod("GET");

    final DigestCredentials credentials = client.getCredentials(context);

    final CommonProfile profile = client.getUserProfile(credentials, context);

    String ha1 = CredentialUtil.encryptMD5(USERNAME + ":" + REALM + ":" +PASSWORD);
    String serverDigest1 = credentials.calculateServerDigest(true, ha1);
    String serverDigest2 = credentials.calculateServerDigest(false, PASSWORD);
    assertEquals(DIGEST_RESPONSE, serverDigest1);
    assertEquals(DIGEST_RESPONSE, serverDigest2);
    assertEquals(USERNAME, profile.getId());
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:21,代码来源:DirectDigestAuthClientTests.java

示例8: getSafe

import org.pac4j.core.profile.CommonProfile; //导入依赖的package包/类
/**
 * Gets template from TemplateEngine that is at least instance of BaseTemplate.
 * Sets parameters to template that are available to all subclasses of BaseTemplate.
 *
 * @param ctx      to use
 * @param fileName to load
 * @param type     of template to load
 * @return template of specified type
 */
private <S extends BaseTemplate> S getSafe(RoutingContext ctx, String fileName, Class<S> type) {
  S base = engine.getSafeTemplate(ctx.getDelegate(), fileName, type);
  base.setLang(ctx.getCookie(LANGUAGE) != null ? ctx.getCookie(LANGUAGE).getValue() :
      ENGLISH.getLocale().getLanguage());
  base.setLogoutUrl(addParameter(AUTH_LOGOUT, URL, UI_LOGIN));
  base.setLoginPage(UI_LOGIN);
  base.setHomePage(UI_HOME);
  base.setMoviesPage(UI_MOVIES);
  base.setSeriesPage(UI_SERIES);
  base.setHistoryPage(UI_HISTORY);
  base.setStatisticsPage(UI_STATISTICS);
  base.setDiscoverPage(UI_DISCOVER);
  base.setListsPage(UI_LISTS);
  CommonProfile profile = getProfile(ctx, securityConfig);
  if (profile != null) {
    base.setUserName(profile.getFirstName() + " " + profile.getFamilyName());
    base.setUserFirstName(profile.getFirstName());
  }
  return base;
}
 
开发者ID:kristenkotkas,项目名称:moviediary,代码行数:30,代码来源:UiRouter.java

示例9: testDoubleDirectClient

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

示例10: VertxAsyncLogoutHandler

import org.pac4j.core.profile.CommonProfile; //导入依赖的package包/类
public VertxAsyncLogoutHandler(final Vertx vertx,
                               final Context context,
                               final AsyncConfig<Void, CommonProfile, VertxAsyncWebContext> config,
                               final LogoutHandlerOptions options) {
    DefaultAsyncLogoutLogic<Void, CommonProfile, VertxAsyncWebContext> defaultApplicationLogoutLogic = new DefaultAsyncLogoutLogic<>(config,
            httpActionAdapter,
            options.getDefaultUrl(),
            options.getLogoutUrlPattern(),
            options.isLocalLogout(),
            options.isDestroySession(),
            options.isCentralLogout());
    defaultApplicationLogoutLogic.setProfileManagerFactory(c -> new VertxAsyncProfileManager(c));
    this.logoutLogic = defaultApplicationLogoutLogic;
    this.config = config;
    this.asynchronousComputationAdapter = new VertxAsynchronousComputationAdapter(vertx, context);
}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:17,代码来源:VertxAsyncLogoutHandler.java

示例11: testDoubleDirectClientChooseBadDirectClient

import org.pac4j.core.profile.CommonProfile; //导入依赖的package包/类
@Test
public void testDoubleDirectClientChooseBadDirectClient(final TestContext testContext) throws Exception {
    final Clients<AsyncClient<? extends Credentials, ? extends CommonProfile>, AsyncAuthorizationGenerator<CommonProfile>> clients = doubleDirectClients();
    when(config.getClients()).thenReturn(clients);
    final String clientNames = NAME;
    when(webContext.getRequestParameter(eq(Clients.DEFAULT_CLIENT_NAME_PARAMETER))).thenReturn(VALUE);
    asyncSecurityLogic = new DefaultAsyncSecurityLogic<>(true, true, config, httpActionAdapter);
    final Async async = testContext.async();

    exception.expect(CompletionException.class);
    exception.expectCause(allOf(IsInstanceOf.instanceOf(TechnicalException.class),
            hasProperty("message", is("Client not allowed: " + VALUE))));
    final CompletableFuture<Object> result = asyncSecurityLogic.perform(webContext, accessGrantedAdapter, clientNames, null, null);
    assertSuccessfulEvaluation(result, ExceptionSoftener.softenConsumer(o -> {
        assertThat(o, is(nullValue()));
        verify(accessGrantedAdapter, times(0)).adapt(webContext);
    }), async);

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

示例12: verifyProfile

import org.pac4j.core.profile.CommonProfile; //导入依赖的package包/类
@Override
protected void verifyProfile(CommonProfile userProfile) {
    final Google2Profile profile = (Google2Profile) userProfile;
    assertEquals("113675986756217860428", profile.getId());
    assertEquals(Google2Profile.class.getName() + CommonProfile.SEPARATOR + "113675986756217860428",
            profile.getTypedId());
    assertTrue(ProfileHelper.isTypedIdOf(profile.getTypedId(), Google2Profile.class));
    assertTrue(CommonHelper.isNotBlank(profile.getAccessToken()));
    assertCommonProfile(userProfile, "[email protected]", "Jérôme", "ScribeUP", "Jérôme ScribeUP", null,
            Gender.MALE, Locale.ENGLISH,
            "https://lh4.googleusercontent.com/-fFUNeYqT6bk/AAAAAAAAAAI/AAAAAAAAAAA/5gBL6csVWio/photo.jpg",
            "https://plus.google.com/113675986756217860428", null);
    assertNull(profile.getBirthday());
    assertTrue(profile.getEmails() != null && profile.getEmails().size() == 1);
    assertEquals(9, profile.getAttributes().size());
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:17,代码来源:RunGoogle2Client.java

示例13: testDoubleDirectClientChooseDirectClient

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

示例14: validate

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

示例15: verifyProfile

import org.pac4j.core.profile.CommonProfile; //导入依赖的package包/类
@Override
protected void verifyProfile(final CommonProfile userProfile) {
    final OidcProfile profile = (OidcProfile) userProfile;
    assertEquals("00u5h0czw1aIjTQtM0h7", profile.getId());
    assertEquals(OidcProfile.class.getName() + CommonProfile.SEPARATOR + "00u5h0czw1aIjTQtM0h7",
            profile.getTypedId());
    assertNotNull(profile.getAccessToken());
    assertNotNull(profile.getIdToken());
    assertTrue(ProfileHelper.isTypedIdOf(profile.getTypedId(), OidcProfile.class));
    assertNotNull(profile.getIdTokenString());
    assertCommonProfile(profile, getLogin(), "Test", "pac4j", "Test pac4j", "[email protected]",
            Gender.UNSPECIFIED, new Locale("en", "US"), null, null, "America/Los_Angeles");
    assertTrue((Boolean) profile.getAttribute("email_verified"));
    assertNotNull(profile.getAttribute("at_hash"));
    assertEquals("1", profile.getAttribute("ver").toString());
    assertNotNull(profile.getAmr());
    assertEquals("https://dev-425954.oktapreview.com", profile.getIssuer());
    assertEquals("ZuxDX1Gw2Kvx4gFyDNWC", profile.getAudience().get(0));
    assertEquals("00o5gxpohzF1JWEXZ0h7", profile.getAttribute("idp"));
    assertNotNull(profile.getAuthTime());
    assertNotNull(profile.getExpirationDate());
    assertNotNull(profile.getIssuedAt());
    assertNotNull(profile.getAttribute("jti"));
    assertEquals(22, profile.getAttributes().size());
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:26,代码来源:RunOkta.java


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