use of io.helidon.config.Config in project helidon by oracle.
the class SmokeTest method testPropertiesParser.
@Test
public void testPropertiesParser() {
Config config = Config.builder().sources(ConfigSources.create("key=value", "text/x-java-properties")).build();
assertThat(config.get("key").asString(), is(ConfigValues.simpleValue("value")));
}
use of io.helidon.config.Config in project helidon by oracle.
the class ConfigCreateDefaultFromPropertiesTest method testCreateKeyFromSysProps.
@Test
@ExtendWith(RestoreSystemPropertiesExt.class)
public void testCreateKeyFromSysProps() {
System.setProperty(KEY, PROP_VALUE);
Config config = Config.create();
assertThat(config.get(KEY).asString(), is(ConfigValues.simpleValue(PROP_VALUE)));
}
use of io.helidon.config.Config in project helidon by oracle.
the class ConfigCreateDefaultFromPropertiesTest method testCreate.
@Test
@ExtendWith(RestoreSystemPropertiesExt.class)
public void testCreate() {
Config config = Config.create();
assertThat(config.get(KEY).asString().get(), is(CONFIG_VALUE));
}
use of io.helidon.config.Config in project helidon by oracle.
the class AtnProvider method syncAuthenticate.
@Override
protected AuthenticationResponse syncAuthenticate(ProviderRequest providerRequest) {
EndpointConfig endpointConfig = providerRequest.endpointConfig();
Config atnConfig = endpointConfig.config(CONFIG_KEY).orElse(null);
Subject user = null;
Subject service = null;
List<Auth> list;
Optional<AtnConfig> optional = providerRequest.endpointConfig().instance(AtnConfig.class);
if (optional.isPresent()) {
list = optional.get().auths();
} else if (atnConfig != null && !atnConfig.isLeaf()) {
list = atnConfig.asNodeList().map(this::fromConfig).orElse(Collections.emptyList());
} else {
list = fromAnnotations(endpointConfig);
}
for (Auth authentication : list) {
if (authentication.type() == SubjectType.USER) {
user = buildSubject(authentication);
} else {
service = buildSubject(authentication);
}
}
return AuthenticationResponse.success(user, service);
}
use of io.helidon.config.Config in project helidon by oracle.
the class SecureGreetClient method main.
/**
* Program entry point.
*
* @param args program arguments
*/
public static void main(String[] args) {
Channel channel = ManagedChannelBuilder.forAddress("localhost", 1408).usePlaintext().build();
Config config = Config.create();
// configure Helidon security and add the basic auth provider
Security security = Security.builder().addProvider(HttpBasicAuthProvider.create(config.get("http-basic-auth"))).build();
// create the gRPC client security call credentials
// setting the properties used by the basic auth provider for user name and password
GrpcClientSecurity clientSecurity = GrpcClientSecurity.builder(security.createContext("test.client")).property(HttpBasicAuthProvider.EP_PROPERTY_OUTBOUND_USER, "Bob").property(HttpBasicAuthProvider.EP_PROPERTY_OUTBOUND_PASSWORD, "password").build();
// create the GreetService client stub and use the GrpcClientSecurity call credentials
GreetServiceGrpc.GreetServiceBlockingStub stub = GreetServiceGrpc.newBlockingStub(channel).withCallCredentials(clientSecurity);
Greet.GreetResponse greetResponse = stub.greet(Greet.GreetRequest.newBuilder().setName("Bob").build());
System.out.println(greetResponse.getMessage());
Greet.SetGreetingResponse setGreetingResponse = stub.setGreeting(Greet.SetGreetingRequest.newBuilder().setGreeting("Merhaba").build());
System.out.println("Greeting set to: " + setGreetingResponse.getGreeting());
greetResponse = stub.greet(Greet.GreetRequest.newBuilder().setName("Bob").build());
System.out.println(greetResponse.getMessage());
}
Aggregations