use of io.openk9.entity.manager.model.payload.Request in project openk9 by smclab.
the class AuthResource method logout.
@PermitAll
@Path("/v1/auth/logout")
@POST
public Uni<byte[]> logout(@Context HttpServerRequest context, RefreshToken request) {
String host = context.host();
Tenant tenant = _findTenant(host);
String realmName = tenant.getRealmName();
String clientSecret = tenant.getClientSecret();
String clientId = tenant.getClientId();
String refreshToken = request.getRefreshToken();
if (refreshToken == null) {
return Uni.createFrom().failure(() -> new HttpException(400, "required refreshToken"));
}
if (clientSecret != null) {
return _authClient.logout(realmName, clientId, clientSecret, refreshToken);
} else {
return _authClient.logout(realmName, clientId, refreshToken);
}
}
use of io.openk9.entity.manager.model.payload.Request in project openk9 by smclab.
the class AuthResource method refreshToken.
@PermitAll
@Path("/v1/auth/refresh")
@POST
public Uni<LoginResponseDTO> refreshToken(@Context HttpServerRequest context, RefreshToken request) {
String host = context.host();
Tenant tenant = _findTenant(host);
String realmName = tenant.getRealmName();
String clientSecret = tenant.getClientSecret();
String clientId = tenant.getClientId();
String refreshToken = request.getRefreshToken();
if (refreshToken == null) {
return Uni.createFrom().failure(() -> new HttpException(400, "required refreshToken"));
}
if (clientSecret != null) {
return _authClient.refresh(realmName, clientId, clientSecret, refreshToken, "refresh_token");
} else {
return _authClient.refresh(realmName, clientId, refreshToken, "refresh_token");
}
}
use of io.openk9.entity.manager.model.payload.Request in project openk9 by smclab.
the class EntityManagerConsumer method consume.
@Incoming("entity-manager-request")
@Outgoing("entity-manager-response")
@Blocking
public Message<JsonObject> consume(Object obj) throws InterruptedException {
JsonObject jsonObject = obj instanceof JsonObject ? (JsonObject) obj : new JsonObject(new String((byte[]) obj));
Payload payload = jsonObject.mapTo(Payload.class);
_entityManagerQueue.offer(payload, 45, TimeUnit.SECONDS);
String replyTo = payload.getReplyTo();
return Message.of(jsonObject, Metadata.of(new OutgoingRabbitMQMetadata.Builder().withRoutingKey(replyTo).withTimestamp(ZonedDateTime.now()).build()));
}
use of io.openk9.entity.manager.model.payload.Request in project openk9 by smclab.
the class AuthResource method login.
@PermitAll
@Path("/v1/auth/login")
@POST
public Uni<LoginResponseDTO> login(@Context HttpServerRequest context, LoginRequest request) {
String host = context.host();
Tenant tenant = _findTenant(host);
String realmName = tenant.getRealmName();
String clientSecret = tenant.getClientSecret();
String clientId = tenant.getClientId();
String username = request.getUsername();
String password = request.getPassword();
if (username == null) {
return Uni.createFrom().failure(() -> new HttpException(400, "required username"));
}
if (password == null) {
return Uni.createFrom().failure(() -> new HttpException(400, "required password"));
}
if (clientSecret != null) {
return _authClient.login(realmName, username, password, clientId, clientSecret, "password");
} else {
return _authClient.login(realmName, username, password, clientId, "password");
}
}
use of io.openk9.entity.manager.model.payload.Request in project openk9 by smclab.
the class JsEnrichProcessor method prepareRequestRawContent.
protected ObjectNode prepareRequestRawContent(ObjectNode objectNode, ObjectNode datasourceConfiguration, DatasourceContext context, PluginDriverDTO pluginDriverDTO) {
JsonNode rawContentNode = objectNode.get(Constants.RAW_CONTENT);
JsonNode codeNode = datasourceConfiguration.get(Constants.CODE);
ObjectNode request = _jsonFactory.createObjectNode();
request.put(Constants.CODE, codeNode);
request.put(Constants.CONTENT, rawContentNode);
JsonNode typeNode = objectNode.get(Constants.TYPE);
ObjectNode datasourcePayload = _jsonFactory.createObjectNode();
if (typeNode != null && typeNode.isArray()) {
ArrayNode types = typeNode.toArrayNode();
for (JsonNode typeJsonNode : types) {
String type = typeJsonNode.asText();
datasourcePayload.put(type, objectNode.get(type));
}
}
request.put(Constants.DATASOURCE_PAYLOAD, datasourcePayload);
request.put(Constants.TENANT_ID, context.getTenant().getTenantId());
request.put(Constants.DATASOURCE_ID, context.getDatasource().getDatasourceId());
request.put(Constants.CONTENT_ID, objectNode.get(Constants.CONTENT_ID));
return request;
}
Aggregations