Skip to content
Snippets Groups Projects

fix: Migrate away from /userinfo

1 unresolved thread
4 files
+ 82
21
Compare changes
  • Side-by-side
  • Inline
Files
4
/*********************************************************************
* Copyright (c) 2023 Eclipse Foundation.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* Author: Zachary Sabourin <zachary.sabourin@eclipse-foundation.org>
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
package org.eclipsefoundation.openvsx.models;
import javax.enterprise.context.RequestScoped;
import javax.servlet.http.HttpServletRequest;
import org.eclipsefoundation.core.exception.FinalForbiddenException;
import org.eclipsefoundation.efservices.api.models.EfUser;
/**
* A RequestScoped bean that wraps the EfUser value set in the request
* chain. This bean is used to access profile information about the
* user associated with the current token. To set this data, a user search must
* be performed using the 'uid' from the current oauth token info. To access
* this data, a EfUser object must be set as the 'current_profile' property in
* the HttpServletRequest bound to the current request chain.
*/
@RequestScoped
public class RequestUserProfileWrapper {
public static final String CURRENT_PROFILE = "current_profile";
private final EfUser currentUserProfile;
public RequestUserProfileWrapper(HttpServletRequest request) {
this.currentUserProfile = (EfUser) request.getAttribute(CURRENT_PROFILE);
}
/*
* Retrieves the EfUser object bound to the current request
*/
public EfUser getCurrentUserProfile() {
if (currentUserProfile == null) {
throw new FinalForbiddenException("No profile data in request chain");
}
return this.currentUserProfile;
}
}
Loading