code format

This commit is contained in:
Alfredo Oliviero 2024-04-17 20:59:23 +02:00
parent ae67b28d16
commit 866c9b2d9a
16 changed files with 175 additions and 181 deletions

View File

@ -281,7 +281,7 @@ java.lang.NoClassDefFoundError: org/apache/http/ssl/TrustStrategy
</exclusions>
</dependency>
<!--
<!--
<dependency>
<groupId>org.gcube.resources.discovery</groupId>
<artifactId>ic-client</artifactId>

View File

@ -24,7 +24,8 @@ import jakarta.ws.rs.WebApplicationException;
public class AdminKeycloakController {
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(AdminKeycloakController.class);
// TODO: Using Keycloak Admin Client to create user with roles (Realm and Client level)
// TODO: Using Keycloak Admin Client to create user with roles (Realm and Client
// level)
// https://gist.github.com/thomasdarimont/c4e739c5a319cf78a4cff3b87173a84b
public static UserRepresentation createUser(String username, String email, String password, String firstName,
String lastName, Map<String, List<String>> attributes, List<String> roles) throws WebApplicationException {

View File

@ -8,8 +8,6 @@ import org.gcube.common.security.Owner;
import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.common.security.secrets.Secret;
public class AuthController {
public final static String IDM_SERVICE_READ = "idm-service-read";
public final static String IDM_SERVICE_ADMIN = "idm-service-admin";
@ -61,9 +59,8 @@ public class AuthController {
String access_token = getAccessToken();
Owner owner = getOwner();
for (String role : roles){
if ( checkContextRole(role, owner) || checkRealmRole(role, access_token)){
for (String role : roles) {
if (checkContextRole(role, owner) || checkRealmRole(role, access_token)) {
return true;
}
}

View File

@ -32,8 +32,7 @@ public class KCUserController {
return users;
}
public static Object formatListUsers(List<UserRepresentation> users, KCUserController.REPRESENTATION format){
public static Object formatListUsers(List<UserRepresentation> users, KCUserController.REPRESENTATION format) {
if (format.equals(KCUserController.REPRESENTATION.username)) {
List<String> usernames = new ArrayList<String>();
@ -60,11 +59,11 @@ public class KCUserController {
}
}
return ids;
}else if (format.equals(KCUserController.REPRESENTATION.email_username)) {
} else if (format.equals(KCUserController.REPRESENTATION.email_username)) {
Map<String, String> usernamesAndFullnames = new HashMap<String, String>();
users.forEach(user -> usernamesAndFullnames.put(user.getUsername(), user.getEmail()));
return usernamesAndFullnames;
}else if (format.equals(KCUserController.REPRESENTATION.fullname)) {
} else if (format.equals(KCUserController.REPRESENTATION.fullname)) {
List<String> fullnames = new ArrayList<String>();
if (users != null) {
for (UserRepresentation user : users) {

View File

@ -19,8 +19,7 @@ public class IsServerConfig {
private String grantType = OAuth2Constants.CLIENT_CREDENTIALS;
public Map<String, String> getProperties(){
public Map<String, String> getProperties() {
return this.properties;
}

View File

@ -62,11 +62,12 @@ public class KkClientFactory {
logger.info("KeycloakAPICredentials object built {} - {}", config.getServerUrl(), config.getName());
}
// public IsServerConfig configFromINI() throws NotFoundException, ServerException{
// public IsServerConfig configFromINI() throws NotFoundException,
// ServerException{
// ApplicationContext appContext = ContextProvider.get();
// SimpleCredentials credentials = (SimpleCredentials)appContext.authorizationProvider().getCredentials();
// SimpleCredentials credentials =
// (SimpleCredentials)appContext.authorizationProvider().getCredentials();
// IsServerConfig cfg = fetchIsConfig();
// IsServerConfig newConfig = new IsServerConfig(
@ -83,7 +84,8 @@ public class KkClientFactory {
public IsServerConfig fetchIsConfig() throws NotFoundException, ServerException {
IsServerConfig cfg = InfrastrctureServiceClient.serviceConfigFromIS(RUNTIME_RESOURCE_NAME, CATEGORY, END_POINT_NAME, IS_ROOT_SERVICE);
IsServerConfig cfg = InfrastrctureServiceClient.serviceConfigFromIS(RUNTIME_RESOURCE_NAME, CATEGORY,
END_POINT_NAME, IS_ROOT_SERVICE);
return cfg;
}

View File

@ -32,12 +32,8 @@ import jakarta.ws.rs.core.Response;
@Path("clients")
public class ClientsAPI {
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(ClientsAPI.class);
@GET
@Path("/{name}")
@Produces({ "application/json;charset=UTF-8", "application/vnd.api+json" })
@ -74,21 +70,18 @@ public class ClientsAPI {
}
}
public class ClientFromTemplateParams {
String client_name;
String client_id;
String context;
}
@POST
@Path("/fromTemplate/{name}")
@Produces({ "application/json;charset=UTF-8", "application/vnd.api+json" })
public Response createClientFromTemplate(
@PathParam("name") String template_name,
ClientFromTemplateParams params
) {
ClientFromTemplateParams params) {
ResponseBeanMap responseBean = new ResponseBeanMap();
try {
@ -125,7 +118,6 @@ public class ClientsAPI {
}
@POST
@Produces({ "application/json;charset=UTF-8", "application/vnd.api+json" })
public Response createClientFromTemplate(ClientRepresentation client) {
@ -154,7 +146,6 @@ public class ClientsAPI {
}
@POST
@Path("/")
@Produces({ "application/json;charset=UTF-8", "application/vnd.api+json" })

View File

@ -1,6 +1,5 @@
package org.gcube.service.idm.rest;
import java.util.ArrayList;
import java.util.List;
import org.gcube.service.idm.IdMManager;

View File

@ -1,6 +1,5 @@
package org.gcube.service.idm.rest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

View File

@ -1,7 +1,9 @@
/**
* <h1>Identity Manager (IDM) Service</h1>
*
* <p>Welcome to Identity Manager Service (aka IDM) API documentation.</p>
* <p>
* Welcome to Identity Manager Service (aka IDM) API documentation.
* </p>
*
* <p>
* To get a complete overview of gCat service take a look at

View File

@ -1,8 +1,6 @@
package org.gcube.service.rest;
public class ErrorMessages
{
public class ErrorMessages {
public static final String ERROR_IN_API_RESULT = "The error is reported into the 'message' field of the returned object";
public static final String INVALID_ATTRIBUTE = "Such an attribute doesn't exist";
@ -10,23 +8,30 @@ public class ErrorMessages
public static final String USER_NOT_AUTHORIZED_PRIVATE = "User is not authorized to access private data";
public static final String CANNOT_RETRIEVE_PROFILE = "Unable to retrieve user profile";
//
// protected static final String CANNOT_RETRIEVE_SERVICE_ENDPOINT_INFORMATION = "Unable to retrieve such service endpoint information";
// protected static final String CANNOT_RETRIEVE_SERVICE_ENDPOINT_INFORMATION =
// "Unable to retrieve such service endpoint information";
// private static final String NO_RUNTIME_RESOURCE_TEMPLATE_NAME_CATEGORY = "There is no Runtime Resource having name %s and Category %s in this scope";
// private static final String NO_RUNTIME_RESOURCE_TEMPLATE_NAME_CATEGORY =
// "There is no Runtime Resource having name %s and Category %s in this scope";
// public static final String MISSING_TOKEN = "Missing token.";
// public static final String MISSING_PARAMETERS = "Missing request parameters.";
// public static final String MISSING_PARAMETERS = "Missing request
// parameters.";
// public static final String INVALID_TOKEN = "Invalid token.";
// public static final String TOKEN_GENERATION_APP_FAILED = "Token generation failed.";
// public static final String NOT_APP_TOKEN = "Invalid token: not belonging to an application.";
// public static final String NOT_APP_ID = "Invalid application id: it doesn't belong to an application.";
// public static final String NO_APP_PROFILE_FOUND = "There is no application profile for this app id/scope.";
// public static final String BAD_REQUEST = "Please check the parameter you passed, it seems a bad request";
// public static final String POST_OUTSIDE_VRE = "A post cannot be written into a context that is not a VRE";
// public static final String DEPRECATED_METHOD = "This method is deprecated, must use version 2";
// public static final String TOKEN_GENERATION_APP_FAILED = "Token generation
// failed.";
// public static final String NOT_APP_TOKEN = "Invalid token: not belonging to
// an application.";
// public static final String NOT_APP_ID = "Invalid application id: it doesn't
// belong to an application.";
// public static final String NO_APP_PROFILE_FOUND = "There is no application
// profile for this app id/scope.";
// public static final String BAD_REQUEST = "Please check the parameter you
// passed, it seems a bad request";
// public static final String POST_OUTSIDE_VRE = "A post cannot be written into
// a context that is not a VRE";
// public static final String DEPRECATED_METHOD = "This method is deprecated,
// must use version 2";
}

View File

@ -22,7 +22,7 @@ public class ResponseBeanMap extends ResponseBean {
/**
* The result object of the request
*/
protected Map<String, Object>result = new HashMap<String, Object>();
protected Map<String, Object> result = new HashMap<String, Object>();
public ResponseBeanMap() {
super();
@ -64,7 +64,7 @@ public class ResponseBeanMap extends ResponseBean {
this.result = mapResults;
}
public void putResult(String key, Object res){
public void putResult(String key, Object res) {
this.result.put(key, res);
}