Search in sources :

Example 1 with NumberUtils.toLong

use of org.apache.commons.lang3.math.NumberUtils.toLong in project cas by apereo.

the class OidcAuthorizationRequestSupport method getOidcMaxAgeFromAuthorizationRequest.

/**
 * Gets oidc max age from authorization request.
 *
 * @param context the context
 * @return the oidc max age from authorization request
 */
public static Optional<Long> getOidcMaxAgeFromAuthorizationRequest(final WebContext context) {
    final URIBuilder builderContext = new URIBuilder(context.getFullRequestURL());
    final Optional<URIBuilder.BasicNameValuePair> parameter = builderContext.getQueryParams().stream().filter(p -> OidcConstants.MAX_AGE.equals(p.getName())).findFirst();
    if (parameter.isPresent()) {
        final long maxAge = NumberUtils.toLong(parameter.get().getValue(), -1);
        return Optional.of(maxAge);
    }
    return Optional.empty();
}
Also used : CasProtocolConstants(org.apereo.cas.CasProtocolConstants) Arrays(java.util.Arrays) CasClient(org.pac4j.cas.client.CasClient) NonNull(lombok.NonNull) OidcConstants(org.apereo.cas.oidc.OidcConstants) ZonedDateTime(java.time.ZonedDateTime) TicketRegistrySupport(org.apereo.cas.ticket.registry.TicketRegistrySupport) Set(java.util.Set) URIBuilder(org.jasig.cas.client.util.URIBuilder) StringUtils(org.apache.commons.lang3.StringUtils) ProfileManager(org.pac4j.core.profile.ProfileManager) Collectors(java.util.stream.Collectors) Pac4jUtils(org.apereo.cas.util.Pac4jUtils) WebContext(org.pac4j.core.context.WebContext) Slf4j(lombok.extern.slf4j.Slf4j) Authentication(org.apereo.cas.authentication.Authentication) NumberUtils(org.apache.commons.lang3.math.NumberUtils) CookieRetrievingCookieGenerator(org.apereo.cas.web.support.CookieRetrievingCookieGenerator) J2EContext(org.pac4j.core.context.J2EContext) Optional(java.util.Optional) UserProfile(org.pac4j.core.profile.UserProfile) AllArgsConstructor(lombok.AllArgsConstructor) URIBuilder(org.jasig.cas.client.util.URIBuilder)

Aggregations

ZonedDateTime (java.time.ZonedDateTime)1 Arrays (java.util.Arrays)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 AllArgsConstructor (lombok.AllArgsConstructor)1 NonNull (lombok.NonNull)1 Slf4j (lombok.extern.slf4j.Slf4j)1 StringUtils (org.apache.commons.lang3.StringUtils)1 NumberUtils (org.apache.commons.lang3.math.NumberUtils)1 CasProtocolConstants (org.apereo.cas.CasProtocolConstants)1 Authentication (org.apereo.cas.authentication.Authentication)1 OidcConstants (org.apereo.cas.oidc.OidcConstants)1 TicketRegistrySupport (org.apereo.cas.ticket.registry.TicketRegistrySupport)1 Pac4jUtils (org.apereo.cas.util.Pac4jUtils)1 CookieRetrievingCookieGenerator (org.apereo.cas.web.support.CookieRetrievingCookieGenerator)1 URIBuilder (org.jasig.cas.client.util.URIBuilder)1 CasClient (org.pac4j.cas.client.CasClient)1 J2EContext (org.pac4j.core.context.J2EContext)1 WebContext (org.pac4j.core.context.WebContext)1