org.cloudfoundry.identity.uaa.oauth.ClientRefreshTokenValidity Maven / Gradle / Ivy
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();
}
}