@Override public void set(final U profile) throws Exception { this.session.get().set(key(profile.getId()), AuthSerializer.objToStr(profile)); }
static Provider profileProvider(AtomicReference<Registry> registry, Class profile, Function<Request, UserProfile> unauthenticated) { return () -> { Request req = registry.get().require(Request.class); ProfileManager pm = req.require(ProfileManager.class); Object result = pm.getAll(req.ifSession().isPresent()).stream() .filter(profile::isInstance) .findFirst() .orElse(null); if (result == null) { if (unauthenticated == null) { throw new Err(Status.FORBIDDEN, "Not found: " + profile.getSimpleName()); } result = unauthenticated.apply(req); } return result; }; } }
/** * Gets pac4j profile manager. * * @param context the context * @return the pac4j profile manager */ public static ProfileManager getPac4jProfileManager(final WebContext context) { return new ProfileManager(context); }
protected void saveUserProfile(final WebContext context, final UserProfile profile) { final ProfileManager manager = new ProfileManager(context); if (profile != null) { manager.save(true, profile); } }
@Override public Object getPrincipal() { return ProfileHelper.flatIntoOneProfile(profiles); }
@Override public String getId() { if (this.userProfile != null) { if (this.typedIdUsed) { return this.userProfile.getTypedId(); } return this.userProfile.getId(); } return null; }
/** * @return the name */ public String getName() { return profile.getId(); }
/** * Gets client id from authenticated profile. * * @param profile the profile * @return the client id from authenticated profile */ public static String getClientIdFromAuthenticatedProfile(final CommonProfile profile) { if (profile.containsAttribute(OAuth20Constants.CLIENT_ID)) { return (String) profile.getAttribute(OAuth20Constants.CLIENT_ID); } return null; }
/** * @return the attributes */ public Map<String, Object> getAttributes() { return profile.getAttributes(); }
public List<String> getRoles() { return profile.getRoles(); }
public List<String> getPermissions() { return profile.getPermissions(); }
/** * @param permissions the permissions to set */ void setPermissions(List<String> permissions) { for (String permission : permissions) { profile.addPermission(permission); } } }
/** * @param roles the roles to set */ void setRoles(List<String> roles) { for (String role : roles) { profile.addRole(role); } }
public Object getAttribute(String attribute) { return profile.getAttribute(attribute); }
String id = profile.getId(); req.set(Auth.ID, id); session.set(Auth.ID, id);
private Optional<CommonProfile> getProfile() { return ProfileHelper.flatIntoOneProfile(profiles); }
log.debug("profile: {}", identity); if (identity != null) { req.set(Auth.ID, identity.getId()); req.set(Auth.CNAME, client.getName()); store.set(identity);
private Optional<UserProfile> getProfile() { return ProfileHelper.flatIntoOneProfile(profiles); }
@Override public String getName() { return profile.getId(); }
/** * Get the main profile of the authenticated user. * * @return the main profile */ public CommonProfile getProfile() { return ProfileHelper.flatIntoOneProfile(this.profiles).get(); }