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

org.apereo.cas.web.TokenRequestExtractor Maven / Gradle / Ivy

There is a newer version: 7.2.0-RC2
Show newest version
package org.apereo.cas.web;

import org.apereo.cas.token.TokenConstants;
import org.apache.commons.lang3.StringUtils;
import jakarta.servlet.http.HttpServletRequest;

/**
 * This is {@link TokenRequestExtractor}.
 *
 * @author Misagh Moayyed
 * @since 5.2.0
 */
public interface TokenRequestExtractor {

    /**
     * Default extractor token request.
     *
     * @return the token request extractor
     */
    static TokenRequestExtractor defaultExtractor() {
        return new TokenRequestExtractor() {
        };
    }

    /**
     * Extract string.
     *
     * @param request the request
     * @return the string
     */
    default String extract(final HttpServletRequest request) {
        var authTokenValue = request.getParameter(TokenConstants.PARAMETER_NAME_TOKEN);
        if (StringUtils.isBlank(authTokenValue)) {
            authTokenValue = request.getHeader(TokenConstants.PARAMETER_NAME_TOKEN);
        }
        return authTokenValue;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy