Package org.pac4j.core.profile

Examples of org.pac4j.core.profile.CommonProfile


    protected abstract void verifyProfile(UserProfile userProfile);

    protected void assertCommonProfile(final UserProfile userProfile, final String email, final String firstName,
            final String familyName, final String displayName, final String username, final Gender gender,
            final Locale locale, final String pictureUrl, final String profileUrl, final String location) {
        final CommonProfile profile = (CommonProfile) userProfile;
        assertEquals(email, profile.getEmail());
        assertEquals(firstName, profile.getFirstName());
        assertEquals(familyName, profile.getFamilyName());
        assertEquals(displayName, profile.getDisplayName());
        assertEquals(username, profile.getUsername());
        assertEquals(gender, profile.getGender());
        assertEquals(locale, profile.getLocale());
        if (pictureUrl == null) {
            assertNull(profile.getPictureUrl());
        } else {
            assertTrue(profile.getPictureUrl().contains(pictureUrl));
        }
        if (profileUrl == null) {
            assertNull(profile.getProfileUrl());
        } else {
            final String profUrl = profile.getProfileUrl();
            assertTrue(profUrl.startsWith(profileUrl));
        }
        assertEquals(location, profile.getLocation());
    }
View Full Code Here


    protected void internalInit() {
    }
   
    @Override
    protected CommonProfile retrieveUserProfile(final C credentials, final WebContext context) {
        return new CommonProfile();
    }
View Full Code Here

   
    private CommonProfile profile;
   
    @Override
    public void setUp() {
        this.profile = new CommonProfile();
        this.profile.addAttribute(ATTRIB1, VALUE1);
        this.profile.addAttribute(ATTRIB2, VALUE2);
    }
View Full Code Here

public final class TestDefaultCasAuthorizationGenerator extends TestCase {

    public void testNoAttribute() {
        AuthorizationGenerator<CommonProfile> generator = new DefaultCasAuthorizationGenerator<CommonProfile>();
        Map<String, Object> attributes = new HashMap<String, Object>();
        CommonProfile profile = (CommonProfile) ProfileHelper.buildProfile("CasProfile#id", attributes);
        generator.generate(profile);
        assertEquals(false, profile.isRemembered());
    }
View Full Code Here

    public void testBadAttributeValue() {
        AuthorizationGenerator<CommonProfile> generator = new DefaultCasAuthorizationGenerator<CommonProfile>();
        Map<String, Object> attributes = new HashMap<String, Object>();
        attributes.put(DefaultCasAuthorizationGenerator.DEFAULT_REMEMBER_ME_ATTRIBUTE_NAME, "yes");
        CommonProfile profile = (CommonProfile) ProfileHelper.buildProfile("CasProfile#id", attributes);
        generator.generate(profile);
        assertEquals(false, profile.isRemembered());
    }
View Full Code Here

    public void testIsNotRemembered() {
        AuthorizationGenerator<CommonProfile> generator = new DefaultCasAuthorizationGenerator<CommonProfile>();
        Map<String, Object> attributes = new HashMap<String, Object>();
        attributes.put(DefaultCasAuthorizationGenerator.DEFAULT_REMEMBER_ME_ATTRIBUTE_NAME, "false");
        CommonProfile profile = (CommonProfile) ProfileHelper.buildProfile("CasProfile#id", attributes);
        generator.generate(profile);
        assertEquals(false, profile.isRemembered());
    }
View Full Code Here

    public void testIsRemembered() {
        AuthorizationGenerator<CommonProfile> generator = new DefaultCasAuthorizationGenerator<CommonProfile>();
        Map<String, Object> attributes = new HashMap<String, Object>();
        attributes.put(DefaultCasAuthorizationGenerator.DEFAULT_REMEMBER_ME_ATTRIBUTE_NAME, "true");
        CommonProfile profile = (CommonProfile) ProfileHelper.buildProfile("CasProfile#id", attributes);
        generator.generate(profile);
        assertEquals(true, profile.isRemembered());
    }
View Full Code Here

   
    IModel<User> userModel = new GenericEntityModel<Long, User>(new User());
    userModel.getObject().setActive(false);
   
    if (token != null && token.getUserProfile() != null) {
      CommonProfile profile = (CommonProfile) token.getUserProfile();
      if (profile.getEmail() != null) {
        User user = userService.getByUserName(profile.getEmail());
        if (user != null) {
          LOGGER.warn("This email address is already used by another user");
          getSession().warn(getString("register.userName.notUnique"));
        }
      }
     
      userModel.getObject().setEmail(profile.getEmail());
      userModel.getObject().setFullName(profile.getDisplayName());
      userModel.getObject().setRemoteIdentifier(profile.getId());
    }

    addBreadCrumbElement(new BreadCrumbElement(new ResourceModel("register.pageTitle"), RegisterPage.linkDescriptor()));
   
    add(new Label("pageTitle", new ResourceModel("register.pageTitle")));
View Full Code Here

  @Autowired
  private RoleHierarchy roleHierarchy;
 
  @Override
  public UserDetails loadUserDetails(ClientAuthenticationToken token) throws UsernameNotFoundException {
    CommonProfile commonProfile = (CommonProfile) token.getUserProfile();
   
    IGroupedUser<?> person = userService.getByRemoteIdentifier(commonProfile.getId());
   
    if (person == null) {
      throw new UsernameNotFoundException("User not found for: " + token.getPrincipal());
    }
   
View Full Code Here

TOP

Related Classes of org.pac4j.core.profile.CommonProfile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.