All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.day.cq.security.util.ImpersonationRequestUtil Maven / Gradle / Ivy

/*
 * Copyright 1997-2008 Day Management AG
 * Barfuesserplatz 6, 4001 Basel, Switzerland
 * All Rights Reserved.
 *
 * This software is the confidential and proprietary information of
 * Day Management AG, ("Confidential Information"). You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Day.
 */
package com.day.cq.security.util;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;

import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.ResourceResolver;
import com.day.cq.security.widgets.impl.UserInfoServlet;

/**
 * This class/service is deprecated and should not be used any more. It will be
 * removed in a future version.
 *
 * @deprecated as of 5.3.4
 */
@Deprecated
@Component(metatype = false)
@Service(ImpersonationRequestUtil.class)
public class ImpersonationRequestUtil {

    /**
     * Returns true if the JCR Session underlying the current
     * request is impersonated. Otherwise false is returned.
     * false is als returned if the request is not a
     * SlingHttpServletRequest or the request's resource resolver
     * is not based on a JCR session.
     *
     * @deprecated check "impersonator" attribute of the session to see whether
     *             the session is impersonated or not.
     */
    @Deprecated
    public boolean isImpersonated(HttpServletRequest request) {
        if (request instanceof SlingHttpServletRequest) {
            ResourceResolver resolver = ((SlingHttpServletRequest) request).getResourceResolver();
            return UserInfoServlet.isImpersonated(resolver);
        }
        return false;
    }

    /**
     * @throws UnsupportedOperationException because this is not implemented and
     *             supported any longer.
     * @deprecated with no replacement. To initiate impersonation send a request
     *             with the sudo request parameter set to the target user
     *             id.
     */
    @Deprecated
    public Cookie createCookie(@SuppressWarnings("unused") String id,
            @SuppressWarnings("unused") String sudo) {
        throw new UnsupportedOperationException("createCookie");
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy