Example usage for com.google.common.base Functions compose

List of usage examples for com.google.common.base Functions compose

Introduction

In this page you can find the example usage for com.google.common.base Functions compose.

Prototype

public static <A, B, C> Function<A, C> compose(Function<B, C> g, Function<A, ? extends B> f) 

Source Link

Document

Returns the composition of two functions.

Usage

From source file:net.shibboleth.idp.saml.impl.nameid.AttributeSourcedSAML2NameIDGenerator.java

/** Constructor. */
public AttributeSourcedSAML2NameIDGenerator() {
    relyingPartyContextLookupStrategy = new ChildContextLookup<>(RelyingPartyContext.class);
    attributeContextLookupStrategy = Functions.compose(
            new ChildContextLookup<RelyingPartyContext, AttributeContext>(AttributeContext.class),
            relyingPartyContextLookupStrategy);
    attributeSourceIds = Collections.emptyList();
}

From source file:fi.csc.idp.stepup.impl.SetRequestedAuthenticationContext.java

/** Constructor. */
public SetRequestedAuthenticationContext() {

    authnRequestLookupStrategy = Functions.compose(new MessageLookup<>(AuthnRequest.class),
            new InboundMessageContextLookup());
}

From source file:org.opensaml.profile.action.impl.PopulateSignatureValidationParameters.java

/**
 * Constructor.//from w  w w.j a va  2 s .  co  m
 */
public PopulateSignatureValidationParameters() {
    // Create context by default.
    securityParametersContextLookupStrategy = Functions.compose(
            new ChildContextLookup<>(SecurityParametersContext.class, true), new InboundMessageContextLookup());
}

From source file:org.opensaml.saml.common.profile.logic.DefaultLocalErrorPredicate.java

/** Constructor. */
public DefaultLocalErrorPredicate() {
    // Default: outbound msg context -> SAMLBindingContext
    bindingContextLookupStrategy = Functions.compose(new ChildContextLookup<>(SAMLBindingContext.class),
            new OutboundMessageContextLookup());

    // Default: outbound msg context -> SAMLPeerEntityContext -> SAMLEndpointContext
    endpointContextLookupStrategy = Functions.compose(new ChildContextLookup<>(SAMLEndpointContext.class),
            Functions.compose(new ChildContextLookup<>(SAMLPeerEntityContext.class),
                    new OutboundMessageContextLookup()));

    eventContextLookupStrategy = new CurrentOrPreviousEventLookup();

    localEvents = Collections.emptySet();
}

From source file:fi.vm.kapa.identification.shibboleth.flow.SLOCheckKatso.java

public SLOCheckKatso() {

    sessionResolverCriteriaStrategy = new Function<ProfileRequestContext, CriteriaSet>() {
        @Override//  w  w  w  .ja  v  a2  s  . c om
        public CriteriaSet apply(final ProfileRequestContext input) {
            if (logoutRequest != null && logoutRequest.getIssuer() != null
                    && logoutRequest.getNameID() != null) {
                return new CriteriaSet(new SPSessionCriterion(logoutRequest.getIssuer().getValue(),
                        logoutRequest.getNameID().getValue()));
            } else {
                return new CriteriaSet();
            }
        }
    };

    logoutRequestLookupStrategy = Functions.compose(new MessageLookup<>(LogoutRequest.class),
            new InboundMessageContextLookup());
}

From source file:net.shibboleth.idp.saml.impl.nameid.AttributeSourcedSAML1NameIdentifierGenerator.java

/** Constructor. */
public AttributeSourcedSAML1NameIdentifierGenerator() {
    relyingPartyContextLookupStrategy = new ChildContextLookup<>(RelyingPartyContext.class);
    attributeContextLookupStrategy = Functions.compose(
            new ChildContextLookup<RelyingPartyContext, AttributeContext>(AttributeContext.class),
            relyingPartyContextLookupStrategy);
    attributeSourceIds = Collections.emptyList();
}

From source file:org.opensaml.saml.common.profile.impl.AddAudienceRestrictionToAssertions.java

/**
 * Constructor./*w  w w.jav  a 2s .  c  om*/
 */
public AddAudienceRestrictionToAssertions() {
    addingAudiencesToExistingRestriction = true;

    responseLookupStrategy = Functions.compose(new MessageLookup<>(SAMLObject.class),
            new OutboundMessageContextLookup());
}

From source file:clocker.mesos.entity.MesosSlaveImpl.java

@Override
public void connectSensors() {
    super.connectSensors();

    final String id = sensors().get(MESOS_SLAVE_ID);

    HttpFeed.Builder httpFeedBuilder = HttpFeed.builder().entity(this).period(30, TimeUnit.SECONDS)
            .baseUri(getMesosCluster().sensors().get(Attributes.MAIN_URI))
            .credentialsIfNotNull(config().get(MesosCluster.MESOS_USERNAME),
                    config().get(MesosCluster.MESOS_PASSWORD))
            .poll(HttpPollConfig.forSensor(MEMORY_AVAILABLE).suburl("/master/state.json")
                    .onSuccess(Functionals.chain(HttpValueFunctions.jsonContents(),
                            Functions.compose(MesosUtils.selectM(new Predicate<JsonElement>() {
                                @Override
                                public boolean apply(JsonElement input) {
                                    return input.getAsJsonObject().get("id").getAsString().equals(id);
                                }//  w w  w  .  j  a  v a 2 s  .  c  o  m
                            }), JsonFunctions.walk("slaves")), JsonFunctions.walkM("resources", "mem"),
                            JsonFunctions.castM(Long.class)))
                    .onFailureOrException(Functions.constant(-1L)))
            .poll(HttpPollConfig.forSensor(CPU_AVAILABLE).suburl("/master/state.json")
                    .onSuccess(Functionals.chain(HttpValueFunctions.jsonContents(),
                            Functions.compose(MesosUtils.selectM(new Predicate<JsonElement>() {
                                @Override
                                public boolean apply(JsonElement input) {
                                    return input.getAsJsonObject().get("id").getAsString().equals(id);
                                }
                            }), JsonFunctions.walk("slaves")), JsonFunctions.walkM("resources", "cpus"),
                            JsonFunctions.castM(Double.class)))
                    .onFailureOrException(Functions.constant(-1d)))
            .poll(HttpPollConfig.forSensor(DISK_AVAILABLE).suburl("/master/state.json")
                    .onSuccess(Functionals.chain(HttpValueFunctions.jsonContents(),
                            Functions.compose(MesosUtils.selectM(new Predicate<JsonElement>() {
                                @Override
                                public boolean apply(JsonElement input) {
                                    return input.getAsJsonObject().get("id").getAsString().equals(id);
                                }
                            }), JsonFunctions.walk("slaves")), JsonFunctions.walkM("resources", "disk"),
                            JsonFunctions.castM(Long.class)))
                    .onFailureOrException(Functions.constant(-1L)))
            .poll(HttpPollConfig.forSensor(MEMORY_USED).suburl("/master/state.json")
                    .onSuccess(Functionals.chain(HttpValueFunctions.jsonContents(),
                            Functions.compose(MesosUtils.selectM(new Predicate<JsonElement>() {
                                @Override
                                public boolean apply(JsonElement input) {
                                    return input.getAsJsonObject().get("id").getAsString().equals(id);
                                }
                            }), JsonFunctions.walk("slaves")), JsonFunctions.walkM("used_resources", "mem"),
                            JsonFunctions.castM(Long.class)))
                    .onFailureOrException(Functions.constant(-1L)))
            .poll(HttpPollConfig.forSensor(CPU_USED).suburl("/master/state.json")
                    .onSuccess(Functionals.chain(HttpValueFunctions.jsonContents(),
                            Functions.compose(MesosUtils.selectM(new Predicate<JsonElement>() {
                                @Override
                                public boolean apply(JsonElement input) {
                                    return input.getAsJsonObject().get("id").getAsString().equals(id);
                                }
                            }), JsonFunctions.walk("slaves")), JsonFunctions.walkM("used_resources", "cpus"),
                            JsonFunctions.castM(Double.class)))
                    .onFailureOrException(Functions.constant(-1d)))
            .poll(HttpPollConfig.forSensor(DISK_USED).suburl("/master/state.json")
                    .onSuccess(Functionals.chain(HttpValueFunctions.jsonContents(),
                            Functions.compose(MesosUtils.selectM(new Predicate<JsonElement>() {
                                @Override
                                public boolean apply(JsonElement input) {
                                    return input.getAsJsonObject().get("id").getAsString().equals(id);
                                }
                            }), JsonFunctions.walk("slaves")), JsonFunctions.walkM("used_resources", "disk"),
                            JsonFunctions.castM(Long.class)))
                    .onFailureOrException(Functions.constant(-1L)));
    httpFeed = httpFeedBuilder.build();
}

From source file:org.opensaml.profile.action.impl.PopulateClientTLSValidationParameters.java

/**
 * Constructor.//from  w  w w .jav  a  2s  .  c  om
 */
public PopulateClientTLSValidationParameters() {
    // Create context by default.
    securityParametersContextLookupStrategy = Functions.compose(
            new ChildContextLookup<>(ClientTLSSecurityParametersContext.class, true),
            new InboundMessageContextLookup());
}

From source file:org.jclouds.vcloud.director.v1_5.compute.strategy.VcloudDirectorAdaptingComputeServiceStrategies.java

@Inject
public VcloudDirectorAdaptingComputeServiceStrategies(Map<String, Credentials> credentialStore,
        PrioritizeCredentialsFromTemplate prioritizeCredentialsFromTemplate,
        ComputeServiceAdapter<Vm, Hardware, QueryResultVAppTemplateRecord, Vdc> client,
        Function<Vm, NodeMetadata> nodeMetadataAdapter,
        Function<QueryResultVAppTemplateRecord, Image> imageAdapter,
        AddDefaultCredentialsToImage addDefaultCredentialsToImage) {
    super(credentialStore, prioritizeCredentialsFromTemplate, client, nodeMetadataAdapter, imageAdapter,
            addDefaultCredentialsToImage);
    this.credentialStore = checkNotNull(credentialStore, "credentialStore");
    this.client = client;
    this.nodeMetadataAdapter = Functions.compose(addLoginCredentials,
            checkNotNull(nodeMetadataAdapter, "nodeMetadataAdapter"));
}