/** {@inheritDoc} */ @Override protected void doDestroy() { final ServiceableComponent<T> oldComponent = cachedComponent; cachedComponent = null; // And tear down. Note that we are synchronized on this right now // and this will grab the lock - but that is OK because the ranking // is to lock this object, then the ServicableComponent. if (null != oldComponent) { oldComponent.unloadComponent(); } super.doDestroy(); }
/** * Get the serviceable component. We do this under interlock and grab the lock on the component. * * @return the <em>pinned</em> component. */ @Override public synchronized ServiceableComponent<T> getServiceableComponent() { if (null == cachedComponent) { return null; } cachedComponent.pinComponent(); return cachedComponent; }
public DateTime getValue() { return service.getLastReloadAttemptInstant(); } });
@Nullable @Override public Service lookup(@Nonnull final String serviceURL) { ServiceableComponent<ServiceRegistry> component = null; try { component = service.getServiceableComponent(); if (null == component) { log.error("ServiceRegistry '{}': error looking up service registry: Invalid configuration.", getId()); return null; } return component.getComponent().lookup(serviceURL); } finally { if (null != component) { component.unpinComponent(); } } } }
/** {@inheritDoc} */ @Override protected void doInitialize() throws ComponentInitializationException { super.doInitialize(); final ServiceableComponent component = getService().getServiceableComponent(); if (component != null) { try { if (component instanceof MetadataResolver) { return; } } finally { component.unpinComponent(); } } throw new ComponentInitializationException("Injected service was null or not a MetadataResolver"); }
public DateTime getValue() { return service.getLastSuccessfulReloadInstant(); } });
/** {@inheritDoc} */ @Override protected void doInitialize() throws ComponentInitializationException { if (getId() == null) { setId(beanName); } super.doInitialize(); }
public String getValue() { return service.getReloadFailureCause() != null ? service.getReloadFailureCause().getMessage() : null; } });
/** {@inheritDoc} */ @Override public SecurityConfiguration getDefaultSecurityConfiguration(final String profileId) { ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this); ServiceableComponent<RelyingPartyConfigurationResolver> component = null; try { component = service.getServiceableComponent(); if (null == component) { log.error("RelyingPartyResolver '{}': error looking up default security config:" + " Invalid configuration.", getId()); } else { final RelyingPartyConfigurationResolver resolver = component.getComponent(); return resolver.getDefaultSecurityConfiguration(profileId); } } finally { if (null != component) { component.unpinComponent(); } } return null; }
/** {@inheritDoc} */ @Override protected void doInitialize() throws ComponentInitializationException { super.doInitialize(); final ServiceableComponent component = getService().getServiceableComponent(); if (component != null) { try { if (component instanceof AttributeResolver) { return; } } finally { component.unpinComponent(); } } throw new ComponentInitializationException("Injected service was null or not an AttributeResolver"); }
/** {@inheritDoc} */ @Override public MetadataFilter getMetadataFilter() { ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this); ServiceableComponent<MetadataResolver> component = null; try { component = service.getServiceableComponent(); if (null == component) { log.error("RelyingPartyMetadataProvider '{}': Error accessing underlying metadata source: " + "Invalid configuration.", getId()); } else { final MetadataResolver resolver = component.getComponent(); return resolver.getMetadataFilter(); } } finally { if (null != component) { component.unpinComponent(); } } throw new IllegalAccessError("Could not find a valid MetadataResolver"); }
/** {@inheritDoc} */ @Override public boolean isRequireValidMetadata() { ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this); ServiceableComponent<MetadataResolver> component = null; try { component = service.getServiceableComponent(); if (null == component) { log.error("RelyingPartyMetadataProvider '{}': Error accessing underlying metadata source: " + "Invalid configuration.", getId()); } else { final MetadataResolver resolver = component.getComponent(); return resolver.isRequireValidMetadata(); } } finally { if (null != component) { component.unpinComponent(); } } throw new IllegalAccessError("Could not find a valid MetadataResolver"); }
public Map<String,DateTime> getValue() { final Builder mapBuilder = ImmutableMap.<String,DateTime>builder(); final ServiceableComponent<MetadataResolver> component = getService().getServiceableComponent(); if (component != null) { try { for (final MetadataResolver resolver : getMetadataResolvers(component.getComponent())) { if (resolver instanceof RefreshableMetadataResolver && ((RefreshableMetadataResolver) resolver).getLastRefresh() != null) { mapBuilder.put(resolver.getId(), ((RefreshableMetadataResolver) resolver).getLastRefresh()); } } } finally { component.unpinComponent(); } } return mapBuilder.build(); } });
public Map<String,DateTime> getValue() { final Builder mapBuilder = ImmutableMap.<String,DateTime>builder(); final ServiceableComponent<MetadataResolver> component = getService().getServiceableComponent(); if (component != null) { try { for (final MetadataResolver resolver : getMetadataResolvers(component.getComponent())) { if (resolver instanceof RefreshableMetadataResolver && ((RefreshableMetadataResolver) resolver).getLastUpdate() != null) { mapBuilder.put(resolver.getId(), ((RefreshableMetadataResolver) resolver).getLastUpdate()); } } } finally { component.unpinComponent(); } } return mapBuilder.build(); } });
/** {@inheritDoc} */ @Override @Nullable public NameIdentifier generate(@Nonnull final ProfileRequestContext profileRequestContext, @Nonnull @NotEmpty final String format) throws SAMLException { ServiceableComponent<NameIdentifierGenerationService> component = null; try { component = generatorService.getServiceableComponent(); if (component == null) { throw new SAMLException("Invalid NameIdentifierGenerationService configuration"); } return component.getComponent().getSAML1NameIdentifierGenerator().generate(profileRequestContext, format); } finally { if (null != component) { component.unpinComponent(); } } }
/** {@inheritDoc} */ @Override @Nullable public NameID generate(@Nonnull final ProfileRequestContext profileRequestContext, @Nonnull @NotEmpty final String format) throws SAMLException { ServiceableComponent<NameIdentifierGenerationService> component = null; try { component = generatorService.getServiceableComponent(); if (component == null) { throw new SAMLException("Invalid NameIdentifierGenerationService configuration"); } return component.getComponent().getSAML2NameIDGenerator().generate(profileRequestContext, format); } finally { if (null != component) { component.unpinComponent(); } } }
/** {@inheritDoc} */ @Override @Nullable public RelyingPartyConfiguration resolveSingle(@Nullable final ProfileRequestContext context) throws ResolverException { ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this); ServiceableComponent<RelyingPartyConfigurationResolver> component = null; try { component = service.getServiceableComponent(); if (null == component) { log.error("RelyingPartyResolver '{}': error looking up Relying Party: Invalid configuration.", getId()); } else { final RelyingPartyConfigurationResolver resolver = component.getComponent(); return resolver.resolveSingle(context); } } catch (final ResolverException e) { log.error("RelyingPartyResolver '{}': error in resolution", getId(), e); } finally { if (null != component) { component.unpinComponent(); } } return null; }
public Map<String,DateTime> getValue() { final Builder mapBuilder = ImmutableMap.<String,DateTime>builder(); final ServiceableComponent<MetadataResolver> component = getService().getServiceableComponent(); if (component != null) { try { for (final MetadataResolver resolver : getMetadataResolvers(component.getComponent())) { if (resolver instanceof ExtendedBatchMetadataResolver && ((ExtendedBatchMetadataResolver) resolver).getRootValidUntil() != null) { mapBuilder.put(resolver.getId(), ((ExtendedBatchMetadataResolver) resolver).getRootValidUntil()); } } } finally { component.unpinComponent(); } } return mapBuilder.build(); } });
/** {@inheritDoc} */ @Override @Nonnull public Iterable<EntityDescriptor> resolve(final CriteriaSet criteria) throws ResolverException { ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this); ServiceableComponent<MetadataResolver> component = null; try { component = service.getServiceableComponent(); if (null == component) { log.error("RelyingPartyMetadataProvider '{}': Error accessing underlying metadata source: " + "Invalid configuration.", getId()); } else { final MetadataResolver resolver = component.getComponent(); return resolver.resolve(criteria); } } catch (final ResolverException e) { log.error("RelyingPartyMetadataProvider '{}': Error during resolution", getId(), e); } finally { if (null != component) { component.unpinComponent(); } } return Collections.EMPTY_SET; }
public Map<String,DateTime> getValue() { final Builder mapBuilder = ImmutableMap.<String,DateTime>builder(); final ServiceableComponent<MetadataResolver> component = getService().getServiceableComponent(); if (component != null) { try { for (final MetadataResolver resolver : getMetadataResolvers(component.getComponent())) { if (resolver instanceof ExtendedRefreshableMetadataResolver && ((ExtendedRefreshableMetadataResolver) resolver) .getLastSuccessfulRefresh() != null) { mapBuilder.put(resolver.getId(), ((ExtendedRefreshableMetadataResolver) resolver) .getLastSuccessfulRefresh()); } } } finally { component.unpinComponent(); } } return mapBuilder.build(); } });