* ========================LICENSE_START=================================
* O-RAN-SC
* %%
- * Copyright (C) 2022 Nordix Foundation
+ * Copyright (C) 2023 Nordix Foundation
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* ========================LICENSE_END===================================
*/
-package org.oran.pmlog.clients;
+package org.oran.pmlog.oauth2;
import java.lang.invoke.MethodHandles;
import java.nio.file.Files;
import java.nio.file.Path;
+import lombok.Getter;
import lombok.Setter;
import org.slf4j.Logger;
private String authToken = "";
+ @Getter
+ private static SecurityContext instance;
+
@Setter
private Path authTokenFilePath;
public SecurityContext(@Value("${app.auth-token-file:}") String authTokenFilename) {
+ instance = this;
if (!authTokenFilename.isEmpty()) {
this.authTokenFilePath = Path.of(authTokenFilename);
}
public synchronized String getBearerAuthToken() {
if (!isConfigured()) {
+ logger.warn("No configuration for auth token");
return "";
}
try {
long lastModified = authTokenFilePath.toFile().lastModified();
if (tokenTimestamp == 0 || lastModified != this.tokenTimestamp) {
this.authToken = Files.readString(authTokenFilePath);
+ this.authToken = this.authToken.trim();
this.tokenTimestamp = lastModified;
}
} catch (Exception e) {