mirror of
https://github.com/jlengrand/helidon.git
synced 2026-03-10 08:21:17 +00:00
Removed deprecations (#1892)
- Removed deprecated methods - Updated deprecated comments to clearly mark 2.0.0 deprecations
This commit is contained in:
@@ -776,11 +776,6 @@
|
||||
<artifactId>helidon-integrations-cdi-jpa</artifactId>
|
||||
<version>${helidon.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.helidon.integrations.cdi</groupId>
|
||||
<artifactId>helidon-integrations-cdi-jpa-weld</artifactId>
|
||||
<version>${helidon.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.helidon.integrations.cdi</groupId>
|
||||
<artifactId>helidon-integrations-cdi-jta</artifactId>
|
||||
|
||||
@@ -167,7 +167,7 @@ public interface Resource {
|
||||
* @param config configuration
|
||||
* @param prefix prefix of the resource
|
||||
* @return resource if configured
|
||||
* @deprecated use {@link #create(io.helidon.config.Config)} instead (and change the configuration to use
|
||||
* @deprecated since 2.0.0 use {@link #create(io.helidon.config.Config)} instead (and change the configuration to use
|
||||
* {@code .resource.type} instead of prefixes
|
||||
*/
|
||||
@Deprecated
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -41,7 +41,7 @@ import io.helidon.common.reactive.Single;
|
||||
* It is possible to register function to convert publisher to {@link io.helidon.common.reactive.Single} of a single entity using
|
||||
* {@link #registerReader(Class, Reader)} or {@link #registerReader(Predicate, Reader)} methods. It
|
||||
* is then possible to use {@link #as(Class)} method to obtain such entity.
|
||||
* @deprecated use {@code io.helidon.media.common.MessageBodyReadableContent} instead
|
||||
* @deprecated since 2.0.0, use {@code io.helidon.media.common.MessageBodyReadableContent} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public interface Content extends Flow.Publisher<DataChunk> {
|
||||
@@ -73,7 +73,7 @@ public interface Content extends Flow.Publisher<DataChunk> {
|
||||
*
|
||||
* @param function a function that transforms a given publisher (that is either the original
|
||||
* publisher or the publisher transformed by the last previously registered filter).
|
||||
* @deprecated use {@code io.helidon.media.common.MessageBodyReaderContext.registerFilter}
|
||||
* @deprecated since 2.0.0, use {@code io.helidon.media.common.MessageBodyReaderContext.registerFilter}
|
||||
*/
|
||||
@Deprecated
|
||||
void registerFilter(Function<Flow.Publisher<DataChunk>, Flow.Publisher<DataChunk>> function);
|
||||
@@ -93,7 +93,7 @@ public interface Content extends Flow.Publisher<DataChunk> {
|
||||
* If an exception is thrown, the resulting completion stage of
|
||||
* {@link #as(Class)} method call ends exceptionally.
|
||||
* @param <T> the requested type
|
||||
* @deprecated use {@code io.helidon.media.common.MessageBodyReaderContext.registerReader}
|
||||
* @deprecated since 2.0.0, use {@code io.helidon.media.common.MessageBodyReaderContext.registerReader}
|
||||
*/
|
||||
@Deprecated
|
||||
<T> void registerReader(Class<T> type, Reader<T> reader);
|
||||
@@ -116,7 +116,7 @@ public interface Content extends Flow.Publisher<DataChunk> {
|
||||
* If an exception is thrown, the resulting completion stage of
|
||||
* {@link #as(Class)} method call ends exceptionally.
|
||||
* @param <T> the requested type
|
||||
* @deprecated use {@code io.helidon.media.common.MessageBodyReaderContext.registerReader}
|
||||
* @deprecated since 2.0.0, use {@code io.helidon.media.common.MessageBodyReaderContext.registerReader}
|
||||
*/
|
||||
@Deprecated
|
||||
<T> void registerReader(Predicate<Class<?>> predicate, Reader<T> reader);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -24,7 +24,7 @@ import java.util.function.BiFunction;
|
||||
* The Reader transforms a {@link DataChunk} publisher into a completion stage of the associated type.
|
||||
*
|
||||
* @param <R> the requested type
|
||||
* @deprecated use {@code io.helidon.media.common.MessageBodyReader} instead
|
||||
* @deprecated since 2.0.0, use {@code io.helidon.media.common.MessageBodyReader} instead
|
||||
*/
|
||||
@FunctionalInterface
|
||||
@Deprecated
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -78,28 +78,6 @@ abstract class JdbcStatement<S extends DbStatement<S, R>, R> extends AbstractSta
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch to {@link #build(java.sql.Connection, io.helidon.dbclient.DbClientServiceContext)} and use services.
|
||||
*
|
||||
* @param connection connection to use
|
||||
* @return prepared statement
|
||||
*/
|
||||
@Deprecated
|
||||
protected PreparedStatement build(Connection connection) {
|
||||
LOGGER.fine(() -> String.format("Building SQL statement: %s", statement()));
|
||||
switch (paramType()) {
|
||||
// Statement may not contain any parameters, no conversion is needed.
|
||||
case UNKNOWN:
|
||||
return prepareStatement(connection, statementName(), statement());
|
||||
case INDEXED:
|
||||
return prepareIndexedStatement(connection, statementName(), statement(), indexedParams());
|
||||
case NAMED:
|
||||
return prepareNamedStatement(connection, statementName(), statement(), namedParams());
|
||||
default:
|
||||
throw new IllegalStateException("Unknown SQL statement type");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String dbType() {
|
||||
return dbType;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2019, 2020 Oracle and/or its affiliates.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -18,15 +18,14 @@
|
||||
# For more information see $JAVA_HOME/jre/lib/logging.properties
|
||||
|
||||
# Send messages to the console
|
||||
handlers=java.util.logging.ConsoleHandler
|
||||
handlers=io.helidon.common.HelidonConsoleHandler
|
||||
|
||||
# Global default logging level. Can be overriden by specific handlers and loggers
|
||||
.level=INFO
|
||||
|
||||
# Helidon Web Server has a custom log formatter that extends SimpleFormatter.
|
||||
# It replaces "!thread!" with the current thread name
|
||||
java.util.logging.ConsoleHandler.level=INFO
|
||||
java.util.logging.ConsoleHandler.formatter=io.helidon.webserver.WebServerLogFormatter
|
||||
io.helidon.common.HelidonConsoleHandler.level=ALL
|
||||
java.util.logging.SimpleFormatter.format=%1$tY.%1$tm.%1$td %1$tH:%1$tM:%1$tS %4$s %3$s !thread!: %5$s%6$s%n
|
||||
|
||||
#Component specific log levels
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2019, 2020 Oracle and/or its affiliates.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -18,15 +18,14 @@
|
||||
# For more information see $JAVA_HOME/jre/lib/logging.properties
|
||||
|
||||
# Send messages to the console
|
||||
handlers=java.util.logging.ConsoleHandler
|
||||
handlers=io.helidon.common.HelidonConsoleHandler
|
||||
|
||||
# Global default logging level. Can be overriden by specific handlers and loggers
|
||||
.level=INFO
|
||||
|
||||
# Helidon Web Server has a custom log formatter that extends SimpleFormatter.
|
||||
# It replaces "!thread!" with the current thread name
|
||||
java.util.logging.ConsoleHandler.level=INFO
|
||||
java.util.logging.ConsoleHandler.formatter=io.helidon.webserver.WebServerLogFormatter
|
||||
io.helidon.common.HelidonConsoleHandler.level=ALL
|
||||
java.util.logging.SimpleFormatter.format=%1$tY.%1$tm.%1$td %1$tH:%1$tM:%1$tS %4$s %3$s !thread!: %5$s%6$s%n
|
||||
|
||||
#Component specific log levels
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2019, 2020 Oracle and/or its affiliates.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -18,15 +18,14 @@
|
||||
# For more information see $JAVA_HOME/jre/lib/logging.properties
|
||||
|
||||
# Send messages to the console
|
||||
handlers=java.util.logging.ConsoleHandler
|
||||
handlers=io.helidon.common.HelidonConsoleHandler
|
||||
|
||||
# Global default logging level. Can be overriden by specific handlers and loggers
|
||||
.level=INFO
|
||||
|
||||
# Helidon Web Server has a custom log formatter that extends SimpleFormatter.
|
||||
# It replaces "!thread!" with the current thread name
|
||||
java.util.logging.ConsoleHandler.level=INFO
|
||||
java.util.logging.ConsoleHandler.formatter=io.helidon.webserver.WebServerLogFormatter
|
||||
io.helidon.common.HelidonConsoleHandler.level=ALL
|
||||
java.util.logging.SimpleFormatter.format=%1$tY.%1$tm.%1$td %1$tH:%1$tM:%1$tS %4$s %3$s !thread!: %5$s%6$s%n
|
||||
|
||||
#Component specific log levels
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -99,12 +99,13 @@ public class AtnProvider extends SynchronousProvider implements AuthenticationPr
|
||||
}
|
||||
|
||||
private List<Auth> fromAnnotations(EndpointConfig endpointConfig) {
|
||||
return endpointConfig.combineAnnotations(Authentications.class, EndpointConfig.AnnotationScope.METHOD)
|
||||
.stream()
|
||||
.map(Authentications::value)
|
||||
.flatMap(Arrays::stream)
|
||||
.map(Auth::new)
|
||||
.collect(Collectors.toList());
|
||||
return endpointConfig.securityLevels()
|
||||
.stream()
|
||||
.flatMap(level -> level.combineAnnotations(Authentications.class, EndpointConfig.AnnotationScope.METHOD).stream())
|
||||
.map(Authentications::value)
|
||||
.flatMap(Arrays::stream)
|
||||
.map(Auth::new)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private Subject buildSubject(Auth authentication) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,6 +30,7 @@ import io.helidon.security.ProviderRequest;
|
||||
import io.helidon.security.Security;
|
||||
import io.helidon.security.SecurityContext;
|
||||
import io.helidon.security.SecurityEnvironment;
|
||||
import io.helidon.security.SecurityLevel;
|
||||
import io.helidon.security.SecurityResponse;
|
||||
import io.helidon.security.Subject;
|
||||
|
||||
@@ -93,9 +94,13 @@ public class AtnProviderSyncTest {
|
||||
when(context.service()).thenReturn(Optional.empty());
|
||||
|
||||
SecurityEnvironment se = SecurityEnvironment.create();
|
||||
|
||||
SecurityLevel level = SecurityLevel.create("mock")
|
||||
.withClassAnnotations(Map.of(AtnProviderSync.AtnAnnot.class, List.of(annot)))
|
||||
.build();
|
||||
|
||||
EndpointConfig ep = EndpointConfig.builder()
|
||||
.annotations(EndpointConfig.AnnotationScope.CLASS,
|
||||
Map.of(AtnProviderSync.AtnAnnot.class, List.of(annot)))
|
||||
.securityLevels(List.of(level))
|
||||
.build();
|
||||
|
||||
ProviderRequest request = mock(ProviderRequest.class);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -89,7 +89,6 @@ public final class BackendServiceClient {
|
||||
* @return future with all records
|
||||
*/
|
||||
public CompletionStage<JsonArray> getAll(final SpanContext spanContext) {
|
||||
|
||||
Span span = tracer.buildSpan("todos.get-all")
|
||||
.asChildOf(spanContext)
|
||||
.start();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -17,6 +17,7 @@
|
||||
package io.helidon.demo.todos.frontend;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import javax.json.JsonObject;
|
||||
@@ -30,6 +31,8 @@ import io.helidon.webserver.ServerRequest;
|
||||
import io.helidon.webserver.ServerResponse;
|
||||
import io.helidon.webserver.Service;
|
||||
|
||||
import io.opentracing.Span;
|
||||
import io.opentracing.SpanContext;
|
||||
import org.eclipse.microprofile.metrics.Counter;
|
||||
import org.eclipse.microprofile.metrics.Metadata;
|
||||
import org.eclipse.microprofile.metrics.MetricRegistry;
|
||||
@@ -135,10 +138,23 @@ public final class TodosHandler implements Service {
|
||||
* @param res the server response
|
||||
*/
|
||||
private void getAll(final ServerRequest req, final ServerResponse res) {
|
||||
AtomicReference<Span> createdSpan = new AtomicReference<>();
|
||||
|
||||
SpanContext spanContext = req.spanContext().orElseGet(() -> {
|
||||
Span mySpan = req.tracer().buildSpan("getAll").start();
|
||||
createdSpan.set(mySpan);
|
||||
return mySpan.context();
|
||||
});
|
||||
secure(req, res, sc -> {
|
||||
bsc.getAll(req.spanContext())
|
||||
bsc.getAll(spanContext)
|
||||
.thenAccept(res::send)
|
||||
.exceptionally(t -> sendError(t, res));
|
||||
.exceptionally(t -> sendError(t, res))
|
||||
.whenComplete((noting, throwable) -> {
|
||||
Span mySpan = createdSpan.get();
|
||||
if (null != mySpan) {
|
||||
mySpan.finish();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -57,10 +57,11 @@ public final class TranslatorFrontendService implements Service {
|
||||
|
||||
Response backendResponse = backendTarget
|
||||
.property(ClientTracingFilter.TRACER_PROPERTY_NAME, request.tracer())
|
||||
.property(ClientTracingFilter.CURRENT_SPAN_CONTEXT_PROPERTY_NAME, request.spanContext())
|
||||
.property(ClientTracingFilter.CURRENT_SPAN_CONTEXT_PROPERTY_NAME, request.spanContext().orElse(null))
|
||||
.queryParam("q", query)
|
||||
.queryParam("lang", language)
|
||||
.request().get();
|
||||
.request()
|
||||
.get();
|
||||
|
||||
final String result;
|
||||
if (backendResponse.getStatusInfo().getFamily() == Response.Status.Family.SUCCESSFUL) {
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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 io.helidon.grpc.server;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import io.opentracing.contrib.grpc.OperationNameConstructor;
|
||||
|
||||
/**
|
||||
* Backward compatibility only.
|
||||
* @deprecated use {@link io.helidon.grpc.server.GrpcTracingConfig}
|
||||
*/
|
||||
@Deprecated
|
||||
public class TracingConfiguration extends GrpcTracingConfig {
|
||||
private TracingConfiguration(OperationNameConstructor operationNameConstructor,
|
||||
Set<ServerRequestAttribute> tracedAttributes,
|
||||
boolean streaming,
|
||||
boolean verbose) {
|
||||
super(operationNameConstructor, tracedAttributes, streaming, verbose);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the configuration of a tracer.
|
||||
* @deprecated use {@link GrpcTracingConfig#builder()} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static class Builder {
|
||||
/**
|
||||
* Creates a Builder with default configuration.
|
||||
*/
|
||||
Builder() {
|
||||
operationNameConstructor = OperationNameConstructor.DEFAULT;
|
||||
streaming = false;
|
||||
verbose = false;
|
||||
tracedAttributes = Collections.emptySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param operationNameConstructor for all spans
|
||||
* @return this Builder with configured operation name
|
||||
*/
|
||||
public Builder withOperationName(OperationNameConstructor operationNameConstructor) {
|
||||
this.operationNameConstructor = operationNameConstructor;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param attributes to set as tags on server spans
|
||||
* @return this Builder configured to trace request
|
||||
* attributes
|
||||
*/
|
||||
public Builder withTracedAttributes(ServerRequestAttribute... attributes) {
|
||||
tracedAttributes = new HashSet<>(Arrays.asList(attributes));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs streaming events to server spans.
|
||||
*
|
||||
* @return this Builder configured to log streaming events
|
||||
*/
|
||||
public Builder withStreaming() {
|
||||
streaming = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs all request life-cycle events to server spans.
|
||||
*
|
||||
* @return this Builder configured to be verbose
|
||||
*/
|
||||
public Builder withVerbosity() {
|
||||
verbose = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a GrpcTracingConfig with this Builder's configuration
|
||||
*/
|
||||
public TracingConfiguration build() {
|
||||
return new TracingConfiguration(operationNameConstructor, tracedAttributes, streaming, verbose);
|
||||
}
|
||||
|
||||
/**
|
||||
* A flag indicating whether to log streaming.
|
||||
*/
|
||||
private OperationNameConstructor operationNameConstructor;
|
||||
|
||||
/**
|
||||
* A flag indicating verbose logging.
|
||||
*/
|
||||
private boolean streaming;
|
||||
|
||||
/**
|
||||
* A flag indicating verbose logging.
|
||||
*/
|
||||
private boolean verbose;
|
||||
|
||||
/**
|
||||
* The set of attributes to log in spans.
|
||||
*/
|
||||
private Set<ServerRequestAttribute> tracedAttributes;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -170,16 +170,6 @@ public class GrpcServerConfigurationTest {
|
||||
assertThat(configuration.tracingConfig(), is(sameInstance(tracingConfig)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldSetTracingConfigurationOldConfig() {
|
||||
TracingConfiguration tracingConfig = mock(TracingConfiguration.class);
|
||||
GrpcServerConfiguration configuration = GrpcServerConfiguration.builder()
|
||||
.tracingConfig(tracingConfig)
|
||||
.build();
|
||||
|
||||
assertThat(configuration.tracingConfig(), is(sameInstance(tracingConfig)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldNotSetNullTracingConfiguration() {
|
||||
GrpcServerConfiguration configuration = GrpcServerConfiguration.builder()
|
||||
|
||||
@@ -739,159 +739,6 @@ public class PersistenceUnitInfoBean implements PersistenceUnitInfo {
|
||||
* Static methods.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Given a {@link Persistence} (a Java object representation of a
|
||||
* {@code META-INF/persistence.xml} resource), a {@link URL}
|
||||
* representing the root of all persistence units, a {@link Map}
|
||||
* of unlisted managed classes (entity classes, mapped
|
||||
* superclasses and so on) indexed by persistence unit name, and a
|
||||
* {@link DataSourceProvider} that can provide {@link DataSource}
|
||||
* instances, returns a {@link Collection} of {@link
|
||||
* PersistenceUnitInfoBean} instances representing all the
|
||||
* persistence units in play.
|
||||
*
|
||||
* <p>This method never returns {@code null}.</p>
|
||||
*
|
||||
* @param persistence a {@link Persistence} containing bootstrap
|
||||
* information from which persistence units and their
|
||||
* configuration may be deduced; may be {@code null} in which case
|
||||
* an {@linkplain Collection#isEmpty() empty} {@link Collection}
|
||||
* will be returned
|
||||
*
|
||||
* @param classLoader a {@link ClassLoader} that the resulting
|
||||
* {@link PersistenceUnitInfoBean} instances will use; may be
|
||||
* {@code null}
|
||||
*
|
||||
* @param tempClassLoaderSupplier a {@link Supplier} of a {@link
|
||||
* ClassLoader} that will be used to implement the {@link
|
||||
* PersistenceUnitInfo#getNewTempClassLoader()} method; may be
|
||||
* {@code null}
|
||||
*
|
||||
* @param rootUrl the {@link URL} representing the root of all
|
||||
* persistence units; must not be {@code null}
|
||||
*
|
||||
* @param unlistedClasses a {@link Map} of managed classes indexed
|
||||
* by persistence unit name whose values might not be explicitly
|
||||
* listed in a {@link PersistenceUnit}; may be {@code null}
|
||||
*
|
||||
* @param dataSourceProvider a {@link DataSourceProvider}; must
|
||||
* not be {@code null}
|
||||
*
|
||||
* @return a non-{@code null} {@link Collection} of {@link
|
||||
* PersistenceUnitInfoBean} instances
|
||||
*
|
||||
* @exception MalformedURLException if a {@link URL} could not be
|
||||
* constructed
|
||||
*
|
||||
* @exception NullPointerException if {@code rootUrl} or {@code
|
||||
* dataSourceProvider} is {@code null}
|
||||
*
|
||||
* @see #fromPersistenceUnit(Persistence.PersistenceUnit,
|
||||
* ClassLoader, Supplier, URL, Map, DataSourceProvider)
|
||||
*
|
||||
* @see PersistenceUnitInfo
|
||||
*
|
||||
* @deprecated Please use the {@link
|
||||
* #fromPersistenceUnit(PersistenceUnit, ClassLoader, Supplier,
|
||||
* URL, Map, Supplier)} method instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final Collection<? extends PersistenceUnitInfoBean>
|
||||
fromPersistence(final Persistence persistence,
|
||||
final ClassLoader classLoader,
|
||||
final Supplier<? extends ClassLoader> tempClassLoaderSupplier,
|
||||
final URL rootUrl,
|
||||
Map<? extends String, ? extends Set<? extends Class<?>>> unlistedClasses,
|
||||
final DataSourceProvider dataSourceProvider)
|
||||
throws MalformedURLException {
|
||||
return fromPersistence(persistence,
|
||||
classLoader,
|
||||
tempClassLoaderSupplier,
|
||||
rootUrl,
|
||||
unlistedClasses,
|
||||
() -> dataSourceProvider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a {@link Collection} of {@link
|
||||
* PersistenceUnitInfoBean} instances from a supplied {@link
|
||||
* Persistence} object.
|
||||
*
|
||||
* @param persistence the {@link Persistence} from which {@link
|
||||
* PersistenceUnitInfoBean} instances should be synthesized; must
|
||||
* not be {@code null}
|
||||
*
|
||||
* @param classLoader classLoader a {@link ClassLoader} that the resulting
|
||||
* {@link PersistenceUnitInfoBean}s will use; may be {@code null}
|
||||
*
|
||||
* @param tempClassLoaderSupplier a {@link Supplier} of a {@link
|
||||
* ClassLoader} that will be used to implement the {@link
|
||||
* PersistenceUnitInfo#getNewTempClassLoader()} method; may be
|
||||
* {@code null}
|
||||
*
|
||||
* @param rootUrl the {@link URL} representing the root of the
|
||||
* persistence units; must not be {@code null}
|
||||
*
|
||||
* @param unlistedClasses a {@link Map} of managed classes indexed
|
||||
* by persistence unit name whose values might not be explicitly
|
||||
* listed in the supplied {@link PersistenceUnit}s; may be {@code
|
||||
* null}
|
||||
*
|
||||
* @param dataSourceProviderSupplier a {@link Supplier} capable of
|
||||
* producing {@link DataSourceProvider} instances; must not be
|
||||
* {@code null}
|
||||
*
|
||||
* @return a non-{@code null} {@link Collection} of {@link
|
||||
* PersistenceUnitInfoBean}s
|
||||
*
|
||||
* @exception MalformedURLException if a {@link URL} could not be
|
||||
* constructed
|
||||
*
|
||||
* @exception NullPointerException if {@code persistence}, {@code
|
||||
* rootUrl} or {@code dataSourceProviderSupplier} is {@code null}
|
||||
*
|
||||
* @deprecated Please use the {@link
|
||||
* #fromPersistenceUnit(PersistenceUnit, ClassLoader, Supplier,
|
||||
* URL, Map, Supplier)} method instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static final Collection<? extends PersistenceUnitInfoBean>
|
||||
fromPersistence(final Persistence persistence,
|
||||
final ClassLoader classLoader,
|
||||
final Supplier<? extends ClassLoader> tempClassLoaderSupplier,
|
||||
final URL rootUrl,
|
||||
Map<? extends String, ? extends Set<? extends Class<?>>> unlistedClasses,
|
||||
final Supplier<? extends DataSourceProvider> dataSourceProviderSupplier)
|
||||
throws MalformedURLException {
|
||||
|
||||
Objects.requireNonNull(rootUrl);
|
||||
if (unlistedClasses == null) {
|
||||
unlistedClasses = Collections.emptyMap();
|
||||
}
|
||||
final Collection<PersistenceUnitInfoBean> returnValue;
|
||||
if (persistence == null) {
|
||||
returnValue = Collections.emptySet();
|
||||
} else {
|
||||
final Collection<? extends PersistenceUnit> persistenceUnits = persistence.getPersistenceUnit();
|
||||
if (persistenceUnits == null || persistenceUnits.isEmpty()) {
|
||||
returnValue = Collections.emptySet();
|
||||
} else {
|
||||
returnValue = new ArrayList<>();
|
||||
for (final PersistenceUnit persistenceUnit : persistenceUnits) {
|
||||
assert persistenceUnit != null;
|
||||
returnValue.add(fromPersistenceUnit(persistenceUnit,
|
||||
classLoader,
|
||||
tempClassLoaderSupplier,
|
||||
rootUrl,
|
||||
unlistedClasses,
|
||||
dataSourceProviderSupplier));
|
||||
}
|
||||
}
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a {@link PersistenceUnit} (a Java object representation
|
||||
* of a {@code <persistence-unit>} element in a {@code
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
# Helidon JPA Weld Integration
|
||||
|
||||
CAUTION: This project is now superfluous, deprecated and slated for
|
||||
eventual removal. Please simply use the [`jpa-cdi`](../jpa-cdi)
|
||||
project instead.
|
||||
@@ -1,164 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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
|
||||
|
||||
http://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.
|
||||
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||
http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>io.helidon.integrations.cdi</groupId>
|
||||
<artifactId>helidon-integrations-cdi-project</artifactId>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>helidon-integrations-cdi-jpa-weld</artifactId>
|
||||
<name>Helidon CDI Integrations JPA Weld</name>
|
||||
|
||||
<!--
|
||||
This project is deprecated and slated for eventual removal
|
||||
from Helidon.
|
||||
|
||||
Please see the ../jpa-cdi project instead.
|
||||
-->
|
||||
|
||||
<properties>
|
||||
<show>package</show>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- Test-scoped dependencies. -->
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest-all</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.helidon.microprofile.cdi</groupId>
|
||||
<artifactId>helidon-microprofile-cdi</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-jdk14</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>helidon-integrations-cdi-jta-weld</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>helidon-integrations-cdi-datasource-hikaricp</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>helidon-integrations-cdi-eclipselink</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.helidon.microprofile.config</groupId>
|
||||
<artifactId>helidon-microprofile-config</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Runtime-scoped dependencies. -->
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>helidon-integrations-cdi-jpa</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss</groupId>
|
||||
<artifactId>jandex</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Provided-scoped dependencies. -->
|
||||
<dependency>
|
||||
<groupId>jakarta.annotation</groupId>
|
||||
<artifactId>jakarta.annotation-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jakarta.enterprise</groupId>
|
||||
<artifactId>jakarta.enterprise.cdi-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jakarta.persistence</groupId>
|
||||
<artifactId>jakarta.persistence-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jakarta.transaction</groupId>
|
||||
<artifactId>jakarta.transaction-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jakarta.validation</groupId>
|
||||
<artifactId>jakarta.validation-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Compile-scoped dependencies. -->
|
||||
<dependency>
|
||||
<groupId>org.jboss.weld</groupId>
|
||||
<artifactId>weld-spi</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<java.util.logging.config.file>${basedir}/src/test/java/logging.properties</java.util.logging.config.file>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.jboss.jandex</groupId>
|
||||
<artifactId>jandex-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-index</id>
|
||||
<goals>
|
||||
<goal>jandex</goal>
|
||||
</goals>
|
||||
<phase>process-classes</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -1,166 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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 io.helidon.integrations.cdi.jpa.weld;
|
||||
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.enterprise.inject.spi.InjectionPoint;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
|
||||
import org.jboss.weld.injection.spi.JpaInjectionServices;
|
||||
import org.jboss.weld.injection.spi.ResourceReferenceFactory;
|
||||
|
||||
/**
|
||||
* A {@link JpaInjectionServices} implementation that integrates JPA
|
||||
* functionality into Weld-based CDI environments.
|
||||
*
|
||||
* @see JpaInjectionServices
|
||||
*
|
||||
* @deprecated This extension is no longer needed and is slated for
|
||||
* removal.
|
||||
*/
|
||||
@Deprecated
|
||||
final class WeldJpaInjectionServices implements JpaInjectionServices {
|
||||
|
||||
|
||||
/*
|
||||
* Static fields.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* The {@link Logger} for use by all instances of this class.
|
||||
*
|
||||
* <p>This field is never {@code null}.</p>
|
||||
*/
|
||||
private static final Logger LOGGER = Logger.getLogger(WeldJpaInjectionServices.class.getName(),
|
||||
WeldJpaInjectionServices.class.getPackage().getName() + ".Messages");
|
||||
|
||||
|
||||
/*
|
||||
* Constructors.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new {@link WeldJpaInjectionServices}.
|
||||
*
|
||||
* <p>Oddly, the fact that this constructor is {@code private}
|
||||
* does not prevent Weld from loading it as a service. This is an
|
||||
* unexpected bonus as nothing about this class should be {@code
|
||||
* public}.</p>
|
||||
*/
|
||||
WeldJpaInjectionServices() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Throws an {@link IllegalArgumentException} when invoked.
|
||||
*
|
||||
* @exception IllegalArgumentException when invoked
|
||||
*
|
||||
* @see ResourceReferenceFactory#createResource()
|
||||
*
|
||||
* @deprecated This class is deprecated, no longer needed and is
|
||||
* slated for removal.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public ResourceReferenceFactory<EntityManager> registerPersistenceContextInjectionPoint(final InjectionPoint injectionPoint) {
|
||||
final String cn = WeldJpaInjectionServices.class.getName();
|
||||
final String mn = "registerPersistenceContextInjectionPoint";
|
||||
if (LOGGER.isLoggable(Level.FINER)) {
|
||||
LOGGER.entering(cn, mn, injectionPoint);
|
||||
}
|
||||
final ResourceBundle messages = ResourceBundle.getBundle(this.getClass().getPackage().getName() + ".Messages");
|
||||
assert messages != null;
|
||||
throw new IllegalArgumentException(messages.getString("deprecated"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Throws an {@link IllegalArgumentException} when invoked.
|
||||
*
|
||||
* @exception IllegalArgumentException when invoked
|
||||
*
|
||||
* @see ResourceReferenceFactory#createResource()
|
||||
*
|
||||
* @deprecated This class is deprecated, no longer needed and is
|
||||
* slated for removal.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public ResourceReferenceFactory<EntityManagerFactory> registerPersistenceUnitInjectionPoint(final InjectionPoint ip) {
|
||||
final String cn = WeldJpaInjectionServices.class.getName();
|
||||
final String mn = "registerPersistenceUnitInjectionPoint";
|
||||
if (LOGGER.isLoggable(Level.FINER)) {
|
||||
LOGGER.entering(cn, mn, ip);
|
||||
}
|
||||
final ResourceBundle messages = ResourceBundle.getBundle(this.getClass().getPackage().getName() + ".Messages");
|
||||
assert messages != null;
|
||||
throw new IllegalArgumentException(messages.getString("deprecated"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoked by Weld automatically to clean up any resources held by
|
||||
* this class.
|
||||
*/
|
||||
@Override
|
||||
public void cleanup() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Throws an {@link IllegalArgumentException} when invoked.
|
||||
*
|
||||
* @param injectionPoint ignored
|
||||
*
|
||||
* @return nothing
|
||||
*
|
||||
* @exception IllegalArgumentException when invoked
|
||||
*
|
||||
* @see #registerPersistenceContextInjectionPoint(InjectionPoint)}
|
||||
*
|
||||
* @deprecated This class is deprecated, no longer needed and is
|
||||
* slated for removal.
|
||||
*/
|
||||
@Deprecated
|
||||
public EntityManager resolvePersistenceContext(final InjectionPoint injectionPoint) {
|
||||
return this.registerPersistenceContextInjectionPoint(injectionPoint).createResource().getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Throws an {@link IllegalArgumentException} when invoked.
|
||||
*
|
||||
* @param injectionPoint ignored
|
||||
*
|
||||
* @return nothing
|
||||
*
|
||||
* @exception IllegalArgumentException when invoked
|
||||
*
|
||||
* @see #registerPersistenceContextInjectionPoint(InjectionPoint)}
|
||||
*
|
||||
* @deprecated This class is deprecated, no longer needed and is
|
||||
* slated for removal.
|
||||
*/
|
||||
@Deprecated
|
||||
public EntityManagerFactory resolvePersistenceUnit(final InjectionPoint injectionPoint) {
|
||||
return this.registerPersistenceUnitInjectionPoint(injectionPoint).createResource().getInstance();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Provides classes and interfaces that help to integrate <a
|
||||
* href="https://javaee.github.io/javaee-spec/javadocs/javax/persistence/package-summary.html"
|
||||
* target="_parent">JPA</a> into <a href="http://weld.cdi-spec.org/"
|
||||
* target="_parent">Weld</a>-based CDI 2.0 SE environments.
|
||||
*
|
||||
* @see
|
||||
* io.helidon.integrations.cdi.jpa.weld.WeldJpaInjectionServices
|
||||
*/
|
||||
package io.helidon.integrations.cdi.jpa.weld;
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Provides classes and interfaces that help to integrate <a
|
||||
* href="https://javaee.github.io/javaee-spec/javadocs/javax/persistence/package-summary.html"
|
||||
* target="_parent">JPA</a> into <a href="http://weld.cdi-spec.org/"
|
||||
* target="_parent">Weld</a>-based CDI 2.0 SE environments.
|
||||
*
|
||||
* @see
|
||||
* io.helidon.integrations.cdi.jpa.weld.WeldJpaInjectionServices
|
||||
*/
|
||||
module io.helidon.integrations.cdi.jpa.weld {
|
||||
requires java.transaction;
|
||||
requires java.annotation;
|
||||
requires java.sql;
|
||||
requires java.persistence;
|
||||
requires jakarta.interceptor.api;
|
||||
requires jakarta.inject.api;
|
||||
requires jakarta.enterprise.cdi.api;
|
||||
requires weld.spi;
|
||||
|
||||
exports io.helidon.integrations.cdi.jpa.weld;
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# http://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.
|
||||
#
|
||||
transactionTypeMismatch=A resource-local EntityManagerFactory was requested for \
|
||||
the persistence unit named "{0}", but a JTA \
|
||||
EntityManagerFactory, {1}, was previously associated \
|
||||
with the persistence unit.
|
||||
persistenceUnitNameMismatch=The sole PersistenceUnitInfo, {0}, representing \
|
||||
the persistence unit with name "{1}", will be used \
|
||||
instead of the requested persistence unit named \
|
||||
"{2}"
|
||||
deprecated=This extension is no longer needed and is slated for removal.
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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 io.helidon.integrations.cdi.jpa.weld;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
final class TestDeprecation {
|
||||
|
||||
TestDeprecation() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Deprecated
|
||||
void testDeprecation() {
|
||||
assertThrows(IllegalArgumentException.class,
|
||||
() -> new WeldJpaInjectionServices().registerPersistenceContextInjectionPoint(null));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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 io.helidon.integrations.cdi.jpa.weld;
|
||||
|
||||
import javax.annotation.sql.DataSourceDefinition;
|
||||
import javax.enterprise.context.ApplicationScoped;
|
||||
import javax.enterprise.context.ContextNotActiveException;
|
||||
import javax.enterprise.context.Initialized;
|
||||
import javax.enterprise.event.Observes;
|
||||
import javax.enterprise.inject.se.SeContainer;
|
||||
import javax.enterprise.inject.se.SeContainerInitializer;
|
||||
import javax.inject.Inject;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import javax.transaction.Status;
|
||||
import javax.transaction.SystemException;
|
||||
import javax.transaction.Transaction;
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
@ApplicationScoped
|
||||
@DataSourceDefinition(
|
||||
name = "test",
|
||||
className = "org.h2.jdbcx.JdbcDataSource",
|
||||
url = "jdbc:h2:mem:test",
|
||||
serverName = "",
|
||||
properties = {
|
||||
"user=sa"
|
||||
}
|
||||
)
|
||||
public class TestIntegration {
|
||||
|
||||
private SeContainer cdiContainer;
|
||||
|
||||
@Inject
|
||||
private Transaction transaction;
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager entityManager;
|
||||
|
||||
TestIntegration() {
|
||||
super();
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
void startCdiContainer() {
|
||||
shutDownCdiContainer();
|
||||
final SeContainerInitializer initializer = SeContainerInitializer.newInstance()
|
||||
.addBeanClasses(TestIntegration.class);
|
||||
assertNotNull(initializer);
|
||||
this.cdiContainer = initializer.initialize();
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void shutDownCdiContainer() {
|
||||
if (this.cdiContainer != null) {
|
||||
this.cdiContainer.close();
|
||||
this.cdiContainer = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static void onStartup(@Observes @Initialized(ApplicationScoped.class) final Object event,
|
||||
final TestIntegration self)
|
||||
throws SystemException {
|
||||
assertNotNull(event);
|
||||
assertNotNull(self);
|
||||
self.doSomethingTransactional();
|
||||
self.doSomethingNonTransactional();
|
||||
}
|
||||
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
void doSomethingTransactional() throws SystemException {
|
||||
assertNotNull(this.transaction);
|
||||
assertEquals(Status.STATUS_ACTIVE, this.transaction.getStatus());
|
||||
assertNotNull(this.entityManager);
|
||||
assertTrue(this.entityManager.isOpen());
|
||||
assertTrue(this.entityManager.isJoinedToTransaction());
|
||||
}
|
||||
|
||||
void doSomethingNonTransactional() {
|
||||
assertNotNull(this.transaction); // ...but the scope won't be active
|
||||
try {
|
||||
this.transaction.toString();
|
||||
fail("The TransactionScoped scope was active when it should not have been");
|
||||
} catch (final ContextNotActiveException expected) {
|
||||
|
||||
}
|
||||
assertNotNull(this.entityManager);
|
||||
assertTrue(this.entityManager.isOpen());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIntegration() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# http://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.
|
||||
#
|
||||
.level=WARNING
|
||||
com.arjuna.level=WARNING
|
||||
com.zaxxer.hikari.level=WARNING
|
||||
handlers=io.helidon.common.HelidonConsoleHandler
|
||||
io.helidon.integrations.cdi.jpa.level=WARNING
|
||||
org.eclipse.persistence.level=WARNING
|
||||
org.jboss.weld.level=WARNING
|
||||
@@ -1,18 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# http://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.
|
||||
#
|
||||
|
||||
mp.initializer.allow=true
|
||||
mp.initializer.no-warn=true
|
||||
@@ -1,48 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
|
||||
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
|
||||
|
||||
http://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.
|
||||
|
||||
-->
|
||||
<persistence version="2.2"
|
||||
xmlns="http://xmlns.jcp.org/xml/ns/persistence"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
|
||||
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd">
|
||||
<persistence-unit name="test" transaction-type="JTA">
|
||||
<jta-data-source>test</jta-data-source>
|
||||
<properties>
|
||||
<property name="eclipselink.deploy-on-startup" value="true"/>
|
||||
<property name="eclipselink.jdbc.native-sql" value="true"/>
|
||||
<property name="eclipselink.logging.logger" value="JavaLogger"/>
|
||||
<property name="eclipselink.logging.parameters" value="true"/>
|
||||
<property name="eclipselink.target-database" value="org.eclipse.persistence.platform.database.H2Platform"/>
|
||||
|
||||
<property name="eclipselink.target-server" value="io.helidon.integrations.cdi.eclipselink.CDISEPlatform"/>
|
||||
<!--
|
||||
Hibernate doesn't need a property here; the presence of a
|
||||
JTAPlatform CDI bean will be enough.
|
||||
-->
|
||||
|
||||
<property name="eclipselink.weaving" value="false"/>
|
||||
<!--
|
||||
Hibernate weaving is disabled by default so there is no
|
||||
property to set here; see
|
||||
https://github.com/hibernate/hibernate-orm/blob/5.3.7/documentation/src/main/asciidoc/userguide/chapters/pc/BytecodeEnhancement.adoc#runtime-enhancement
|
||||
-->
|
||||
|
||||
</properties>
|
||||
</persistence-unit>
|
||||
</persistence>
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -36,6 +36,12 @@ final class MicroProfileConfigAuthenticationDetailsProvider extends CustomerAuth
|
||||
this.config = Objects.requireNonNull(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is implementing an interface of a third party. Until
|
||||
* that interface removes this method, we need to keep it in Helidon.
|
||||
*
|
||||
* @return pass phrase
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public String getPassPhrase() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
|
||||
Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@@ -40,7 +40,6 @@
|
||||
<module>hibernate-cdi</module>
|
||||
<module>jedis-cdi</module>
|
||||
<module>jpa-cdi</module>
|
||||
<module>jpa-weld</module> <!-- Deprecated and slated for eventual removal. -->
|
||||
<module>jta-cdi</module>
|
||||
<module>jta-weld</module>
|
||||
<module>oci-objectstorage-cdi</module>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,13 +25,13 @@ import io.helidon.common.http.Parameters;
|
||||
|
||||
/**
|
||||
* Accessor for the {@link Charset} specified by a content-type header.
|
||||
* @deprecated use {@link MessageBodyContext#charset()} instead
|
||||
* @deprecated since 2.0.0, use {@link MessageBodyContext#charset()} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public class ContentTypeCharset {
|
||||
|
||||
/**
|
||||
* Cannot be instanciated.
|
||||
* Cannot be instantiated.
|
||||
*/
|
||||
private ContentTypeCharset() {
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ public abstract class MessageBodyContext implements MessageBodyFilters {
|
||||
* Register a function filter.
|
||||
*
|
||||
* @param function filter function
|
||||
* @deprecated use {@link #registerFilter(MessageBodyFilter)} instead
|
||||
* @deprecated since 2.0.0 use {@link #registerFilter(MessageBodyFilter)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public void registerFilter(Function<Publisher<DataChunk>, Publisher<DataChunk>> function) {
|
||||
|
||||
@@ -117,7 +117,7 @@ public final class MessageBodyReaderContext extends MessageBodyContext implement
|
||||
* @param <T> supported type
|
||||
* @param type class representing the supported type
|
||||
* @param reader reader function
|
||||
* @deprecated use {@link #registerReader(MessageBodyReader) } instead
|
||||
* @deprecated since 2.0.0 use {@link #registerReader(MessageBodyReader) } instead
|
||||
*/
|
||||
@Deprecated
|
||||
public <T> void registerReader(Class<T> type, io.helidon.common.http.Reader<T> reader) {
|
||||
@@ -129,7 +129,7 @@ public final class MessageBodyReaderContext extends MessageBodyContext implement
|
||||
* @param <T> supported type
|
||||
* @param predicate class predicate
|
||||
* @param reader reader function
|
||||
* @deprecated use {@link #registerReader(MessageBodyReader) } instead
|
||||
* @deprecated since 2.0.0 use {@link #registerReader(MessageBodyReader) } instead
|
||||
*/
|
||||
@Deprecated
|
||||
public <T> void registerReader(Predicate<Class<?>> predicate, io.helidon.common.http.Reader<T> reader) {
|
||||
|
||||
@@ -218,7 +218,7 @@ public final class MessageBodyWriterContext extends MessageBodyContext implement
|
||||
* @param type class representing the type supported by this writer
|
||||
* @param function writer function
|
||||
* @return this {@code MessageBodyWriteableContent} instance
|
||||
* @deprecated use {@link #registerWriter(MessageBodyWriter) } instead
|
||||
* @deprecated since 2.0.0, use {@link #registerWriter(MessageBodyWriter) } instead
|
||||
*/
|
||||
@Deprecated
|
||||
public <T> MessageBodyWriterContext registerWriter(Class<T> type, Function<T, Publisher<DataChunk>> function) {
|
||||
@@ -234,7 +234,7 @@ public final class MessageBodyWriterContext extends MessageBodyContext implement
|
||||
* @param contentType the media type
|
||||
* @param function writer function
|
||||
* @return this {@code MessageBodyWriteableContent} instance
|
||||
* @deprecated use {@link #registerWriter(MessageBodyWriter) } instead
|
||||
* @deprecated since 2.0.0, use {@link #registerWriter(MessageBodyWriter) } instead
|
||||
*/
|
||||
@Deprecated
|
||||
public <T> MessageBodyWriterContext registerWriter(Class<T> type, MediaType contentType,
|
||||
@@ -251,7 +251,7 @@ public final class MessageBodyWriterContext extends MessageBodyContext implement
|
||||
* @param accept the object predicate
|
||||
* @param function writer function
|
||||
* @return this {@code MessageBodyWriteableContent} instance
|
||||
* @deprecated use {@link #registerWriter(MessageBodyWriter) } instead
|
||||
* @deprecated since 2.0.0 use {@link #registerWriter(MessageBodyWriter) } instead
|
||||
*/
|
||||
@Deprecated
|
||||
public <T> MessageBodyWriterContext registerWriter(Predicate<?> accept, Function<T, Publisher<DataChunk>> function) {
|
||||
@@ -267,7 +267,7 @@ public final class MessageBodyWriterContext extends MessageBodyContext implement
|
||||
* @param contentType the media type
|
||||
* @param function writer function
|
||||
* @return this {@code MessageBodyWriteableContent} instance
|
||||
* @deprecated use {@link #registerWriter(MessageBodyWriter) } instead
|
||||
* @deprecated since 2.0.0, use {@link #registerWriter(MessageBodyWriter) } instead
|
||||
*/
|
||||
@Deprecated
|
||||
public <T> MessageBodyWriterContext registerWriter(Predicate<?> accept, MediaType contentType,
|
||||
|
||||
@@ -48,6 +48,7 @@ import io.helidon.common.HelidonFlavor;
|
||||
import io.helidon.common.http.Http;
|
||||
import io.helidon.common.http.MediaType;
|
||||
import io.helidon.config.Config;
|
||||
import io.helidon.config.DeprecatedConfig;
|
||||
import io.helidon.media.jsonp.server.JsonSupport;
|
||||
import io.helidon.webserver.Handler;
|
||||
import io.helidon.webserver.RequestHeaders;
|
||||
@@ -536,10 +537,12 @@ public final class MetricsSupport implements Service {
|
||||
*/
|
||||
public Builder config(Config config) {
|
||||
this.config = config;
|
||||
|
||||
// align with health checks
|
||||
config.get("web-context").asString().ifPresent(this::context);
|
||||
// backward compatibility
|
||||
config.get("context").asString().ifPresent(this::context);
|
||||
DeprecatedConfig.get(config, "web-context", "context")
|
||||
.asString()
|
||||
.ifPresent(this::webContext);
|
||||
|
||||
config.get(CORS_CONFIG_KEY)
|
||||
.as(CrossOriginConfig::create)
|
||||
.ifPresent(this::crossOriginConfig);
|
||||
@@ -556,7 +559,7 @@ public final class MetricsSupport implements Service {
|
||||
* {@link RegistryFactory#create(io.helidon.config.Config)} or
|
||||
* {@link RegistryFactory#create()} and create multiple
|
||||
* {@link io.helidon.metrics.MetricsSupport} instances with different
|
||||
* {@link #context(String) contexts}.
|
||||
* {@link #webContext(String)} contexts}.
|
||||
* <p>
|
||||
* If this method is not called,
|
||||
* {@link io.helidon.metrics.MetricsSupport} would use the shared
|
||||
@@ -571,19 +574,6 @@ public final class MetricsSupport implements Service {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a new root context for REST API of metrics.
|
||||
*
|
||||
* @param newContext context to use
|
||||
* @return updated builder instance
|
||||
* @deprecated use {@link #webContext(String)} instead, aligned with API
|
||||
* of heatlh checks
|
||||
*/
|
||||
@Deprecated
|
||||
public Builder context(String newContext) {
|
||||
return webContext(newContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a new root context for REST API of metrics.
|
||||
*
|
||||
|
||||
@@ -18,7 +18,6 @@ package io.helidon.metrics;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import io.helidon.config.Config;
|
||||
|
||||
@@ -85,34 +84,6 @@ public final class RegistryFactory {
|
||||
return new RegistryFactory(config);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get a supplier for registry factory. The supplier will return the singleton isntance
|
||||
* that is created.
|
||||
*
|
||||
* @return supplier of registry factory (to bind as late as possible)
|
||||
* @deprecated use {@link io.helidon.metrics.RegistryFactory#getInstance() RegistryFactory::getInstance} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public static Supplier<RegistryFactory> getRegistryFactory() {
|
||||
return RegistryFactory::getInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a registry factory for systems without CDI.
|
||||
*
|
||||
* @param config configuration to load the factory config from
|
||||
* @return a new registry factory to obtain application registry (and other registries)
|
||||
* @deprecated use {@link #create()} or {@link #create(io.helidon.config.Config)} instead when a new
|
||||
* registry factory instance is needed. Use {@link #getInstance()} or {@link #getInstance(io.helidon.config.Config)}
|
||||
* to retrieve the shared (singleton) instance.
|
||||
*/
|
||||
@Deprecated
|
||||
public static RegistryFactory createSeFactory(Config config) {
|
||||
return create(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a singleton instance of the registry factory.
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -46,7 +46,7 @@ public final class MetricUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* DO NOT USE THIS METHOD please.
|
||||
* DO NOT USE THIS METHOD please, it will be removed.
|
||||
*
|
||||
* @param element element
|
||||
* @param annotClass annotation class
|
||||
@@ -54,7 +54,8 @@ public final class MetricUtil {
|
||||
* @param <E> element type
|
||||
* @param <A> annotation type
|
||||
* @return lookup result
|
||||
* @deprecated This method is made public to migrate from metrics1 to metrics2 for gRPC, this should be refactored
|
||||
* @deprecated This method is made public to migrate from metrics1 to metrics2 for gRPC, this should be refactored.
|
||||
* This method will be removed outside of major version of Helidon.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Deprecated
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,7 +25,7 @@ import javax.enterprise.inject.spi.CDI;
|
||||
* Uses {@code logging.properties} to configure Java logging unless a configuration is defined through
|
||||
* a Java system property. The file is expected either in the directory the application was started, or on
|
||||
* the classpath.
|
||||
* @deprecated use {@link io.helidon.microprofile.cdi.Main} instead
|
||||
* @deprecated since 2.0.0, use {@link io.helidon.microprofile.cdi.Main} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public final class Main {
|
||||
@@ -35,7 +35,7 @@ public final class Main {
|
||||
}
|
||||
|
||||
/**
|
||||
* Main method to start server. The server will collection JAX-RS application automatically (through
|
||||
* Main method to start server. The server will collect JAX-RS application automatically (through
|
||||
* CDI extension - just annotate it with {@link javax.enterprise.context.ApplicationScoped}).
|
||||
*
|
||||
* @param args command line arguments, currently ignored
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package io.helidon.microprofile.tracing;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.annotation.Priority;
|
||||
import javax.enterprise.context.ApplicationScoped;
|
||||
import javax.inject.Provider;
|
||||
@@ -56,11 +58,11 @@ public class MpTracingContextFilter implements ContainerRequestFilter {
|
||||
ServerRequest serverRequest = this.request.get();
|
||||
|
||||
Tracer tracer = serverRequest.tracer();
|
||||
SpanContext parentSpan = serverRequest.spanContext();
|
||||
Optional<SpanContext> parentSpan = serverRequest.spanContext();
|
||||
|
||||
boolean clientEnabled = config.getOptionalValue("tracing.client.enabled", Boolean.class).orElse(true);
|
||||
TracingContext tracingContext = TracingContext.create(tracer, serverRequest.headers().toMap(), clientEnabled);
|
||||
tracingContext.parentSpan(parentSpan);
|
||||
parentSpan.ifPresent(tracingContext::parentSpan);
|
||||
|
||||
Contexts.context().ifPresent(ctx -> ctx.register(tracingContext));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -351,11 +351,14 @@ public final class WebSecurity implements Service {
|
||||
EndpointConfig ec = EndpointConfig.builder()
|
||||
.build();
|
||||
|
||||
SecurityContext context = security.contextBuilder(String.valueOf(SECURITY_COUNTER.incrementAndGet()))
|
||||
.tracingSpan(req.spanContext())
|
||||
SecurityContext.Builder contextBuilder = security.contextBuilder(String.valueOf(SECURITY_COUNTER.incrementAndGet()))
|
||||
.env(env)
|
||||
.endpointConfig(ec)
|
||||
.build();
|
||||
.endpointConfig(ec);
|
||||
|
||||
// only register if exists
|
||||
req.spanContext().ifPresent(contextBuilder::tracingSpan);
|
||||
|
||||
SecurityContext context = contextBuilder.build();
|
||||
|
||||
req.context().register(context);
|
||||
req.context().register(defaultHandler);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,6 +25,7 @@ import javax.annotation.security.RolesAllowed;
|
||||
import io.helidon.security.AuthorizationResponse;
|
||||
import io.helidon.security.EndpointConfig;
|
||||
import io.helidon.security.ProviderRequest;
|
||||
import io.helidon.security.SecurityLevel;
|
||||
import io.helidon.security.SecurityResponse;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -47,9 +48,12 @@ public class AbacProviderTest {
|
||||
Attrib1 attrib = Mockito.mock(Attrib1.class);
|
||||
doReturn(Attrib1.class).when(attrib).annotationType();
|
||||
|
||||
SecurityLevel level = SecurityLevel.create("mock")
|
||||
.withClassAnnotations(Map.of(Attrib1.class, List.of(attrib)))
|
||||
.build();
|
||||
|
||||
EndpointConfig ec = EndpointConfig.builder()
|
||||
.annotations(EndpointConfig.AnnotationScope.CLASS,
|
||||
Map.of(Attrib1.class, List.of(attrib)))
|
||||
.securityLevels(List.of(level))
|
||||
.build();
|
||||
|
||||
ProviderRequest request = Mockito.mock(ProviderRequest.class);
|
||||
@@ -72,9 +76,12 @@ public class AbacProviderTest {
|
||||
RolesAllowed attrib = Mockito.mock(RolesAllowed.class);
|
||||
doReturn(RolesAllowed.class).when(attrib).annotationType();
|
||||
|
||||
SecurityLevel level = SecurityLevel.create("mock")
|
||||
.withClassAnnotations(Map.of(RolesAllowed.class, List.of(attrib)))
|
||||
.build();
|
||||
|
||||
EndpointConfig ec = EndpointConfig.builder()
|
||||
.annotations(EndpointConfig.AnnotationScope.CLASS,
|
||||
Map.of(RolesAllowed.class, List.of(attrib)))
|
||||
.securityLevels(List.of(level))
|
||||
.build();
|
||||
|
||||
ProviderRequest request = Mockito.mock(ProviderRequest.class);
|
||||
@@ -98,9 +105,12 @@ public class AbacProviderTest {
|
||||
when(attrib.value()).thenReturn(false);
|
||||
doReturn(Attrib1.class).when(attrib).annotationType();
|
||||
|
||||
SecurityLevel level = SecurityLevel.create("mock")
|
||||
.withClassAnnotations(Map.of(Attrib1.class, List.of(attrib)))
|
||||
.build();
|
||||
|
||||
EndpointConfig ec = EndpointConfig.builder()
|
||||
.annotations(EndpointConfig.AnnotationScope.CLASS,
|
||||
Map.of(Attrib1.class, List.of(attrib)))
|
||||
.securityLevels(List.of(level))
|
||||
.build();
|
||||
|
||||
ProviderRequest request = Mockito.mock(ProviderRequest.class);
|
||||
@@ -124,8 +134,12 @@ public class AbacProviderTest {
|
||||
when(attrib.value()).thenReturn(true);
|
||||
doReturn(Attrib1.class).when(attrib).annotationType();
|
||||
|
||||
SecurityLevel level = SecurityLevel.create("mock")
|
||||
.withClassAnnotations(Map.of(Attrib1.class, List.of(attrib)))
|
||||
.build();
|
||||
|
||||
EndpointConfig ec = EndpointConfig.builder()
|
||||
.annotations(EndpointConfig.AnnotationScope.CLASS, Map.of(Attrib1.class, List.of(attrib)))
|
||||
.securityLevels(List.of(level))
|
||||
.build();
|
||||
|
||||
ProviderRequest request = Mockito.mock(ProviderRequest.class);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -85,14 +85,6 @@ public class ConfigUserStore implements SecureUserStore {
|
||||
return cu;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated this is needed (for now) for digest authentication.
|
||||
*/
|
||||
@Deprecated
|
||||
char[] password() {
|
||||
return password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String login() {
|
||||
return login;
|
||||
@@ -110,7 +102,7 @@ public class ConfigUserStore implements SecureUserStore {
|
||||
|
||||
@Override
|
||||
public Optional<String> digestHa1(String realm, HttpDigest.Algorithm algorithm) {
|
||||
return Optional.of(DigestToken.ha1(algorithm, realm, login(), password()));
|
||||
return Optional.of(DigestToken.ha1(algorithm, realm, login(), password));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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 io.helidon.security.providers.httpauth;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Store of users for resolving httpauth and digest authentication.
|
||||
*
|
||||
* @deprecated This store is designed for POC - e.g. no need for better security. You can use
|
||||
* {@link io.helidon.security.providers.httpauth.SecureUserStore} instead.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
@Deprecated
|
||||
public interface UserStore extends SecureUserStore {
|
||||
/**
|
||||
* Representation of a single user.
|
||||
*/
|
||||
interface User extends SecureUserStore.User {
|
||||
/**
|
||||
* Get password of the user.
|
||||
* The password must be provided in clear text, as we may need to create a digest based on the password
|
||||
* and other (variable) values for digest authentication.
|
||||
*
|
||||
* @return password
|
||||
*/
|
||||
char[] password();
|
||||
|
||||
@Override
|
||||
default boolean isPasswordValid(char[] password) {
|
||||
return Arrays.equals(password, password());
|
||||
}
|
||||
|
||||
@Override
|
||||
default Optional<String> digestHa1(String realm, HttpDigest.Algorithm algorithm) {
|
||||
return Optional.of(DigestToken.ha1(algorithm, realm, login(), password()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,545 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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 io.helidon.security.providers.httpauth;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Base64;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
import io.helidon.common.Builder;
|
||||
import io.helidon.security.AuthenticationResponse;
|
||||
import io.helidon.security.Principal;
|
||||
import io.helidon.security.Security;
|
||||
import io.helidon.security.SecurityContext;
|
||||
import io.helidon.security.SecurityResponse;
|
||||
import io.helidon.security.Subject;
|
||||
import io.helidon.security.spi.AuthenticationProvider;
|
||||
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.not;
|
||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||
import static org.hamcrest.CoreMatchers.startsWith;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
||||
/**
|
||||
* Unit test for {@link io.helidon.security.providers.httpauth.HttpBasicAuthProvider} and
|
||||
* {@link io.helidon.security.providers.httpauth.HttpDigestAuthProvider}.
|
||||
* Todo remove this once UserStore is removed.
|
||||
*/
|
||||
public class HttpAuthProviderBuilderLegacyUserStoreTest {
|
||||
private static final String QUOTE = "\"";
|
||||
private static Security security;
|
||||
private volatile static int counter = 0;
|
||||
private final Random random = new Random();
|
||||
private SecurityContext context;
|
||||
|
||||
@BeforeAll
|
||||
public static void initClass() {
|
||||
UserStore us = userStore();
|
||||
|
||||
security = Security.builder()
|
||||
.addAuthenticationProvider(basicAuthProvider(us), "basic")
|
||||
.addAuthenticationProvider(digestAuthProvider(false, us), "digest")
|
||||
.addAuthenticationProvider(digestAuthProvider(true, us), "digest_old")
|
||||
.build();
|
||||
}
|
||||
|
||||
private static UserStore userStore() {
|
||||
return login -> {
|
||||
if (login.equals("jack")) {
|
||||
return Optional.of(new UserStore.User() {
|
||||
@Override
|
||||
public String login() {
|
||||
return "jack";
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] password() {
|
||||
return "jackIsGreat".toCharArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> roles() {
|
||||
return Set.of("user", "admin");
|
||||
}
|
||||
});
|
||||
}
|
||||
if (login.equals("jill")) {
|
||||
return Optional.of(new UserStore.User() {
|
||||
@Override
|
||||
public String login() {
|
||||
return "jill";
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] password() {
|
||||
return "password".toCharArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> roles() {
|
||||
return Set.of("user");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return Optional.empty();
|
||||
};
|
||||
}
|
||||
|
||||
private static Builder<? extends AuthenticationProvider> basicAuthProvider(UserStore us) {
|
||||
return HttpBasicAuthProvider.builder()
|
||||
.realm("mic")
|
||||
.userStore(us);
|
||||
}
|
||||
|
||||
private static Builder<? extends AuthenticationProvider> digestAuthProvider(boolean old, UserStore us) {
|
||||
HttpDigestAuthProvider.Builder builder = HttpDigestAuthProvider.builder()
|
||||
.realm("mic")
|
||||
.digestServerSecret("pwd".toCharArray())
|
||||
.userStore(us);
|
||||
|
||||
if (old) {
|
||||
builder.noDigestQop();
|
||||
}
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
public void init() {
|
||||
context = security.contextBuilder(String.valueOf(counter++))
|
||||
.build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void basicTestFail() {
|
||||
AuthenticationResponse response = context.atnClientBuilder().buildAndGet();
|
||||
|
||||
assertThat(response.status().isSuccess(), is(false));
|
||||
assertThat(response.statusCode().orElse(200), is(401));
|
||||
String authHeader = response.responseHeaders().get(HttpBasicAuthProvider.HEADER_AUTHENTICATION_REQUIRED).get(0);
|
||||
assertThat(authHeader, notNullValue());
|
||||
assertThat(authHeader.toLowerCase(), is("basic realm=\"mic\""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void basicTestJack() {
|
||||
setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION, buildBasic("jack", "jackIsGreat"));
|
||||
|
||||
AuthenticationResponse response = context.authenticate();
|
||||
|
||||
assertThat(response.status(), is(SecurityResponse.SecurityStatus.SUCCESS));
|
||||
assertThat(response.statusCode().orElse(200), is(200));
|
||||
|
||||
assertThat(context.user().map(sub -> sub.principal().getName()).orElse(null), is("jack"));
|
||||
assertThat(context.isUserInRole("admin"), is(true));
|
||||
assertThat(context.isUserInRole("user"), is(true));
|
||||
}
|
||||
|
||||
private void setHeader(SecurityContext context, String name, String value) {
|
||||
context.env(context.env()
|
||||
.derive()
|
||||
.header(name, value)
|
||||
.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void basicTestInvalidUser() {
|
||||
setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION, buildBasic("wrong", "user"));
|
||||
|
||||
AuthenticationResponse response = context.authenticate();
|
||||
|
||||
assertThat(response.description().orElse(""), is("Invalid username or password"));
|
||||
assertThat(response.status().isSuccess(), is(false));
|
||||
assertThat(response.statusCode().orElse(200), is(401));
|
||||
String authHeader = response.responseHeaders().get(HttpBasicAuthProvider.HEADER_AUTHENTICATION_REQUIRED).get(0);
|
||||
assertThat(authHeader, notNullValue());
|
||||
assertThat(authHeader.toLowerCase(), is("basic realm=\"mic\""));
|
||||
|
||||
setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION, buildBasic("jack", "invalid_passworrd"));
|
||||
|
||||
response = context.authenticate();
|
||||
|
||||
assertThat(response.description().orElse(""), is("Invalid username or password"));
|
||||
assertThat(response.status().isSuccess(), is(false));
|
||||
assertThat(response.statusCode().orElse(200), is(401));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sendInvalidTypeTest() {
|
||||
setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION, "bearer token=\"adfasfaf\"");
|
||||
|
||||
AuthenticationResponse response = context.authenticate();
|
||||
|
||||
assertThat(response.status(), is(SecurityResponse.SecurityStatus.FAILURE));
|
||||
assertThat(response.statusCode().orElse(200), is(401));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sendInvalidBasicTest() {
|
||||
setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION, "basic wrong_header_value");
|
||||
AuthenticationResponse response = context.authenticate();
|
||||
|
||||
assertThat(response.status(), is(SecurityResponse.SecurityStatus.FAILURE));
|
||||
assertThat(response.statusCode().orElse(200), is(401));
|
||||
|
||||
// not base64 encoded and invalid
|
||||
setHeader(context,
|
||||
HttpBasicAuthProvider.HEADER_AUTHENTICATION,
|
||||
"basic " + Base64.getEncoder().encodeToString("Hello".getBytes()));
|
||||
|
||||
response = context.authenticate();
|
||||
|
||||
assertThat(response.status(), is(SecurityResponse.SecurityStatus.FAILURE));
|
||||
assertThat(response.statusCode().orElse(200), is(401));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sendDigestNotBasicTest() {
|
||||
setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION, buildDigest(HttpDigest.Qop.AUTH, "jack", "jackIsGreat"));
|
||||
AuthenticationResponse response = context.authenticate();
|
||||
|
||||
assertThat(response.status(), is(SecurityResponse.SecurityStatus.FAILURE));
|
||||
assertThat(response.statusCode().orElse(200), is(401));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void basicTestJill() {
|
||||
setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION, buildBasic("jill", "password"));
|
||||
AuthenticationResponse response = context.authenticate();
|
||||
|
||||
assertThat(response.status(), is(SecurityResponse.SecurityStatus.SUCCESS));
|
||||
assertThat(response.statusCode().orElse(200), is(200));
|
||||
|
||||
assertThat(getUsername(context), is("jill"));
|
||||
assertThat(context.isUserInRole("admin"), is(false));
|
||||
assertThat(context.isUserInRole("user"), is(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void digestTest401() {
|
||||
AuthenticationResponse response = context.atnClientBuilder()
|
||||
.explicitProvider("digest")
|
||||
.buildAndGet();
|
||||
|
||||
assertThat(response.status().isSuccess(), is(false));
|
||||
assertThat(response.statusCode().orElse(200), is(401));
|
||||
String authHeader = response.responseHeaders().get(HttpBasicAuthProvider.HEADER_AUTHENTICATION_REQUIRED).get(0);
|
||||
assertThat(authHeader, notNullValue());
|
||||
assertThat(authHeader.toLowerCase(), startsWith("digest realm=\"mic\""));
|
||||
assertThat(authHeader.toLowerCase(), containsString("qop="));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void digestOldTest401() {
|
||||
AuthenticationResponse response = context.atnClientBuilder()
|
||||
.explicitProvider("digest_old")
|
||||
.buildAndGet();
|
||||
|
||||
assertThat(response.status().isSuccess(), is(false));
|
||||
assertThat(response.statusCode().orElse(200), is(401));
|
||||
String authHeader = response.responseHeaders().get(HttpBasicAuthProvider.HEADER_AUTHENTICATION_REQUIRED).get(0);
|
||||
assertThat(authHeader, notNullValue());
|
||||
assertThat(authHeader.toLowerCase(), startsWith("digest realm=\"mic\""));
|
||||
assertThat(authHeader.toLowerCase(), not(containsString("qop=")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void digestTestJack() {
|
||||
setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION, buildDigest(HttpDigest.Qop.AUTH, "jack", "jackIsGreat"));
|
||||
AuthenticationResponse response = context.atnClientBuilder()
|
||||
.explicitProvider("digest")
|
||||
.buildAndGet();
|
||||
|
||||
assertThat(response.description().orElse("No description"),
|
||||
response.status(),
|
||||
is(SecurityResponse.SecurityStatus.SUCCESS));
|
||||
assertThat(response.statusCode().orElse(200), is(200));
|
||||
|
||||
assertThat(getUsername(context), is("jack"));
|
||||
assertThat(context.isUserInRole("admin"), is(true));
|
||||
assertThat(context.isUserInRole("user"), is(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void digestTestInvalidUser() {
|
||||
setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION, buildDigest(HttpDigest.Qop.AUTH, "wrong", "user"));
|
||||
AuthenticationResponse response = context.atnClientBuilder()
|
||||
.explicitProvider("digest")
|
||||
.buildAndGet();
|
||||
|
||||
assertThat(response.description().orElse(""), is("Invalid username or password"));
|
||||
assertThat(response.status().isSuccess(), is(false));
|
||||
assertThat(response.statusCode().orElse(200), is(401));
|
||||
String authHeader = response.responseHeaders().get(HttpBasicAuthProvider.HEADER_AUTHENTICATION_REQUIRED).get(0);
|
||||
assertThat(authHeader, notNullValue());
|
||||
assertThat(authHeader.toLowerCase(), startsWith("digest realm=\"mic\""));
|
||||
|
||||
setHeader(context,
|
||||
HttpBasicAuthProvider.HEADER_AUTHENTICATION,
|
||||
buildDigest(HttpDigest.Qop.AUTH, "jack", "wrong password"));
|
||||
response = context.atnClientBuilder()
|
||||
.explicitProvider("digest")
|
||||
.buildAndGet();
|
||||
|
||||
assertThat(response.description().orElse(""), is("Invalid username or password"));
|
||||
assertThat(response.status().isSuccess(), is(false));
|
||||
assertThat(response.statusCode().orElse(200), is(401));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sendBasicNotDigestTest() {
|
||||
setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION, buildBasic("jack", "jackIsGreat"));
|
||||
AuthenticationResponse response = context.atnClientBuilder()
|
||||
.explicitProvider("digest")
|
||||
.buildAndGet();
|
||||
|
||||
assertThat(response.status(), is(SecurityResponse.SecurityStatus.FAILURE));
|
||||
assertThat(response.statusCode().orElse(200), is(401));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sendInvalidDigestTest() {
|
||||
setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION, "digest wrong_header_value");
|
||||
AuthenticationResponse response = context.atnClientBuilder()
|
||||
.explicitProvider("digest")
|
||||
.buildAndGet();
|
||||
|
||||
assertThat(response.status(), is(SecurityResponse.SecurityStatus.FAILURE));
|
||||
assertThat(response.statusCode().orElse(200), is(401));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void digestTestJill() {
|
||||
setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION, buildDigest(HttpDigest.Qop.AUTH, "jill", "password"));
|
||||
AuthenticationResponse response = context.atnClientBuilder()
|
||||
.explicitProvider("digest")
|
||||
.buildAndGet();
|
||||
|
||||
assertThat(response.description().orElse("No description"),
|
||||
response.status(),
|
||||
is(SecurityResponse.SecurityStatus.SUCCESS));
|
||||
assertThat(response.statusCode().orElse(200), is(200));
|
||||
|
||||
assertThat(getUsername(context), is("jill"));
|
||||
assertThat(context.isUserInRole("admin"), is(false));
|
||||
assertThat(context.isUserInRole("user"), is(true));
|
||||
}
|
||||
|
||||
private String getUsername(SecurityContext context) {
|
||||
return context.user().map(Subject::principal).map(Principal::getName).orElse(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void digestOldTestJack() {
|
||||
setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION, buildDigest(HttpDigest.Qop.NONE, "jack", "jackIsGreat"));
|
||||
AuthenticationResponse response = context.atnClientBuilder()
|
||||
.explicitProvider("digest_old")
|
||||
.buildAndGet();
|
||||
|
||||
assertThat(response.description().orElse("No description"),
|
||||
response.status(),
|
||||
is(SecurityResponse.SecurityStatus.SUCCESS));
|
||||
assertThat(response.statusCode().orElse(200), is(200));
|
||||
|
||||
assertThat(getUsername(context), is("jack"));
|
||||
assertThat(context.isUserInRole("admin"), is(true));
|
||||
assertThat(context.isUserInRole("user"), is(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void digestOldTestJill() {
|
||||
setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION, buildDigest(HttpDigest.Qop.NONE, "jill", "password"));
|
||||
AuthenticationResponse response = context.atnClientBuilder()
|
||||
.explicitProvider("digest_old")
|
||||
.buildAndGet();
|
||||
|
||||
assertThat(response.description().orElse("No description"),
|
||||
response.status(),
|
||||
is(SecurityResponse.SecurityStatus.SUCCESS));
|
||||
assertThat(response.statusCode().orElse(200), is(200));
|
||||
|
||||
assertThat(getUsername(context), is("jill"));
|
||||
assertThat(context.isUserInRole("admin"), is(false));
|
||||
assertThat(context.isUserInRole("user"), is(true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void digestTestNonceTimeout() {
|
||||
Instant in = Instant.now().minus(100, ChronoUnit.DAYS);
|
||||
|
||||
setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION,
|
||||
buildDigest(HttpDigest.Qop.AUTH,
|
||||
"jack",
|
||||
"jackIsGreat",
|
||||
HttpDigestAuthProvider.nonce(in.toEpochMilli(), random, "pwd".toCharArray()),
|
||||
"mic"));
|
||||
|
||||
AuthenticationResponse response = context.atnClientBuilder()
|
||||
.explicitProvider("digest")
|
||||
.buildAndGet();
|
||||
|
||||
assertThat(response.description().orElse(""), is("Nonce timeout"));
|
||||
assertThat(response.status(), is(SecurityResponse.SecurityStatus.FAILURE));
|
||||
assertThat(response.statusCode().orElse(200), is(401));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void digestTestNonceNotB64() {
|
||||
setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION,
|
||||
buildDigest(HttpDigest.Qop.AUTH,
|
||||
"jack",
|
||||
"jackIsGreat",
|
||||
"Not a base64 encoded $tring",
|
||||
"mic"));
|
||||
AuthenticationResponse response = context.atnClientBuilder()
|
||||
.explicitProvider("digest")
|
||||
.buildAndGet();
|
||||
|
||||
assertThat(response.description().orElse(""), is("Nonce must be base64 encoded"));
|
||||
assertThat(response.status(), is(SecurityResponse.SecurityStatus.FAILURE));
|
||||
assertThat(response.statusCode().orElse(200), is(401));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void digestTestNonceTooShort() {
|
||||
setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION,
|
||||
buildDigest(HttpDigest.Qop.AUTH,
|
||||
"jack",
|
||||
"jackIsGreat",
|
||||
// must be base64 encoded string of less than 17 bytes
|
||||
"wrongNonce",
|
||||
"mic"));
|
||||
|
||||
AuthenticationResponse response = context.atnClientBuilder()
|
||||
.explicitProvider("digest")
|
||||
.buildAndGet();
|
||||
assertThat(response.description().orElse(""), is("Invalid nonce length"));
|
||||
assertThat(response.status(), is(SecurityResponse.SecurityStatus.FAILURE));
|
||||
assertThat(response.statusCode().orElse(200), is(401));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void digestTestNonceNotEncrypted() {
|
||||
setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION,
|
||||
buildDigest(HttpDigest.Qop.AUTH,
|
||||
"jack",
|
||||
"jackIsGreat",
|
||||
Base64.getEncoder()
|
||||
.encodeToString("4444444444444444444444444444444444444444444444".getBytes()),
|
||||
"mic"));
|
||||
|
||||
AuthenticationResponse response = context.atnClientBuilder()
|
||||
.explicitProvider("digest")
|
||||
.buildAndGet();
|
||||
assertThat(response.description().orElse(""), is("Invalid nonce value"));
|
||||
assertThat(response.status(), is(SecurityResponse.SecurityStatus.FAILURE));
|
||||
assertThat(response.statusCode().orElse(200), is(401));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void digestTestWrongRealm() {
|
||||
setHeader(context, HttpBasicAuthProvider.HEADER_AUTHENTICATION,
|
||||
buildDigest(HttpDigest.Qop.AUTH,
|
||||
"jack",
|
||||
"jackIsGreat",
|
||||
HttpDigestAuthProvider.nonce(System.currentTimeMillis(), random, "pwd".toCharArray()),
|
||||
"wrongRealm"));
|
||||
AuthenticationResponse response = context.atnClientBuilder()
|
||||
.explicitProvider("digest")
|
||||
.buildAndGet();
|
||||
|
||||
assertThat(response.description().orElse(""), is("Invalid realm"));
|
||||
assertThat(response.status(), is(SecurityResponse.SecurityStatus.FAILURE));
|
||||
assertThat(response.statusCode().orElse(200), is(401));
|
||||
}
|
||||
|
||||
private String buildBasic(String user, String password) {
|
||||
return "basic " + Base64.getEncoder()
|
||||
.encodeToString((user + ":" + password).getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
private String buildDigest(HttpDigest.Qop qop,
|
||||
String user,
|
||||
String password,
|
||||
String nonce,
|
||||
String realm) {
|
||||
|
||||
StringBuilder result = new StringBuilder(100);
|
||||
|
||||
String opaque = "someString";
|
||||
String path = "/digest";
|
||||
String cnonce = createCnonce();
|
||||
String nc = "00000001";
|
||||
|
||||
DigestToken token = new DigestToken();
|
||||
token.setAlgorithm(HttpDigest.Algorithm.MD5);
|
||||
token.setQop(qop);
|
||||
token.setUsername(user);
|
||||
token.setOpaque(opaque);
|
||||
token.setRealm(realm);
|
||||
token.setMethod("GET");
|
||||
token.setUri(path);
|
||||
token.setNonce(nonce);
|
||||
token.setNc(nc);
|
||||
token.setCnonce(cnonce);
|
||||
|
||||
String response = token.digest(password.toCharArray());
|
||||
|
||||
result.append("digest ");
|
||||
result.append("username=").append(QUOTE).append(user).append(QUOTE);
|
||||
result.append(", realm=").append(QUOTE).append(realm).append(QUOTE);
|
||||
result.append(", nonce=").append(QUOTE).append(nonce).append(QUOTE);
|
||||
result.append(", uri=").append(QUOTE).append(path).append(QUOTE);
|
||||
result.append(", algorithm=MD5");
|
||||
result.append(", response=").append(QUOTE).append(response).append(QUOTE);
|
||||
result.append(", opaque=").append(QUOTE).append(opaque).append(QUOTE);
|
||||
if (qop != HttpDigest.Qop.NONE) {
|
||||
result.append(", qop=").append(qop.getQop());
|
||||
}
|
||||
result.append(", nc=").append(nc);
|
||||
result.append(", cnonce=").append(QUOTE).append(cnonce).append(QUOTE);
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
private String buildDigest(HttpDigest.Qop qop, String user, String password) {
|
||||
return buildDigest(qop,
|
||||
user,
|
||||
password,
|
||||
HttpDigestAuthProvider.nonce(System.currentTimeMillis(), random, "pwd".toCharArray()),
|
||||
"mic");
|
||||
}
|
||||
|
||||
private String createCnonce() {
|
||||
byte[] cnonce = new byte[8];
|
||||
random.nextBytes(cnonce);
|
||||
|
||||
return Base64.getEncoder().encodeToString(cnonce);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,12 +16,10 @@
|
||||
|
||||
package io.helidon.security;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
@@ -120,42 +118,6 @@ public class EndpointConfig implements AbacSupport {
|
||||
return Optional.ofNullable(configMap.get(configKey));
|
||||
}
|
||||
|
||||
/**
|
||||
* All custom annotations for scopes defined in parameters, in the same order.
|
||||
*
|
||||
* @param scopes scopes the caller is interested in
|
||||
* @return a map of annotation classes to annotation instances
|
||||
* @see SecurityProvider#supportedAnnotations()
|
||||
* @deprecated use iteration over security levels instead
|
||||
*/
|
||||
@Deprecated
|
||||
public Map<Class<? extends Annotation>, List<Annotation>> annotations(AnnotationScope... scopes) {
|
||||
Map<Class<? extends Annotation>, List<Annotation>> result = new HashMap<>();
|
||||
|
||||
for (AnnotationScope scope : scopes) {
|
||||
Map<Class<? extends Annotation>, List<Annotation>> map;
|
||||
switch (scope) {
|
||||
case APPLICATION:
|
||||
map = securityLevels.get(0).getClassLevelAnnotations();
|
||||
break;
|
||||
case CLASS:
|
||||
map = securityLevels.get(securityLevels.size() - 1).getClassLevelAnnotations();
|
||||
break;
|
||||
case METHOD:
|
||||
map = securityLevels.get(securityLevels.size() - 1).getMethodLevelAnnotations();
|
||||
break;
|
||||
default:
|
||||
map = null;
|
||||
}
|
||||
if (null != map) {
|
||||
map.forEach((annotClass, annotList) -> result.computeIfAbsent(annotClass, aClass -> new LinkedList<>())
|
||||
.addAll(annotList));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all security levels endpoint configuration object registered.
|
||||
* The first level represents {@link AnnotationScope#APPLICATION} level annotations.
|
||||
@@ -167,25 +129,6 @@ public class EndpointConfig implements AbacSupport {
|
||||
return securityLevels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all annotations of a specific class declared on any level.
|
||||
*
|
||||
* @param annotationClass Class of annotation you want
|
||||
* @param scopes scopes the caller is interested in
|
||||
* @param <T> type of annotation wanted
|
||||
* @return list of annotations in order specified by methodFirst parameter
|
||||
* @deprecated use iteration over security levels instead
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends Annotation> List<T> combineAnnotations(Class<T> annotationClass, AnnotationScope... scopes) {
|
||||
List<T> result = new LinkedList<>();
|
||||
|
||||
result.addAll((Collection<? extends T>) annotations(scopes).getOrDefault(annotationClass, List.of()));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Derive a new endpoint configuration builder based on this instance.
|
||||
*
|
||||
@@ -296,62 +239,6 @@ public class EndpointConfig implements AbacSupport {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add annotations of a specific scope to this request builder.
|
||||
* Only used by frameworks that use annotations.
|
||||
*
|
||||
* @param scope Annotation scope to add annotations for
|
||||
* @param annotations Collected annotations based on security provider requirements.
|
||||
* @return updated Builder instance
|
||||
* @deprecated Use the {@link #securityLevels(List) securityLevels} method.
|
||||
*/
|
||||
@Deprecated
|
||||
public Builder annotations(AnnotationScope scope,
|
||||
Map<Class<? extends Annotation>, List<Annotation>> annotations) {
|
||||
// here we must switch from a proxy to actual annotation type
|
||||
Map<Class<? extends Annotation>, List<Annotation>> newAnnots = new HashMap<>();
|
||||
|
||||
if (securityLevels.isEmpty()) {
|
||||
securityLevels.add(SecurityLevel.create("APPLICATION").build()); //Security level of Application
|
||||
securityLevels.add(SecurityLevel.create("CLASS").build()); // Security level of class and method
|
||||
}
|
||||
SecurityLevel securityLevel;
|
||||
int index;
|
||||
if (scope == AnnotationScope.APPLICATION) {
|
||||
index = 0;
|
||||
} else {
|
||||
index = securityLevels.size() - 1;
|
||||
}
|
||||
securityLevel = securityLevels.get(index);
|
||||
|
||||
annotations.forEach((aClass, list) -> {
|
||||
if (!list.isEmpty()) {
|
||||
Annotation annotation = list.get(0);
|
||||
newAnnots.put(annotation.annotationType(), list);
|
||||
}
|
||||
});
|
||||
|
||||
switch (scope) {
|
||||
case APPLICATION:
|
||||
case CLASS:
|
||||
securityLevels.set(index,
|
||||
SecurityLevel.create(securityLevel)
|
||||
.withClassAnnotations(newAnnots)
|
||||
.build());
|
||||
break;
|
||||
case METHOD:
|
||||
securityLevels.set(index,
|
||||
SecurityLevel.create(securityLevel)
|
||||
.withMethodAnnotations(newAnnots)
|
||||
.build());
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Scope FIELD is not supported here.");
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attributes of this endpoint configuration.
|
||||
*
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -36,8 +36,6 @@ public interface SecurityProvider {
|
||||
* class and resource methods will be collected.
|
||||
*
|
||||
* @return Collection of annotations this provider expects.
|
||||
* @see EndpointConfig#annotations(EndpointConfig.AnnotationScope...)
|
||||
* @see EndpointConfig#combineAnnotations(Class, EndpointConfig.AnnotationScope...)
|
||||
*/
|
||||
default Collection<Class<? extends Annotation>> supportedAnnotations() {
|
||||
return Set.of();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2020 Oracle and/or its affiliates.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -23,7 +23,6 @@ io.helidon.level=INFO
|
||||
# It replaces "!thread!" with the current thread name
|
||||
#java.util.logging.ConsoleHandler.level=ALL
|
||||
io.helidon.common.HelidonConsoleHandler.level=ALL
|
||||
#java.util.logging.ConsoleHandler.formatter=io.helidon.webserver.WebServerLogFormatter
|
||||
java.util.logging.SimpleFormatter.format=%1$tY.%1$tm.%1$td %1$tH:%1$tM:%1$tS %4$s %3$s !thread!: %5$s%6$s%n
|
||||
AUDIT.level=FINEST
|
||||
io.helidon.webserver.level=WARNING
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -32,7 +32,6 @@ io.helidon.level=INFO
|
||||
# It replaces "!thread!" with the current thread name
|
||||
#java.util.logging.ConsoleHandler.level=ALL
|
||||
io.helidon.common.HelidonConsoleHandler.level=ALL
|
||||
#java.util.logging.ConsoleHandler.formatter=io.helidon.webserver.WebServerLogFormatter
|
||||
java.util.logging.SimpleFormatter.format=%1$tY.%1$tm.%1$td %1$tH:%1$tM:%1$tS %4$s %3$s !thread!: %5$s%6$s%n
|
||||
AUDIT.level=FINEST
|
||||
io.helidon.webserver.level=WARNING
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -354,19 +354,6 @@ public class JaegerTracerBuilder implements TracerBuilder<JaegerTracerBuilder> {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The host name and port when using the remote controlled sampler.
|
||||
*
|
||||
* @param samplerManagerHostPort host and port of the sampler manager
|
||||
* @return updated builder instance
|
||||
* @deprecated typo, please use {@link #samplerManager(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public JaegerTracerBuilder samplerMananger(String samplerManagerHostPort) {
|
||||
this.samplerManager = samplerManagerHostPort;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The host name and port when using the remote controlled sampler.
|
||||
*
|
||||
@@ -476,18 +463,6 @@ public class JaegerTracerBuilder implements TracerBuilder<JaegerTracerBuilder> {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tracer buildAndRegister() {
|
||||
if (global) {
|
||||
return build();
|
||||
}
|
||||
|
||||
Tracer result = build();
|
||||
GlobalTracer.register(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Configuration jaegerConfig() {
|
||||
/*
|
||||
* Preload from environment, then override configured values
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,7 +22,6 @@ import io.helidon.common.Builder;
|
||||
import io.helidon.config.Config;
|
||||
|
||||
import io.opentracing.Tracer;
|
||||
import io.opentracing.util.GlobalTracer;
|
||||
|
||||
/**
|
||||
* A builder for tracing {@link Tracer tracer}.
|
||||
@@ -250,7 +249,6 @@ public interface TracerBuilder<T extends TracerBuilder> extends Builder<Tracer>
|
||||
|
||||
/**
|
||||
* When enabled, the created instance is also registered as a global tracer.
|
||||
* When set to {@code true} method {@link #build()} will have the same result as {@link #buildAndRegister()}.
|
||||
*
|
||||
* @param global whether to register this tracer as a global tracer once built
|
||||
* @return updated builder instance
|
||||
@@ -266,18 +264,4 @@ public interface TracerBuilder<T extends TracerBuilder> extends Builder<Tracer>
|
||||
// declaration on io.helidon.common.Builder
|
||||
// this class returned an Object instead of Tracer
|
||||
Tracer build();
|
||||
|
||||
/**
|
||||
* Build and register as a global tracer.
|
||||
*
|
||||
* @return The {@link Tracer} built and registered
|
||||
* @deprecated Use {@link #registerGlobal(boolean)} to control whether the resulting instance is
|
||||
* registered as a {@link io.opentracing.util.GlobalTracer}.
|
||||
*/
|
||||
@Deprecated
|
||||
default Tracer buildAndRegister() {
|
||||
Tracer result = build();
|
||||
GlobalTracer.register(result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -51,7 +51,8 @@ class TracerBuilderTest {
|
||||
.addTracerTag("key2", 49)
|
||||
.addTracerTag("key3", true)
|
||||
.enabled(true)
|
||||
.buildAndRegister();
|
||||
.registerGlobal(true)
|
||||
.build();
|
||||
|
||||
assertThat(tracer, notNullValue());
|
||||
assertThat(tracer, instanceOf(NoopTracer.class));
|
||||
@@ -60,7 +61,7 @@ class TracerBuilderTest {
|
||||
@Test
|
||||
void testNoOpTracerBuilderFromConfig() {
|
||||
Tracer tracer = TracerBuilder.create(Config.create())
|
||||
.buildAndRegister();
|
||||
.build();
|
||||
|
||||
assertThat(tracer, notNullValue());
|
||||
assertThat(tracer, instanceOf(NoopTracer.class));
|
||||
@@ -97,7 +98,7 @@ class TracerBuilderTest {
|
||||
// make sure we do not lose the builder type
|
||||
.first("first")
|
||||
.second("second")
|
||||
.buildAndRegister();
|
||||
.build();
|
||||
|
||||
assertThat(tracer, notNullValue());
|
||||
assertThat(tracer, instanceOf(NoopTracer.class));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -326,18 +326,6 @@ public class ZipkinTracerBuilder implements TracerBuilder<ZipkinTracerBuilder> {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tracer buildAndRegister() {
|
||||
if (global) {
|
||||
return build();
|
||||
}
|
||||
|
||||
Tracer result = build();
|
||||
GlobalTracer.register(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Version of Zipkin API to use.
|
||||
* Defaults to {@link Version#V2}.
|
||||
|
||||
@@ -283,7 +283,7 @@ public interface WebClient {
|
||||
*
|
||||
* @param amount amount of time
|
||||
* @param unit time unit
|
||||
* @deprecated see {@link WebClient.Builder#connectTimeout(long, TimeUnit)}
|
||||
* @deprecated use {@link WebClient.Builder#connectTimeout(long, TimeUnit)}, this method will be removed
|
||||
* @return updated builder instance
|
||||
*/
|
||||
@Deprecated
|
||||
@@ -309,7 +309,7 @@ public interface WebClient {
|
||||
*
|
||||
* @param amount amount of time
|
||||
* @param unit time unit
|
||||
* @deprecated see {@link WebClient.Builder#readTimeout(long, TimeUnit)}
|
||||
* @deprecated use {@link WebClient.Builder#readTimeout(long, TimeUnit)}, this method will be removed
|
||||
* @return updated builder instance
|
||||
*/
|
||||
@Deprecated
|
||||
|
||||
@@ -191,7 +191,7 @@ public interface WebClientRequestBuilder {
|
||||
*
|
||||
* @param amount amount of time
|
||||
* @param unit time unit
|
||||
* @deprecated see {@link WebClientRequestBuilder#connectTimeout(long, TimeUnit)}
|
||||
* @deprecated use {@link WebClientRequestBuilder#connectTimeout(long, TimeUnit)}, this method will be removed
|
||||
* @return updated builder instance
|
||||
*/
|
||||
@Deprecated
|
||||
@@ -211,7 +211,7 @@ public interface WebClientRequestBuilder {
|
||||
*
|
||||
* @param amount amount of time
|
||||
* @param unit time unit
|
||||
* @deprecated see {@link WebClientRequestBuilder#readTimeout(long, TimeUnit)}
|
||||
* @deprecated use {@link WebClientRequestBuilder#readTimeout(long, TimeUnit)}, this method will be removed
|
||||
* @return updated builder instance
|
||||
*/
|
||||
@Deprecated
|
||||
|
||||
@@ -274,8 +274,8 @@ public class JerseySupport implements Service {
|
||||
requestContext.setRequestScopedInitializer(injectionManager -> {
|
||||
injectionManager.<Ref<ServerRequest>>getInstance(REQUEST_TYPE).set(req);
|
||||
injectionManager.<Ref<ServerResponse>>getInstance(RESPONSE_TYPE).set(res);
|
||||
injectionManager.<Ref<Span>>getInstance(SPAN_TYPE).set(req.span());
|
||||
injectionManager.<Ref<SpanContext>>getInstance(SPAN_CONTEXT_TYPE).set(req.spanContext());
|
||||
injectionManager.<Ref<SpanContext>>getInstance(SPAN_CONTEXT_TYPE)
|
||||
.set(req.spanContext().orElse(null));
|
||||
});
|
||||
|
||||
appHandler.handle(requestContext);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2017, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2017, 2020 Oracle and/or its affiliates.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
|
||||
#All attributes details
|
||||
handlers=java.util.logging.ConsoleHandler
|
||||
java.util.logging.ConsoleHandler.level=FINEST
|
||||
java.util.logging.ConsoleHandler.formatter=io.helidon.webserver.WebServerLogFormatter
|
||||
handlers=io.helidon.common.HelidonConsoleHandler
|
||||
|
||||
io.helidon.common.HelidonConsoleHandler.level=ALL
|
||||
java.util.logging.SimpleFormatter.format=%1$tY.%1$tm.%1$td %1$tH:%1$tM:%1$tS %4$s %3$s !thread!: %5$s%6$s%n
|
||||
|
||||
#All log level details
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -32,7 +32,6 @@ public interface ExperimentalConfiguration {
|
||||
*
|
||||
* @return a new builder instance.
|
||||
*/
|
||||
@SuppressWarnings("deprecation") // will be changed to private constructor and deprecation removed
|
||||
static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
@@ -43,14 +42,7 @@ public interface ExperimentalConfiguration {
|
||||
final class Builder implements io.helidon.common.Builder<ExperimentalConfiguration> {
|
||||
private Http2Configuration http2;
|
||||
|
||||
/**
|
||||
* Do not use this constructor.
|
||||
* Will be changed to {@code private} in next release.
|
||||
*
|
||||
* @deprecated use {@link ExperimentalConfiguration#builder()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public Builder() {
|
||||
private Builder() {
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import io.helidon.common.GenericType;
|
||||
@@ -197,8 +198,8 @@ abstract class Request implements ServerRequest {
|
||||
|
||||
private Span createReadSpan(GenericType<?> type) {
|
||||
// only create this span if we have a parent span
|
||||
SpanContext parentSpan = spanContext();
|
||||
if (null == parentSpan) {
|
||||
Optional<SpanContext> parentSpan = spanContext();
|
||||
if (parentSpan.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -212,7 +213,7 @@ abstract class Request implements ServerRequest {
|
||||
if (spanConfig.enabled()) {
|
||||
// only create a real span if enabled
|
||||
Tracer.SpanBuilder spanBuilder = tracer().buildSpan(spanName);
|
||||
spanBuilder.asChildOf(parentSpan);
|
||||
spanBuilder.asChildOf(parentSpan.get());
|
||||
|
||||
if (type != null) {
|
||||
spanBuilder.withTag("requested.type", type.getTypeName());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -270,15 +270,13 @@ class RequestRouting implements Routing {
|
||||
this.errorHandlers = new LinkedList<>(errorHandlers);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public Span span() {
|
||||
Span span() {
|
||||
return context().get(ServerRequest.class, Span.class).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpanContext spanContext() {
|
||||
return context().get(ServerRequest.class, SpanContext.class).orElse(null);
|
||||
public Optional<SpanContext> spanContext() {
|
||||
return context().get(ServerRequest.class, SpanContext.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -580,7 +580,7 @@ public interface ServerConfiguration extends SocketConfiguration {
|
||||
// experimental
|
||||
Config experimentalConfig = config.get("experimental");
|
||||
if (experimentalConfig.exists()) {
|
||||
ExperimentalConfiguration.Builder experimentalBuilder = new ExperimentalConfiguration.Builder();
|
||||
ExperimentalConfiguration.Builder experimentalBuilder = ExperimentalConfiguration.builder();
|
||||
Config http2Config = experimentalConfig.get("http2");
|
||||
if (http2Config.exists()) {
|
||||
Http2Configuration.Builder http2Builder = new Http2Configuration.Builder();
|
||||
|
||||
@@ -16,11 +16,12 @@
|
||||
|
||||
package io.helidon.webserver;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import io.helidon.common.context.Context;
|
||||
import io.helidon.common.http.HttpRequest;
|
||||
import io.helidon.media.common.MessageBodyReadableContent;
|
||||
|
||||
import io.opentracing.Span;
|
||||
import io.opentracing.SpanContext;
|
||||
import io.opentracing.Tracer;
|
||||
|
||||
@@ -120,28 +121,14 @@ public interface ServerRequest extends HttpRequest {
|
||||
*/
|
||||
long requestId();
|
||||
|
||||
/**
|
||||
* Returns a span connected with current {@link Handler} call.
|
||||
* <p>
|
||||
* {@code Span} is a tracing component from <a href="http://opentracing.io">opentracing.io</a> standard.
|
||||
*
|
||||
* @return a current span
|
||||
* @deprecated use {@link #spanContext()} instead
|
||||
*/
|
||||
@Deprecated
|
||||
Span span();
|
||||
|
||||
/**
|
||||
* Returns a span context related to the current request.
|
||||
* <p>
|
||||
* {@code SpanContext} is a tracing component from <a href="http://opentracing.io">opentracing.io</a> standard.
|
||||
*
|
||||
* @return the related span context, may be null if not enabled
|
||||
* @deprecated this method will have a different return type in next backward incompatible version
|
||||
* of Helidon. It will return {@code Optional<SpanContext>}. All methods that can return null will use
|
||||
* {@link java.util.Optional}
|
||||
* @return the related span context, empty if not enabled
|
||||
*/
|
||||
SpanContext spanContext();
|
||||
Optional<SpanContext> spanContext();
|
||||
|
||||
/**
|
||||
* Returns the {@link io.opentracing.Tracer} associated with {@link io.helidon.webserver.WebServer}.
|
||||
|
||||
@@ -184,7 +184,7 @@ public interface ServerResponse extends MessageBodyFilters, MessageBodyWriters {
|
||||
* @param <T> a type of the content
|
||||
* @return this instance of {@link ServerResponse}
|
||||
* @throws NullPointerException if {@code function} parameter is {@code null}
|
||||
* @deprecated use {@link #registerWriter(io.helidon.media.common.MessageBodyWriter)} instead
|
||||
* @deprecated Since 2.0.0, use {@link #registerWriter(io.helidon.media.common.MessageBodyWriter)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
<T> ServerResponse registerWriter(Class<T> type, Function<T, Publisher<DataChunk>> function);
|
||||
@@ -203,7 +203,7 @@ public interface ServerResponse extends MessageBodyFilters, MessageBodyWriters {
|
||||
* @param <T> a type of the content
|
||||
* @return this instance of {@link ServerResponse}
|
||||
* @throws NullPointerException if {@code function} parameter is {@code null}
|
||||
* @deprecated use {@link #registerWriter(io.helidon.media.common.MessageBodyWriter)} instead
|
||||
* @deprecated since 2.0.0, use {@link #registerWriter(io.helidon.media.common.MessageBodyWriter)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
<T> ServerResponse registerWriter(Class<T> type,
|
||||
@@ -221,7 +221,7 @@ public interface ServerResponse extends MessageBodyFilters, MessageBodyWriters {
|
||||
* @param <T> a type of the content
|
||||
* @return this instance of {@link ServerResponse}
|
||||
* @throws NullPointerException if {@code function} parameter is {@code null}
|
||||
* @deprecated use {@link #registerWriter(io.helidon.media.common.MessageBodyWriter)} instead
|
||||
* @deprecated since 2.0.0, use {@link #registerWriter(io.helidon.media.common.MessageBodyWriter)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
<T> ServerResponse registerWriter(Predicate<?> accept, Function<T, Publisher<DataChunk>> function);
|
||||
@@ -240,7 +240,7 @@ public interface ServerResponse extends MessageBodyFilters, MessageBodyWriters {
|
||||
* @param <T> a type of the content
|
||||
* @return this instance of {@link ServerResponse}
|
||||
* @throws NullPointerException if {@code function} parameter is {@code null}
|
||||
* @deprecated use {@link #registerWriter(io.helidon.media.common.MessageBodyWriter)} instead
|
||||
* @deprecated since 2.0.0, use {@link #registerWriter(io.helidon.media.common.MessageBodyWriter)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
<T> ServerResponse registerWriter(Predicate<?> accept,
|
||||
@@ -264,7 +264,7 @@ public interface ServerResponse extends MessageBodyFilters, MessageBodyWriters {
|
||||
* {@code null} then the result will be ignored.
|
||||
* @return this instance of {@link ServerResponse}
|
||||
* @throws NullPointerException if parameter {@code function} is {@code null}
|
||||
* @deprecated use {@link #registerFilter(io.helidon.media.common.MessageBodyFilter)} instead
|
||||
* @deprecated since 2.0.0, use {@link #registerFilter(io.helidon.media.common.MessageBodyFilter)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
ServerResponse registerFilter(Function<Publisher<DataChunk>, Publisher<DataChunk>> function);
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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 io.helidon.webserver;
|
||||
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.SimpleFormatter;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* The WebServerLogFormatter provides a way to customize logging messages.
|
||||
*/
|
||||
@Deprecated
|
||||
public class WebServerLogFormatter extends SimpleFormatter {
|
||||
|
||||
private static final Pattern THREAD_PATTERN = Pattern.compile("!thread!");
|
||||
|
||||
@Override
|
||||
public String format(LogRecord record) {
|
||||
String message = super.format(record);
|
||||
|
||||
return THREAD_PATTERN.matcher(message).replaceAll(Thread.currentThread().toString());
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -44,7 +44,7 @@ public class ExperimentalConfigTest {
|
||||
Http2Configuration http2 = builder.build();
|
||||
assertThat(http2.enable(), is(true));
|
||||
assertThat(http2.maxContentLength(), is(32 * 1024));
|
||||
ExperimentalConfiguration config = new ExperimentalConfiguration.Builder().http2(http2).build();
|
||||
ExperimentalConfiguration config = ExperimentalConfiguration.builder().http2(http2).build();
|
||||
assertThat(config.http2(), is(http2));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2020 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2020 Oracle and/or its affiliates.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,8 +16,10 @@
|
||||
|
||||
package io.helidon.webserver;
|
||||
|
||||
import io.helidon.common.reactive.Single;
|
||||
import java.net.URI;
|
||||
import java.util.Optional;
|
||||
|
||||
import io.helidon.common.reactive.Single;
|
||||
|
||||
import io.opentracing.Span;
|
||||
import io.opentracing.SpanContext;
|
||||
@@ -60,13 +62,8 @@ public class RequestTestStub extends Request {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Span span() {
|
||||
return span;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpanContext spanContext() {
|
||||
return span.context();
|
||||
public Optional<SpanContext> spanContext() {
|
||||
return Optional.ofNullable(span.context());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user