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

org.cloudfoundry.identity.uaa.oauth.ClientRefreshTokenValidity Maven / Gradle / Ivy

There is a newer version: 4.30.0
Show newest version
package org.cloudfoundry.identity.uaa.oauth;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.cloudfoundry.identity.uaa.zone.ClientServicesExtension;
import org.cloudfoundry.identity.uaa.zone.IdentityZoneHolder;
import org.springframework.security.oauth2.provider.ClientDetails;
import org.springframework.security.oauth2.provider.ClientRegistrationException;

public class ClientRefreshTokenValidity implements ClientTokenValidity {
    private final Log logger = LogFactory.getLog(getClass());
    private ClientServicesExtension clientServicesExtension;

    public ClientRefreshTokenValidity(ClientServicesExtension clientServicesExtension) {
        this.clientServicesExtension = clientServicesExtension;
    }

    @Override
    public Integer getValiditySeconds(String clientId) {
        ClientDetails clientDetails;

        try {
            clientDetails = clientServicesExtension.loadClientByClientId(clientId, IdentityZoneHolder.get().getId());
        } catch (ClientRegistrationException e) {
            logger.info("Could not load details for client " + clientId, e);
            return null;
        }
        return clientDetails.getRefreshTokenValiditySeconds();
    }

    @Override
    public Integer getZoneValiditySeconds() {
        return IdentityZoneHolder.get().getConfig().getTokenPolicy().getRefreshTokenValidity();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy