001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019package org.eclipse.aether.spi.connector.transport.http; 020 021import java.util.Collections; 022import java.util.HashMap; 023import java.util.Map; 024 025import org.eclipse.aether.spi.connector.transport.TransportListener; 026import org.eclipse.aether.transfer.HttpTransportProperty.HttpVersion; 027import org.eclipse.aether.transfer.HttpTransportProperty.Key; 028import org.eclipse.aether.transfer.HttpTransportProperty.SslProtocol; 029import org.eclipse.aether.transfer.TransferEvent; 030 031/** 032 * Builder for HTTP transport properties used in {@link TransportListener#transportPropertiesAvailable(Map)}. 033 * @since 2.0.21 034 */ 035public final class HttpTransportPropertiesBuilder { 036 private final Map<TransferEvent.TransportPropertyKey, Object> properties = new HashMap<>(); 037 038 public HttpTransportPropertiesBuilder(HttpVersion version) { 039 this.properties.put(Key.HTTP_VERSION, version); 040 } 041 042 public HttpTransportPropertiesBuilder withSslProtocol(String name) { 043 return withSslProtocol(SslProtocol.fromStandardName(name)); 044 } 045 046 public HttpTransportPropertiesBuilder withSslProtocol(SslProtocol sslProtocol) { 047 this.properties.put(Key.SSL_PROTOCOL, sslProtocol); 048 return this; 049 } 050 051 public HttpTransportPropertiesBuilder withSslCipherSuite(String cipherSuite) { 052 this.properties.put(Key.SSL_CIPHER_SUITE, cipherSuite); 053 return this; 054 } 055 056 public HttpTransportPropertiesBuilder withContentCoding(String contentCoding) { 057 this.properties.put(Key.CONTENT_CODING, contentCoding); 058 return this; 059 } 060 061 public Map<TransferEvent.TransportPropertyKey, Object> build() { 062 return Collections.unmodifiableMap(new HashMap<>(properties)); 063 } 064}