Compare commits

...

8 Commits

15 changed files with 140 additions and 113 deletions

View File

@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<classpath> <classpath>
<classpathentry including="**/*.java" kind="src" output="out/maven/classes" path="src"> <classpathentry including="**/*.java" kind="src" output="target/classes" path="src">
<attributes> <attributes>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="src" output="out/maven/test-classes" path="test/src"> <classpathentry kind="src" output="target/test-classes" path="test/src">
<attributes> <attributes>
<attribute name="test" value="true"/> <attribute name="test" value="true"/>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
@@ -18,17 +18,17 @@
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry excluding="**" kind="src" output="out/maven/test-classes" path="test/resources"> <classpathentry excluding="**" kind="src" output="target/test-classes" path="test/resources">
<attributes> <attributes>
<attribute name="test" value="true"/> <attribute name="test" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-21"> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="output" path="out/maven/classes"/> <classpathentry kind="output" path="target/classes"/>
</classpath> </classpath>

4
.island/release.bash Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/bash
mvn versions:set -DnewVersion=$(cat version.txt)

View File

@@ -84,7 +84,6 @@ Reformat XML file like the pom.xml
XMLLINT_INDENT=" " xmllint --format "back/pom.xml" -o "back/pom.xml" XMLLINT_INDENT=" " xmllint --format "back/pom.xml" -o "back/pom.xml"
``` ```
Enable the pre-commit checker Enable the pre-commit checker
----------------------------- -----------------------------
@@ -94,6 +93,8 @@ Enable the pre-commit checker
> **_Note_**: You can change the code in `.git/hooks/pre-commit` by replacing `formatter:verify` with `formatter:format` to auto format the code @ every commit > **_Note_**: You can change the code in `.git/hooks/pre-commit` by replacing `formatter:verify` with `formatter:format` to auto format the code @ every commit
Add Gitea in the dependency for the registry: Add Gitea in the dependency for the registry:
============================================= =============================================

17
pom.xml
View File

@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>kangaroo-and-rabbit</groupId> <groupId>kangaroo-and-rabbit</groupId>
<artifactId>archidata</artifactId> <artifactId>archidata</artifactId>
<version>0.6.0</version> <version>0.6.1</version>
<properties> <properties>
<maven.compiler.version>3.1</maven.compiler.version> <maven.compiler.version>3.1</maven.compiler.version>
<maven.compiler.source>21</maven.compiler.source> <maven.compiler.source>21</maven.compiler.source>
@@ -160,7 +160,18 @@
<version>5.10.1</version> <version>5.10.1</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<version>2.23.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.3.1</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
<sourceDirectory>src</sourceDirectory> <sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test/src</testSourceDirectory> <testSourceDirectory>test/src</testSourceDirectory>
@@ -241,7 +252,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId> <artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.0</version> <version>3.3.1</version>
<configuration> <configuration>
<configLocation>CheckStyle.xml</configLocation> <configLocation>CheckStyle.xml</configLocation>
<consoleOutput>true</consoleOutput> <consoleOutput>true</consoleOutput>
@@ -253,7 +264,7 @@
<plugin> <plugin>
<groupId>net.revelc.code.formatter</groupId> <groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId> <artifactId>formatter-maven-plugin</artifactId>
<version>2.12.2</version> <version>2.23.0</version>
<configuration> <configuration>
<encoding>UTF-8</encoding> <encoding>UTF-8</encoding>
<lineEnding>LF</lineEnding> <lineEnding>LF</lineEnding>

View File

@@ -22,7 +22,7 @@ public class JacksonCatcher implements ExceptionMapper<JsonProcessingException>
} }
private RestErrorResponse build(final Exception exception) { private RestErrorResponse build(final Exception exception) {
return new RestErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, "Catch Unknown Exception", exception.getMessage()); return new RestErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, "Catch JSON Exception", exception.getMessage());
} }
} }

View File

@@ -960,7 +960,10 @@ public class DataAccess {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static <T> List<T> getsWhere(final Class<T> clazz, final QueryOptions options) throws Exception { public static <T> List<T> getsWhere(final Class<T> clazz, final QueryOptions options) throws Exception {
final Condition condition = options.get(Condition.class); Condition condition = options.get(Condition.class);
if (condition == null) {
condition = new Condition();
}
final List<LazyGetter> lazyCall = new ArrayList<>(); final List<LazyGetter> lazyCall = new ArrayList<>();
final String deletedFieldName = AnnotationTools.getDeletedFieldName(clazz); final String deletedFieldName = AnnotationTools.getDeletedFieldName(clazz);
DBEntry entry = DBEntry.createInterface(GlobalConfiguration.dbConfig); DBEntry entry = DBEntry.createInterface(GlobalConfiguration.dbConfig);
@@ -979,9 +982,7 @@ public class DataAccess {
generateSelectField(querySelect, query, clazz, options, count); generateSelectField(querySelect, query, clazz, options, count);
querySelect.append(query.toString()); querySelect.append(query.toString());
query = querySelect; query = querySelect;
if (condition != null) {
condition.whereAppendQuery(query, tableName, options, deletedFieldName); condition.whereAppendQuery(query, tableName, options, deletedFieldName);
}
final OrderBy orders = options.get(OrderBy.class); final OrderBy orders = options.get(OrderBy.class);
if (orders != null) { if (orders != null) {
orders.generateQuerry(query, tableName); orders.generateQuerry(query, tableName);
@@ -994,9 +995,7 @@ public class DataAccess {
// prepare the request: // prepare the request:
final PreparedStatement ps = entry.connection.prepareStatement(query.toString(), Statement.RETURN_GENERATED_KEYS); final PreparedStatement ps = entry.connection.prepareStatement(query.toString(), Statement.RETURN_GENERATED_KEYS);
final CountInOut iii = new CountInOut(1); final CountInOut iii = new CountInOut(1);
if (condition != null) {
condition.injectQuerry(ps, iii); condition.injectQuerry(ps, iii);
}
if (limit != null) { if (limit != null) {
limit.injectQuerry(ps, iii); limit.injectQuerry(ps, iii);
} }
@@ -1066,7 +1065,10 @@ public class DataAccess {
public static long countWhere(final Class<?> clazz, final QueryOption... option) throws Exception { public static long countWhere(final Class<?> clazz, final QueryOption... option) throws Exception {
final QueryOptions options = new QueryOptions(option); final QueryOptions options = new QueryOptions(option);
final Condition condition = options.get(Condition.class); Condition condition = options.get(Condition.class);
if (condition == null) {
condition = new Condition();
}
final String deletedFieldName = AnnotationTools.getDeletedFieldName(clazz); final String deletedFieldName = AnnotationTools.getDeletedFieldName(clazz);
DBEntry entry = DBEntry.createInterface(GlobalConfiguration.dbConfig); DBEntry entry = DBEntry.createInterface(GlobalConfiguration.dbConfig);
long count = 0; long count = 0;
@@ -1077,9 +1079,7 @@ public class DataAccess {
query.append("SELECT COUNT(*) AS count FROM `"); query.append("SELECT COUNT(*) AS count FROM `");
query.append(tableName); query.append(tableName);
query.append("` "); query.append("` ");
if (condition != null) {
condition.whereAppendQuery(query, tableName, options, deletedFieldName); condition.whereAppendQuery(query, tableName, options, deletedFieldName);
}
final Limit limit = options.get(Limit.class); final Limit limit = options.get(Limit.class);
if (limit != null) { if (limit != null) {
limit.generateQuerry(query, tableName); limit.generateQuerry(query, tableName);
@@ -1088,9 +1088,7 @@ public class DataAccess {
// prepare the request: // prepare the request:
final PreparedStatement ps = entry.connection.prepareStatement(query.toString(), Statement.RETURN_GENERATED_KEYS); final PreparedStatement ps = entry.connection.prepareStatement(query.toString(), Statement.RETURN_GENERATED_KEYS);
final CountInOut iii = new CountInOut(1); final CountInOut iii = new CountInOut(1);
if (condition != null) {
condition.injectQuerry(ps, iii); condition.injectQuerry(ps, iii);
}
if (limit != null) { if (limit != null) {
limit.injectQuerry(ps, iii); limit.injectQuerry(ps, iii);
} }

View File

@@ -83,7 +83,7 @@ public class AddOnSQLTableExternalForeinKeyAsList implements DataAccessAddOn {
@Override @Override
public boolean canRetrieve(final Field field) { public boolean canRetrieve(final Field field) {
return false; return true;
} }
@Override @Override

View File

@@ -52,7 +52,7 @@ public class DBEntry implements Closeable {
try { try {
this.connection = DriverManager.getConnection(this.config.getUrl(true), this.config.getLogin(), this.config.getPassword()); this.connection = DriverManager.getConnection(this.config.getUrl(true), this.config.getLogin(), this.config.getPassword());
} catch (final SQLException ex) { } catch (final SQLException ex) {
throw new IOException("Connection db fail: " + ex.getMessage()); throw new IOException("Connection db fail: " + ex.getMessage() + " On URL: " + this.config.getUrl(true));
} }
} }
@@ -61,7 +61,7 @@ public class DBEntry implements Closeable {
try { try {
this.connection = DriverManager.getConnection(this.config.getUrl(), this.config.getLogin(), this.config.getPassword()); this.connection = DriverManager.getConnection(this.config.getUrl(), this.config.getLogin(), this.config.getPassword());
} catch (final SQLException ex) { } catch (final SQLException ex) {
throw new IOException("Connection db fail: " + ex.getMessage()); throw new IOException("Connection db fail: " + ex.getMessage() + " On URL: " + this.config.getUrl(true));
} }
} }

View File

@@ -43,8 +43,8 @@ public class AuthenticationFilter implements ContainerRequestFilter {
private ResourceInfo resourceInfo; private ResourceInfo resourceInfo;
protected final String applicationName; protected final String applicationName;
private static final String AUTHENTICATION_SCHEME = "Yota"; public static final String AUTHENTICATION_SCHEME = "Bearer";
private static final String AUTHENTICATION_TOKEN_SCHEME = "Zota"; public static final String APIKEY = "ApiKey";
public AuthenticationFilter(final String applicationName) { public AuthenticationFilter(final String applicationName) {
this.applicationName = applicationName; this.applicationName = applicationName;
@@ -58,7 +58,7 @@ public class AuthenticationFilter implements ContainerRequestFilter {
// Access denied for all // Access denied for all
if (method.isAnnotationPresent(DenyAll.class)) { if (method.isAnnotationPresent(DenyAll.class)) {
LOGGER.debug(" ==> deny all {}", requestContext.getUriInfo().getPath()); LOGGER.debug(" ==> deny all {}", requestContext.getUriInfo().getPath());
requestContext.abortWith(Response.status(Response.Status.FORBIDDEN).entity("Access blocked !!!").build()); abortWithForbidden(requestContext, "Access blocked !!!");
return; return;
} }
@@ -71,28 +71,28 @@ public class AuthenticationFilter implements ContainerRequestFilter {
// this is a security guard, all the API must define their access level: // this is a security guard, all the API must define their access level:
if (!method.isAnnotationPresent(RolesAllowed.class)) { if (!method.isAnnotationPresent(RolesAllowed.class)) {
LOGGER.error(" ==> missing @RolesAllowed {}", requestContext.getUriInfo().getPath()); LOGGER.error(" ==> missing @RolesAllowed {}", requestContext.getUriInfo().getPath());
requestContext.abortWith(Response.status(Response.Status.FORBIDDEN).entity("Access ILLEGAL !!!").build()); abortWithForbidden(requestContext, "Access ILLEGAL !!!");
return; return;
} }
// Get the Authorization header from the request // Get the Authorization header from the request
String authorizationHeader = requestContext.getHeaderString(HttpHeaders.AUTHORIZATION); String authorizationHeader = requestContext.getHeaderString(HttpHeaders.AUTHORIZATION);
String apikeyHeader = requestContext.getHeaderString(APIKEY);
// logger.debug("authorizationHeader: {}", authorizationHeader); // logger.debug("authorizationHeader: {}", authorizationHeader);
if (authorizationHeader == null && method.isAnnotationPresent(PermitTokenInURI.class)) { if (authorizationHeader == null && apikeyHeader == null && method.isAnnotationPresent(PermitTokenInURI.class)) {
final MultivaluedMap<String, String> quaryparam = requestContext.getUriInfo().getQueryParameters(); final MultivaluedMap<String, String> quaryparam = requestContext.getUriInfo().getQueryParameters();
for (final Entry<String, List<String>> item : quaryparam.entrySet()) { for (final Entry<String, List<String>> item : quaryparam.entrySet()) {
if (item.getKey().equals(HttpHeaders.AUTHORIZATION)) { if ((authorizationHeader == null && HttpHeaders.AUTHORIZATION.equals(item.getKey())) && !item.getValue().isEmpty()) {
if (!item.getValue().isEmpty()) {
authorizationHeader = item.getValue().get(0); authorizationHeader = item.getValue().get(0);
} }
break; if ((apikeyHeader == null && APIKEY.equals(item.getKey())) && !item.getValue().isEmpty()) {
apikeyHeader = item.getValue().get(0);
} }
} }
} }
// logger.debug("authorizationHeader: {}", authorizationHeader); // logger.debug("authorizationHeader: {}", authorizationHeader);
final boolean isApplicationToken = isApplicationTokenBasedAuthentication(authorizationHeader); final boolean isApplicationToken = apikeyHeader != null;
final boolean isJwtToken = isTokenBasedAuthentication(authorizationHeader); final boolean isJwtToken = isTokenBasedAuthentication(authorizationHeader);
// Validate the Authorization header data Model "Yota jwt.to.ken" "Zota tokenId:hash(token)"
if (!isApplicationToken && !isJwtToken) { if (!isApplicationToken && !isJwtToken) {
LOGGER.warn("REJECTED unauthorized: {}", requestContext.getUriInfo().getPath()); LOGGER.warn("REJECTED unauthorized: {}", requestContext.getUriInfo().getPath());
abortWithUnauthorized(requestContext, "REJECTED unauthorized: " + requestContext.getUriInfo().getPath()); abortWithUnauthorized(requestContext, "REJECTED unauthorized: " + requestContext.getUriInfo().getPath());
@@ -100,7 +100,7 @@ public class AuthenticationFilter implements ContainerRequestFilter {
} }
UserByToken userByToken = null; UserByToken userByToken = null;
if (isJwtToken) { if (isJwtToken) {
// Extract the token from the Authorization header (Remove "Yota ") // Extract the token from the Authorization header (Remove "Bearer ")
final String token = authorizationHeader.substring(AUTHENTICATION_SCHEME.length()).trim(); final String token = authorizationHeader.substring(AUTHENTICATION_SCHEME.length()).trim();
// logger.debug("token: {}", token); // logger.debug("token: {}", token);
try { try {
@@ -116,9 +116,7 @@ public class AuthenticationFilter implements ContainerRequestFilter {
return; return;
} }
} else { } else {
// Extract the token from the Authorization header (Remove "Zota ") final String token = apikeyHeader.trim();
final String token = authorizationHeader.substring(AUTHENTICATION_TOKEN_SCHEME.length()).trim();
// logger.debug("token: {}", token);
try { try {
userByToken = validateToken(token); userByToken = validateToken(token);
} catch (final Exception e) { } catch (final Exception e) {
@@ -164,13 +162,6 @@ public class AuthenticationFilter implements ContainerRequestFilter {
return authorizationHeader != null && authorizationHeader.toLowerCase().startsWith(AUTHENTICATION_SCHEME.toLowerCase() + " "); return authorizationHeader != null && authorizationHeader.toLowerCase().startsWith(AUTHENTICATION_SCHEME.toLowerCase() + " ");
} }
private boolean isApplicationTokenBasedAuthentication(final String authorizationHeader) {
// Check if the Authorization header is valid
// It must not be null and must be prefixed with "Bearer" plus a whitespace
// The authentication scheme comparison must be case-insensitive
return authorizationHeader != null && authorizationHeader.toLowerCase().startsWith(AUTHENTICATION_TOKEN_SCHEME.toLowerCase() + " ");
}
private void abortWithUnauthorized(final ContainerRequestContext requestContext, final String message) { private void abortWithUnauthorized(final ContainerRequestContext requestContext, final String message) {
// Abort the filter chain with a 401 status code response // Abort the filter chain with a 401 status code response
@@ -182,6 +173,12 @@ public class AuthenticationFilter implements ContainerRequestFilter {
.type(MediaType.APPLICATION_JSON).build()); .type(MediaType.APPLICATION_JSON).build());
} }
private void abortWithForbidden(final ContainerRequestContext requestContext, final String message) {
final RestErrorResponse ret = new RestErrorResponse(Response.Status.FORBIDDEN, "FORBIDDEN", message);
LOGGER.error("Error UUID={}", ret.uuid);
requestContext.abortWith(Response.status(ret.status).header(HttpHeaders.WWW_AUTHENTICATE, message).entity(ret).type(MediaType.APPLICATION_JSON).build());
}
protected UserByToken validateToken(final String authorization) throws Exception { protected UserByToken validateToken(final String authorization) throws Exception {
LOGGER.info("Must be Override by the application implmentation, otherwise it dose not work"); LOGGER.info("Must be Override by the application implmentation, otherwise it dose not work");
return null; return null;

View File

@@ -35,13 +35,13 @@ class MySecurityContext implements SecurityContext {
@Override @Override
public boolean isSecure() { public boolean isSecure() {
return this.sheme.equalsIgnoreCase("https"); return "https".equalsIgnoreCase(this.sheme);
} }
@Override @Override
public String getAuthenticationScheme() { public String getAuthenticationScheme() {
if (this.contextPrincipale.userByToken != null) { if (this.contextPrincipale.userByToken != null) {
return "Zota"; return "Bearer";
} }
return null; return null;
} }

View File

@@ -14,6 +14,9 @@ public class ConfigBaseVariable {
static public String ssoAdress; static public String ssoAdress;
static public String ssoToken; static public String ssoToken;
static public String testMode; static public String testMode;
static public String eMailFrom;
static public String eMailLogin;
static public String eMailPassword;
// For test only // For test only
public static void clearAllValue() { public static void clearAllValue() {
@@ -30,6 +33,9 @@ public class ConfigBaseVariable {
ssoAdress = System.getenv("SSO_ADDRESS"); ssoAdress = System.getenv("SSO_ADDRESS");
ssoToken = System.getenv("SSO_TOKEN"); ssoToken = System.getenv("SSO_TOKEN");
testMode = System.getenv("TEST_MODE"); testMode = System.getenv("TEST_MODE");
eMailFrom = System.getenv("EMAIL_FROM");
eMailLogin = System.getenv("EMAIL_LOGIN");
eMailPassword = System.getenv("EMAIL_PASSWORD");
} }
static { static {
@@ -120,4 +126,15 @@ public class ConfigBaseVariable {
} }
return Boolean.parseBoolean(testMode); return Boolean.parseBoolean(testMode);
} }
public record EMailConfig(String from, String login, String password) {
};
public static EMailConfig getEMailConfig() {
if (eMailFrom == null || eMailLogin == null || eMailPassword == null) {
return null;
}
return new EMailConfig(eMailFrom, eMailLogin, eMailPassword);
}
} }

View File

@@ -11,6 +11,7 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import org.kar.archidata.filter.AuthenticationFilter;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -64,7 +65,7 @@ class TestSigner implements JWSSigner {
public class JWTWrapper { public class JWTWrapper {
static final Logger LOGGER = LoggerFactory.getLogger(JWTWrapper.class); static final Logger LOGGER = LoggerFactory.getLogger(JWTWrapper.class);
private static RSAKey rsaJWK = null;; private static RSAKey rsaJWK = null;
private static RSAKey rsaPublicJWK = null; private static RSAKey rsaPublicJWK = null;
public static class PublicKey { public static class PublicKey {
@@ -89,7 +90,7 @@ public class JWTWrapper {
con.setRequestProperty("Accept", "application/json"); con.setRequestProperty("Accept", "application/json");
final String ssoToken = ConfigBaseVariable.ssoToken(); final String ssoToken = ConfigBaseVariable.ssoToken();
if (ssoToken != null) { if (ssoToken != null) {
con.setRequestProperty("Authorization", "Zota " + ssoToken); con.setRequestProperty(AuthenticationFilter.APIKEY, ssoToken);
} }
final int responseCode = con.getResponseCode(); final int responseCode = con.getResponseCode();
@@ -244,9 +245,7 @@ public class JWTWrapper {
// LOGGER.debug("JWT token is verified 'alice' =?= '" + signedJWT.getJWTClaimsSet().getSubject() + "'"); // LOGGER.debug("JWT token is verified 'alice' =?= '" + signedJWT.getJWTClaimsSet().getSubject() + "'");
// LOGGER.debug("JWT token isuer 'https://c2id.com' =?= '" + signedJWT.getJWTClaimsSet().getIssuer() + "'"); // LOGGER.debug("JWT token isuer 'https://c2id.com' =?= '" + signedJWT.getJWTClaimsSet().getIssuer() + "'");
return signedJWT.getJWTClaimsSet(); return signedJWT.getJWTClaimsSet();
} catch (final JOSEException ex) { } catch (final JOSEException | ParseException e) {
ex.printStackTrace();
} catch (final ParseException e) {
e.printStackTrace(); e.printStackTrace();
} }
return null; return null;

View File

@@ -40,7 +40,7 @@ public class RESTApi {
final HttpClient client = HttpClient.newHttpClient(); final HttpClient client = HttpClient.newHttpClient();
Builder requestBuilding = HttpRequest.newBuilder().version(Version.HTTP_1_1).uri(URI.create(this.baseUrl + urlOffset)); Builder requestBuilding = HttpRequest.newBuilder().version(Version.HTTP_1_1).uri(URI.create(this.baseUrl + urlOffset));
if (this.token != null) { if (this.token != null) {
requestBuilding = requestBuilding.header(HttpHeaders.AUTHORIZATION, "Yota " + this.token); requestBuilding = requestBuilding.header(HttpHeaders.AUTHORIZATION, "Bearer " + this.token);
} }
final HttpRequest request = requestBuilding.GET().build(); final HttpRequest request = requestBuilding.GET().build();
final HttpResponse<String> httpResponse = client.send(request, HttpResponse.BodyHandlers.ofString()); final HttpResponse<String> httpResponse = client.send(request, HttpResponse.BodyHandlers.ofString());
@@ -111,7 +111,7 @@ public class RESTApi {
LOGGER.trace("call {}: {}", model, URI.create(this.baseUrl + urlOffset)); LOGGER.trace("call {}: {}", model, URI.create(this.baseUrl + urlOffset));
LOGGER.trace("DATA: {}", body); LOGGER.trace("DATA: {}", body);
if (this.token != null) { if (this.token != null) {
requestBuilding = requestBuilding.header(HttpHeaders.AUTHORIZATION, "Yota " + this.token); requestBuilding = requestBuilding.header(HttpHeaders.AUTHORIZATION, "Bearer " + this.token);
} }
if (body == null) { if (body == null) {
body = ""; body = "";
@@ -143,7 +143,7 @@ public class RESTApi {
String body = null; String body = null;
Builder requestBuilding = HttpRequest.newBuilder().version(Version.HTTP_1_1).uri(URI.create(this.baseUrl + urlOffset)); Builder requestBuilding = HttpRequest.newBuilder().version(Version.HTTP_1_1).uri(URI.create(this.baseUrl + urlOffset));
if (this.token != null) { if (this.token != null) {
requestBuilding = requestBuilding.header(HttpHeaders.AUTHORIZATION, "Yota " + this.token); requestBuilding = requestBuilding.header(HttpHeaders.AUTHORIZATION, "Bearer " + this.token);
} }
if (data == null) { if (data == null) {
body = ""; body = "";
@@ -171,7 +171,7 @@ public class RESTApi {
final HttpClient client = HttpClient.newHttpClient(); final HttpClient client = HttpClient.newHttpClient();
Builder requestBuilding = HttpRequest.newBuilder().version(Version.HTTP_1_1).uri(URI.create(this.baseUrl + urlOffset)); Builder requestBuilding = HttpRequest.newBuilder().version(Version.HTTP_1_1).uri(URI.create(this.baseUrl + urlOffset));
if (this.token != null) { if (this.token != null) {
requestBuilding = requestBuilding.header(HttpHeaders.AUTHORIZATION, "Yota " + this.token); requestBuilding = requestBuilding.header(HttpHeaders.AUTHORIZATION, "Bearer " + this.token);
} }
final HttpRequest request = requestBuilding.DELETE().build(); final HttpRequest request = requestBuilding.DELETE().build();
final HttpResponse<String> httpResponse = client.send(request, HttpResponse.BodyHandlers.ofString()); final HttpResponse<String> httpResponse = client.send(request, HttpResponse.BodyHandlers.ofString());

View File

@@ -23,5 +23,5 @@ function __run() #(step, name, cmd)
fi fi
} }
__run "1/1" "Check JAVA code format" "mvn formatter:verify" __run "1/1" "Check JAVA code format" "mvn formatter:validate"

View File

@@ -1 +1 @@
0.6.0 0.6.1