Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
27095d90
Commit
27095d90
authored
Sep 17, 2020
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
10ad53af
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
74 additions
and
22 deletions
+74
-22
Builder.java
...pringframework/boot/buildpack/platform/build/Builder.java
+18
-0
DockerApi.java
...ngframework/boot/buildpack/platform/docker/DockerApi.java
+2
-1
DockerRegistryAuthentication.java
...rm/docker/configuration/DockerRegistryAuthentication.java
+6
-14
DockerRegistryTokenAuthentication.java
...cker/configuration/DockerRegistryTokenAuthentication.java
+1
-1
DockerRegistryUserAuthentication.java
...ocker/configuration/DockerRegistryUserAuthentication.java
+1
-1
JsonEncodedDockerRegistryAuthentication.java
...onfiguration/JsonEncodedDockerRegistryAuthentication.java
+42
-0
HttpClientTransport.java
...ldpack/platform/docker/transport/HttpClientTransport.java
+4
-5
No files found.
spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/build/Builder.java
View file @
27095d90
...
...
@@ -45,18 +45,36 @@ public class Builder {
private
final
DockerApi
docker
;
/**
* Create a new builder instance.
*/
public
Builder
()
{
this
(
BuildLog
.
toSystemOut
());
}
/**
* Create a new builder instance.
* @param dockerConfiguration the docker configuration
* @since 2.4.0
*/
public
Builder
(
DockerConfiguration
dockerConfiguration
)
{
this
(
BuildLog
.
toSystemOut
(),
dockerConfiguration
);
}
/**
* Create a new builder instance.
* @param log a logger used to record output
*/
public
Builder
(
BuildLog
log
)
{
this
(
log
,
new
DockerApi
());
}
/**
* Create a new builder instance.
* @param log a logger used to record output
* @param dockerConfiguration the docker configuration
* @since 2.4.0
*/
public
Builder
(
BuildLog
log
,
DockerConfiguration
dockerConfiguration
)
{
this
(
log
,
new
DockerApi
(
dockerConfiguration
));
}
...
...
spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/DockerApi.java
View file @
27095d90
...
...
@@ -74,7 +74,8 @@ public class DockerApi {
/**
* Create a new {@link DockerApi} instance.
* @param dockerConfiguration the Docker configuration options
* @param dockerConfiguration the docker configuration
* @since 2.4.0
*/
public
DockerApi
(
DockerConfiguration
dockerConfiguration
)
{
this
(
HttpTransport
.
create
(
dockerConfiguration
));
...
...
spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/configuration/DockerRegistryAuthentication.java
View file @
27095d90
...
...
@@ -16,26 +16,18 @@
package
org
.
springframework
.
boot
.
buildpack
.
platform
.
docker
.
configuration
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
org.springframework.boot.buildpack.platform.json.SharedObjectMapper
;
import
org.springframework.util.Base64Utils
;
/**
* Docker registry authentication configuration.
*
* @author Scott Frederick
* @since 2.4.0
*/
public
abstract
class
DockerRegistryAuthentication
{
public
interface
DockerRegistryAuthentication
{
public
String
createAuthHeader
()
{
try
{
return
Base64Utils
.
encodeToUrlSafeString
(
SharedObjectMapper
.
get
().
writeValueAsBytes
(
this
));
}
catch
(
JsonProcessingException
ex
)
{
throw
new
IllegalStateException
(
"Error creating Docker registry authentication header"
,
ex
);
}
}
/**
* Create the auth header that should be used for docker authentication.
* @return the auth header
*/
String
createAuthHeader
();
}
spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/configuration/DockerRegistryTokenAuthentication.java
View file @
27095d90
...
...
@@ -23,7 +23,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
*
* @author Scott Frederick
*/
class
DockerRegistryTokenAuthentication
extends
DockerRegistryAuthentication
{
class
DockerRegistryTokenAuthentication
extends
JsonEncoded
DockerRegistryAuthentication
{
@JsonProperty
(
"identitytoken"
)
private
final
String
token
;
...
...
spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/configuration/DockerRegistryUserAuthentication.java
View file @
27095d90
...
...
@@ -23,7 +23,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
*
* @author Scott Frederick
*/
class
DockerRegistryUserAuthentication
extends
DockerRegistryAuthentication
{
class
DockerRegistryUserAuthentication
extends
JsonEncoded
DockerRegistryAuthentication
{
@JsonProperty
private
final
String
username
;
...
...
spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/configuration/JsonEncodedDockerRegistryAuthentication.java
0 → 100644
View file @
27095d90
/*
* Copyright 2012-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
buildpack
.
platform
.
docker
.
configuration
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
org.springframework.boot.buildpack.platform.json.SharedObjectMapper
;
import
org.springframework.util.Base64Utils
;
/**
* {@link DockerRegistryAuthentication} that uses creates a Base64 encoded auth header
* value based on the JSON created from the instance.
*
* @author Scott Frederick
*/
class
JsonEncodedDockerRegistryAuthentication
implements
DockerRegistryAuthentication
{
@Override
public
String
createAuthHeader
()
{
try
{
return
Base64Utils
.
encodeToUrlSafeString
(
SharedObjectMapper
.
get
().
writeValueAsBytes
(
this
));
}
catch
(
JsonProcessingException
ex
)
{
throw
new
IllegalStateException
(
"Error creating Docker registry authentication header"
,
ex
);
}
}
}
spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/transport/HttpClientTransport.java
View file @
27095d90
...
...
@@ -37,6 +37,7 @@ import org.apache.http.entity.AbstractHttpEntity;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.springframework.boot.buildpack.platform.docker.configuration.DockerConfiguration
;
import
org.springframework.boot.buildpack.platform.docker.configuration.DockerRegistryAuthentication
;
import
org.springframework.boot.buildpack.platform.io.Content
;
import
org.springframework.boot.buildpack.platform.io.IOConsumer
;
import
org.springframework.boot.buildpack.platform.json.SharedObjectMapper
;
...
...
@@ -122,11 +123,9 @@ abstract class HttpClientTransport implements HttpTransport {
}
private
String
buildRegistryAuthHeader
(
DockerConfiguration
dockerConfiguration
)
{
if
(
dockerConfiguration
==
null
||
dockerConfiguration
.
getRegistryAuthentication
()
==
null
)
{
return
null
;
}
String
authHeader
=
dockerConfiguration
.
getRegistryAuthentication
().
createAuthHeader
();
DockerRegistryAuthentication
authentication
=
(
dockerConfiguration
!=
null
)
?
dockerConfiguration
.
getRegistryAuthentication
()
:
null
;
String
authHeader
=
(
authentication
!=
null
)
?
authentication
.
createAuthHeader
()
:
null
;
return
(
StringUtils
.
hasText
(
authHeader
))
?
authHeader
:
null
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment