Skip to content

Commit

Permalink
Merge branch 'master' into SHIBUI-808
Browse files Browse the repository at this point in the history
  • Loading branch information
jj committed Sep 26, 2018
2 parents 857dda5 + 8dc34cb commit a484de2
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ResourceBundleMessageSource;
Expand All @@ -47,9 +48,6 @@
public class CoreShibUiConfiguration {
private static final Logger logger = LoggerFactory.getLogger(CoreShibUiConfiguration.class);

@Value("${shibui.metadata-dir:/opt/shibboleth-idp/metadata/generated}")
private String metadataDir;

@Bean
public OpenSamlObjects openSamlObjects() {
return new OpenSamlObjects();
Expand Down Expand Up @@ -92,8 +90,9 @@ public AttributeUtility attributeUtility() {
ResourceBundleMessageSource messageSource;

@Bean
public EntityDescriptorFilesScheduledTasks entityDescriptorFilesScheduledTasks(EntityDescriptorRepository entityDescriptorRepository) {
return new EntityDescriptorFilesScheduledTasks(this.metadataDir, entityDescriptorRepository, openSamlObjects());
@ConditionalOnProperty(name = "shibui.metadata-dir")
public EntityDescriptorFilesScheduledTasks entityDescriptorFilesScheduledTasks(EntityDescriptorRepository entityDescriptorRepository, @Value("${shibui.metadata-dir}") final String metadataDir) {
return new EntityDescriptorFilesScheduledTasks(metadataDir, entityDescriptorRepository, openSamlObjects());
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.apache.http.impl.client.HttpClients;
import org.apache.lucene.index.IndexWriter;
import org.joda.time.DateTime;
import org.joda.time.chrono.ISOChronology;
import org.opensaml.saml.metadata.resolver.filter.FilterException;
import org.opensaml.saml.metadata.resolver.filter.MetadataFilterChain;
import org.opensaml.saml.metadata.resolver.impl.FileBackedHTTPMetadataResolver;
Expand Down Expand Up @@ -92,4 +93,34 @@ public void refilter() {
logger.error("An error occurred while attempting to filter metadata!", e);
}
}

//TODO: This is a band-aid for the negative refresh issue. This override should go away once we figure out
// why the negative refresh is occurring.
@Override
public synchronized void refresh() throws ResolverException {
// In case a destroy() thread beat this thread into the monitor.
if (isDestroyed()) {
return;
}

try {

DateTime now = new DateTime(ISOChronology.getInstanceUTC());
String mdId = getMetadataIdentifier();

final byte[] mdBytes = fetchMetadata();
if (mdBytes == null) {
processCachedMetadata(mdId, now);
} else {
processNewMetadata(mdId, now, mdBytes);
}
} catch (final Throwable t) {
if (t instanceof Exception) {
throw new ResolverException((Exception) t);
} else {
throw new ResolverException(String.format("Saw an error of type '%s' with message '%s'",
t.getClass().getName(), t.getMessage()));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import org.opensaml.core.xml.io.MarshallingException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.transaction.annotation.Transactional;

Expand All @@ -31,6 +33,8 @@
*
* @since 1.0
*/
@Configuration
@ConditionalOnProperty(name = "shibui-metadata-dir")
public class EntityDescriptorFilesScheduledTasks {

private static final Logger LOGGER = LoggerFactory.getLogger(EntityDescriptorFilesScheduledTasks.class);
Expand Down
2 changes: 1 addition & 1 deletion backend/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ spring.jpa.properties.hibernate.format_sql=false

spring.jpa.hibernate.use-new-id-generator-mappings=true

shibui.metadata-dir=/opt/shibboleth-idp/metadata/generated
# shibui.metadata-dir=/opt/shibboleth-idp/metadata/generated
shibui.logout-url=/dashboard

spring.profiles.active=default
Expand Down

0 comments on commit a484de2

Please sign in to comment.