Returns a new {@link ClientRequestContextBuilder} created from the specified {@link RpcRequest} and URI.
555625
public static ClientRequestContextBuilder of(RpcRequest request, String uri) {
        return of(request, URI.create(requireNonNull(uri, "uri")));
    }
1083886
@Override
  public JobMasterClientContext build() {
    if (mMasterInquireClient == null) {
      mMasterInquireClient = MasterInquireClient.Factory.createForJobMaster(mContext.getConf());
    }
    return new JobMasterClientContext(mContext, mMasterInquireClient);
  }
1150143
@Deprecated
    public static SslContext newClientContext(SslProvider provider) throws SSLException {
        return newClientContext(provider, null, null);
    }
1320712
@Override
    public RetryingRpcClient build(Client<RpcRequest, RpcResponse> delegate) {
        return new RetryingRpcClient(
                delegate, retryStrategyWithContent(), maxTotalAttempts(),
                responseTimeoutMillisForEachAttempt());
    }
1145989
public static Resource fromRaw(RawResource r, Function<String, Optional<ResourceType>> rtLoader) {
        return new Resource(r.getId(), r.getName(), r.getFeedId(), rtLoader.apply(r.getTypeId()).orElse(null),
                r.getParentId(), r.getMetrics(), r.getProperties(), r.getConfig());
    }
92939
public <T> T getClient(ClientBuilder<T> clientBuilder) {

        JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean();
        proxyFactory.setServiceClass(clientBuilder.getServiceClass());
        proxyFactory.setAddress(clientBuilder.getAddress());

        // JAX-WS handlers
        if (clientBuilder.getHandlers() != null) {
            for (Handler h : clientBuilder.getHandlers()) {
                proxyFactory.getHandlers().add(h);
            }
        }

        // ClientProxyFactoryBean bindingId
        if (clientBuilder.getBindingId() != null) {
            proxyFactory.setBindingId(clientBuilder.getBindingId());
        }

        // CXF interceptors
        if (clientBuilder.getCxfInInterceptors() != null) {
            proxyFactory.getInInterceptors().addAll(clientBuilder.getCxfInInterceptors());
        }
        if (clientBuilder.getCxfInFaultInterceptors() != null) {
            proxyFactory.getInFaultInterceptors().addAll(clientBuilder.getCxfInFaultInterceptors());
        }
        if (clientBuilder.getCxfOutInterceptors() != null) {
            proxyFactory.getOutInterceptors().addAll(clientBuilder.getCxfOutInterceptors());
        }
        if (clientBuilder.getCxfOutFaultInterceptors() != null) {
            proxyFactory.getOutFaultInterceptors().addAll(clientBuilder.getCxfOutFaultInterceptors());
        }

        T proxy = clientBuilder.getServiceClass().cast(proxyFactory.create());

        // MTOM support
        if (clientBuilder.isMtomEnabled()) {
            BindingProvider bp = (BindingProvider)proxy;
            SOAPBinding binding = (SOAPBinding)bp.getBinding();
            binding.setMTOMEnabled(true);
        }

        HTTPConduit http = (HTTPConduit)ClientProxy.getClient(proxy).getConduit();
        HTTPClientPolicy client = http.getClient();
        client.setConnectionTimeout(clientBuilder.getConnectTimeout());
        client.setReceiveTimeout(clientBuilder.getReceiveTimeout());

        return proxy;
    }
1308319
public static ServiceContext createServiceContext(ServletRequest request) {
        if (!(request instanceof HttpServletRequest)) {
            throw new IllegalArgumentException("Expected HttpServletRequest");
        }
        return createServiceContext((HttpServletRequest) request);
    }
425319
public static Function<Client<RpcRequest, RpcResponse>, RetryingRpcClient>
    newDecorator(RetryStrategyWithContent<RpcResponse> retryStrategyWithContent) {
        return new RetryingRpcClientBuilder(retryStrategyWithContent).newDecorator();
    }
1137463
public Request<T> build()
    {
        MultiMap headers = resolveHeaders();
        MultiMap parameters = resolveParameters();

        parameters.add("version",Integer.toString(version));

        Request<T> request = new Request<T>();
        request.setEntityName(entityName);
        request.setEntityType(objectType);
        request.setHeaders(headers);
        request.setParameters(parameters);

        return request;
    }
284990
public ResponseBuilder createResource() {
        final String baseUrl = getBaseUrl();
        final String identifier = baseUrl + req.getPartition() + req.getPath() + id;
        final String contentType = req.getContentType();
        final Session session = ofNullable(req.getSession()).orElseGet(HttpSession::new);

        LOGGER.info("Creating resource as {}", identifier);

        final Optional<RDFSyntax> rdfSyntax = ofNullable(contentType).flatMap(RDFSyntax::byMediaType)
            .filter(SUPPORTED_RDF_TYPES::contains);

        final IRI defaultType = nonNull(contentType) && !rdfSyntax.isPresent() ? LDP.NonRDFSource : LDP.RDFSource;
        final IRI internalId = rdf.createIRI(TRELLIS_PREFIX + req.getPartition() + req.getPath() + id);

        // Add LDP type (ldp:Resource results in the defaultType)
        final IRI ldpType = ofNullable(req.getLink())
            .filter(l -> "type".equals(l.getRel())).map(Link::getUri).map(URI::toString)
            .filter(l -> l.startsWith(LDP.URI)).map(rdf::createIRI)
            .filter(l -> !LDP.Resource.equals(l)).orElse(defaultType);

        if (ldpType.equals(LDP.NonRDFSource) && rdfSyntax.isPresent()) {
            return status(BAD_REQUEST).type(TEXT_PLAIN).entity("Cannot save a NonRDFSource with RDF syntax");
        }

        try (final TrellisDataset dataset = TrellisDataset.createDataset()) {

            // Add Audit quads
            audit.ifPresent(svc ->
                    svc.creation(internalId, session).stream().map(skolemizeQuads(resourceService, baseUrl))
                .forEachOrdered(dataset::add));

            dataset.add(rdf.createQuad(PreferServerManaged, internalId, RDF.type, ldpType));

            // Add user-supplied data
            if (ldpType.equals(LDP.NonRDFSource)) {
                // Check the expected digest value
                final Digest digest = req.getDigest();
                if (nonNull(digest) && !getDigestForEntity(digest).equals(digest.getDigest())) {
                    return status(BAD_REQUEST);
                }

                final Map<String, String> metadata = singletonMap(CONTENT_TYPE, ofNullable(contentType)
                        .orElse(APPLICATION_OCTET_STREAM));
                final IRI binaryLocation = rdf.createIRI(binaryService.getIdentifierSupplier(req.getPartition())
                        .get());
                dataset.add(rdf.createQuad(PreferServerManaged, internalId, DC.hasPart, binaryLocation));
                dataset.add(rdf.createQuad(PreferServerManaged, binaryLocation, DC.modified,
                            rdf.createLiteral(now().toString(), XSD.dateTime)));
                dataset.add(rdf.createQuad(PreferServerManaged, binaryLocation, DC.format,
                            rdf.createLiteral(ofNullable(contentType).orElse(APPLICATION_OCTET_STREAM))));
                dataset.add(rdf.createQuad(PreferServerManaged, binaryLocation, DC.extent,
                            rdf.createLiteral(Long.toString(entity.length()), XSD.long_)));

                // Persist the content
                persistContent(binaryLocation, metadata);
            } else {
                readEntityIntoDataset(identifier, baseUrl, PreferUserManaged, rdfSyntax.orElse(TURTLE), dataset);

                // Check for any constraints
                checkConstraint(dataset, PreferUserManaged, ldpType, TRELLIS_PREFIX + req.getPartition(),
                        rdfSyntax.orElse(TURTLE));
            }

            if (resourceService.put(internalId, dataset.asDataset())) {
                final ResponseBuilder builder = status(CREATED).location(create(identifier));

                // Add LDP types
                ldpResourceTypes(ldpType).map(IRI::getIRIString).forEach(type -> builder.link(type, "type"));

                return builder;
            }
        }

        LOGGER.error("Unable to persist data to location at {}", internalId.getIRIString());
        return serverError().type(TEXT_PLAIN)
            .entity("Unable to persist data. Please consult the logs for more information");
    }
278315
private JCreditControlRequest createCCR(int ccRequestType, String subscriptionId, String serviceContextId) throws Exception {
    ClientCCASession roSession = roSessions.get(serviceContextId);

    // Create Credit-Control-Request
    JCreditControlRequest ccr = createCreditControlRequest(roSession.getSessions().get(0).createRequest(JCreditControlRequest.code, roAppId, realmName, serverHost));

    // AVPs present by default: Origin-Host, Origin-Realm, Session-Id, Vendor-Specific-Application-Id, Destination-Realm
    AvpSet ccrAvps = ccr.getMessage().getAvps();

    // Add remaining AVPs ... from RFC 4006:
    //<CCR> ::= < Diameter Header: 272, REQ, PXY >
    // < Session-Id > 
    // ccrAvps.addAvp(Avp.SESSION_ID, s.getSessionId());

    // { Origin-Host }
    ccrAvps.removeAvp(Avp.ORIGIN_HOST);
    ccrAvps.addAvp(Avp.ORIGIN_HOST, clientURI, true);

    // { Origin-Realm }
    // ccrAvps.addAvp(Avp.ORIGIN_REALM, realmName, true);

    // { Destination-Realm } 
    // ccrAvps.addAvp(Avp.DESTINATION_REALM, realmName, true);

    // { Auth-Application-Id }
    ccrAvps.addAvp(Avp.AUTH_APPLICATION_ID, 4);
    AvpSet vsaid = ccrAvps.addGroupedAvp(Avp.VENDOR_SPECIFIC_APPLICATION_ID);
    vsaid.addAvp(Avp.VENDOR_ID, 10415);
    vsaid.addAvp(Avp.AUTH_APPLICATION_ID, 4);

    // { Service-Context-Id }
    // 8.42.  Service-Context-Id AVP
    //
    // The Service-Context-Id AVP is of type UTF8String (AVP Code 461) and
    // contains a unique identifier of the Diameter credit-control service
    // specific document that applies to the request (as defined in section
    // 4.1.2).  This is an identifier allocated by the service provider, by
    // the service element manufacturer, or by a standardization body, and
    // MUST uniquely identify a given Diameter credit-control service
    // specific document.  The format of the Service-Context-Id is:
    // 
    // "service-context" "@" "domain"
    // 
    // service-context = Token
    // 
    // The Token is an arbitrary string of characters and digits.
    // 
    // 'domain' represents the entity that allocated the Service-Context-Id.
    // It can be ietf.org, 3gpp.org, etc., if the identifier is allocated by
    // a standardization body, or it can be the FQDN of the service provider
    // (e.g., provider.example.com) or of the vendor (e.g.,
    // vendor.example.com) if the identifier is allocated by a private
    // entity.
    // 
    // This AVP SHOULD be placed as close to the Diameter header as
    // possible.
    // 
    // Service-specific documents that are for private use only (i.e., to
    // one provider's own use, where no interoperability is deemed useful)
    // may define private identifiers without need of coordination.
    // However, when interoperability is wanted, coordination of the
    // identifiers via, for example, publication of an informational RFC is
    // RECOMMENDED in order to make Service-Context-Id globally available.
    ccrAvps.addAvp(461, serviceContextId + SERVICE_CONTEXT_DOMAIN , false);

    // { CC-Request-Type }
    // 8.3.  CC-Request-Type AVP
    //
    // The CC-Request-Type AVP (AVP Code 416) is of type Enumerated and
    // contains the reason for sending the credit-control request message.
    // It MUST be present in all Credit-Control-Request messages.  The
    // following values are defined for the CC-Request-Type AVP:
    // 
    // INITIAL_REQUEST                 1
    //    An Initial request is used to initiate a credit-control session,
    //    and contains credit control information that is relevant to the
    //    initiation.
    // 
    // UPDATE_REQUEST                  2
    //    An Update request contains credit-control information for an
    //    existing credit-control session.  Update credit-control requests
    //    SHOULD be sent every time a credit-control re-authorization is
    //    needed at the expiry of the allocated quota or validity time.
    //    Further, additional service-specific events MAY trigger a
    //    spontaneous Update request.
    // 
    // TERMINATION_REQUEST             3
    //    A Termination request is sent to terminate a credit-control
    //    session and contains credit-control information relevant to the
    //    existing session.
    // 
    // EVENT_REQUEST                   4
    //    An Event request is used when there is no need to maintain any
    //    credit-control session state in the credit-control server.  This
    //    request contains all information relevant to the service, and is
    //    the only request of the service.  The reason for the Event request
    //    is further detailed in the Requested-Action AVP.  The Requested-
    //    Action AVP MUST be included in the Credit-Control-Request message
    //    when CC-Request-Type is set to EVENT_REQUEST.
    ccrAvps.addAvp(416, ccRequestType);

    // { CC-Request-Number }
    // 8.2.  CC-Request-Number AVP
    //
    // The CC-Request-Number AVP (AVP Code 415) is of type Unsigned32 and
    // identifies this request within one session.  As Session-Id AVPs are
    // globally unique, the combination of Session-Id and CC-Request-Number
    // AVPs is also globally unique and can be used in matching credit-
    // control messages with confirmations.  An easy way to produce unique
    // numbers is to set the value to 0 for a credit-control request of type
    // INITIAL_REQUEST and EVENT_REQUEST and to set the value to 1 for the
    // first UPDATE_REQUEST, to 2 for the second, and so on until the value
    // for TERMINATION_REQUEST is one more than for the last UPDATE_REQUEST.
    ccrAvps.addAvp(415, this.ccRequestNumber++);

    // [ Destination-Host ]
    ccrAvps.removeAvp(Avp.DESTINATION_HOST);
    ccrAvps.addAvp(Avp.DESTINATION_HOST, serverURI, false);

    // [ User-Name ] 
    // [ CC-Sub-Session-Id ] 
    // [ Acct-Multi-Session-Id ] 
    // [ Origin-State-Id ] 
    // [ Event-Timestamp ] 

    //*[ Subscription-Id ]
    // 8.46.  Subscription-Id AVP
    // 
    // The Subscription-Id AVP (AVP Code 443) is used to identify the end
    // user's subscription and is of type Grouped.  The Subscription-Id AVP
    // includes a Subscription-Id-Data AVP that holds the identifier and a
    // Subscription-Id-Type AVP that defines the identifier type.
    // 
    // It is defined as follows (per the grouped-avp-def of RFC 3588
    // [DIAMBASE]):
    // 
    // Subscription-Id ::= < AVP Header: 443 >
    //                     { Subscription-Id-Type }
    //                     { Subscription-Id-Data }
    AvpSet subscriptionIdAvp = ccrAvps.addGroupedAvp(443);

    // 8.47.  Subscription-Id-Type AVP
    // 
    // The Subscription-Id-Type AVP (AVP Code 450) is of type Enumerated,
    // and it is used to determine which type of identifier is carried by
    // the Subscription-Id AVP.
    // 
    // This specification defines the following subscription identifiers.
    // However, new Subscription-Id-Type values can be assigned by an IANA
    // designated expert, as defined in section 12.  A server MUST implement
    // all the Subscription-Id-Types required to perform credit
    // authorization for the services it supports, including possible future
    // values.  Unknown or unsupported Subscription-Id-Types MUST be treated
    // according to the 'M' flag rule, as defined in [DIAMBASE].
    // 
    // END_USER_E164                   0
    //   The identifier is in international E.164 format (e.g., MSISDN),
    // according to the ITU-T E.164 numbering plan defined in [E164] and
    // [CE164].
    // 
    // END_USER_IMSI                   1
    //   The identifier is in international IMSI format, according to the
    // ITU-T E.212 numbering plan as defined in [E212] and [CE212].
    // 
    // END_USER_SIP_URI                2
    //   The identifier is in the form of a SIP URI, as defined in [SIP].
    // 
    // END_USER_NAI                    3
    //   The identifier is in the form of a Network Access Identifier, as
    // defined in [NAI].
    // 
    // END_USER_PRIVATE                4
    //   The Identifier is a credit-control server private identifier.
    subscriptionIdAvp.addAvp(450, 2);

    // 8.48.  Subscription-Id-Data AVP
    // 
    // The Subscription-Id-Data AVP (AVP Code 444) is used to identify the
    // end user and is of type UTF8String.  The Subscription-Id-Type AVP
    // defines which type of identifier is used.
    subscriptionIdAvp.addAvp(444, subscriptionId, false);

    // [ Service-Identifier ]  
    // [ Termination-Cause ]

    // [ Requested-Service-Unit ] 
    // 8.18.  Requested-Service-Unit AVP
    //
    // The Requested-Service-Unit AVP (AVP Code 437) is of type Grouped and
    // contains the amount of requested units specified by the Diameter
    // credit-control client.  A server is not required to implement all the
    // unit types, and it must treat unknown or unsupported unit types as
    // invalid AVPs.
    // 
    // The Requested-Service-Unit AVP is defined as follows (per the
    // grouped-avp-def of RFC 3588 [DIAMBASE]):
    //
    // Requested-Service-Unit ::= < AVP Header: 437 >
    //                            [ CC-Time ]
    //                            [ CC-Money ]
    //                            [ CC-Total-Octets ]
    //                            [ CC-Input-Octets ]
    //                            [ CC-Output-Octets ]
    //                            [ CC-Service-Specific-Units ]
    //                           *[ AVP ]
    AvpSet rsuAvp = ccrAvps.addGroupedAvp(437);

    // 8.21.  CC-Time AVP
    //
    // The CC-Time AVP (AVP Code 420) is of type Unsigned32 and indicates
    // the length of the requested, granted, or used time in seconds.
    rsuAvp.addAvp(420, CHARGING_UNITS_TIME);

    // [ Requested-Action ] 
    //*[ Used-Service-Unit ] 
    // 8.19.  Used-Service-Unit AVP
    // 
    // The Used-Service-Unit AVP is of type Grouped (AVP Code 446) and
    // contains the amount of used units measured from the point when the
    // service became active or, if interim interrogations are used during
    // the session, from the point when the previous measurement ended.
    // 
    // The Used-Service-Unit AVP is defined as follows (per the grouped-
    // avp-def of RFC 3588 [DIAMBASE]):
    // 
    //   Used-Service-Unit ::= < AVP Header: 446 >
    //                         [ Tariff-Change-Usage ]
    //                         [ CC-Time ]
    //                         [ CC-Money ]
    //                         [ CC-Total-Octets ]
    //                         [ CC-Input-Octets ]
    //                         [ CC-Output-Octets ]
    //                         [ CC-Service-Specific-Units ]
    //                        *[ AVP ]
    if(ccRequestNumber >= 1) {
      AvpSet usedServiceUnit = ccrAvps.addGroupedAvp(446);
      usedServiceUnit.addAvp(420, this.partialCallDurationCounter);
    }
    // [ AoC-Request-Type ] 
    // [ Multiple-Services-Indicator ] 
    //*[ Multiple-Services-Credit-Control ]  
    //*[ Service-Parameter-Info ]  
    // [ CC-Correlation-Id ] 
    // [ User-Equipment-Info ] 
    //*[ Proxy-Info ]
    //*[ Route-Record ]
    // [ Service-Information ]
    //*[ AVP ]

    DiameterUtilities.printMessage(ccr.getMessage());

    return ccr;
  }
1177606
public Event buildAuthenticationRequestEvent(final RequestContext context) {
        val clients = new ArrayList<WsFedClient>();
        val request = WebUtils.getHttpServletRequestFromExternalWebflowContext(context);
        val service = (Service) context.getFlowScope().get(CasProtocolConstants.PARAMETER_SERVICE);
        this.configurations.forEach(cfg -> {
            val c = new WsFedClient();
            c.setName(cfg.getName());
            val id = UUID.randomUUID().toString();
            val rpId = wsFederationHelper.getRelyingPartyIdentifier(service, cfg);
            c.setAuthorizationUrl(cfg.getAuthorizationUrl(rpId, id));
            c.setReplyingPartyId(rpId);
            c.setId(id);
            c.setRedirectUrl(getRelativeRedirectUrlFor(cfg, service, request));
            c.setAutoRedirect(cfg.isAutoRedirect());
            clients.add(c);

            if (cfg.isAutoRedirect()) {
                WebUtils.putDelegatedAuthenticationProviderPrimary(context, cfg);
            }
        });
        context.getFlowScope().put(PARAMETER_NAME_WSFED_CLIENTS, clients);
        return new EventFactorySupport().event(this, CasWebflowConstants.TRANSITION_ID_PROCEED);
    }
78250
public static ApiContext create(String clientId, String clientSecret, Mode mode) {
        if (instance == null) {
            synchronized (ApiContext.class) {
                if (instance == null) {
                    instance = new ApiContext(clientId, clientSecret, mode);
                }
            }
        }

        return instance;
    }
205418
public static ClientConfigurationBuilder builder(final String url, final String username, final String password) {
        return new ClientConfigurationBuilder(url, username, password);
    }
1020838
public static UriBuilder fromUri(Uri uri) throws IllegalArgumentException {
        if (uri == null)
            throw new IllegalArgumentException("Uri cannot be null");

        UriBuilder b = newInstance();
        b.uri(uri);
        return b;
    }
522007
public Client<? extends Options, ? extends OptionsBuilder, ? extends RequestBuilder> newClient() {
        if (clientClassName == null) {
            return new DefaultClient();
        } else {
            try {
                return (Client) Thread.currentThread().getContextClassLoader().loadClass(clientClassName).newInstance();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }
681125
public HttpClientActionBuilder client(String httpClient) {
		HttpClientActionBuilder clientAction = new HttpClientActionBuilder(action, httpClient)
				.withApplicationContext(applicationContext);
		return clientAction;
	}