computacao-ufcg / alumni-backend

GNU General Public License v3.0
4 stars 1 forks source link

Public Key Route #6

Closed natalia-sa closed 4 years ago

natalia-sa commented 4 years ago

objective of this pull request

create /publicKey route

Creation a new get route "/publickey", that returns the public key generated

issue: #3

How to test:

Run project locally. Use ApiClient to send a request to http://localhost:8080/publicKey

natalia-sa commented 4 years ago

Certo, vou corrigir. Obrigada!

Em seg, 5 de out de 2020 09:32, fubica notifications@github.com escreveu:

@fubica requested changes on this pull request.

In pom.xml https://github.com/computacao-ufcg/alumni-backend/pull/6#discussion_r499557502 :

@@ -85,6 +97,12 @@

         <artifactId>json</artifactId>

         <version>20200518</version>

     </dependency>

+

  • org.slf4j

A gente usa org.apache.log4j.Logger. Essa dependência deve ser removida e a classe que estiver usando org.slf4j.Logger deve passar a usar org.apache.log4j.Logger.

In src/main/java/br/edu/ufcg/computacao/alumni/constants/ConfigurationPropertyKeys.java https://github.com/computacao-ufcg/alumni-backend/pull/6#discussion_r499560029 :

@@ -3,4 +3,5 @@

public class ConfigurationPropertyKeys {

 public static final String LINKEDIN_URL_KEY = "linkedin_url";

 public static final String ALUMNI_INPUT_KEY = "alumni_input_key";

Por favor, corrija o nome dessa propriedade que eu coloquei errado. Deve ser alumni_input e não alumni_input_key.

In src/main/java/br/edu/ufcg/computacao/alumni/constants/ConfigurationPropertyKeys.java https://github.com/computacao-ufcg/alumni-backend/pull/6#discussion_r499561143 :

@@ -3,4 +3,5 @@

public class ConfigurationPropertyKeys {

 public static final String LINKEDIN_URL_KEY = "linkedin_url";

 public static final String ALUMNI_INPUT_KEY = "alumni_input_key";
  • public static final String ALUMNI_PUBLIC_KEY = "src/main/resources/private/rsa.public";

Essa constante deve conter o nome da propriedade que deve aparecer no arquivo de configuração e não o caminho para o arquivo onde a chave está armazenada.

Deve ser: public static final String ALUMNI_PUBLICKEY_KEY = "alumni_publickey";

No arquivo alumni.conf deve ter uma linha: alumni_publickey="src/main/resources/private/rsa.public" (ou outro caminho que o usuário escolha).

In src/main/java/br/edu/ufcg/computacao/alumni/core/ApplicationFacade.java https://github.com/computacao-ufcg/alumni-backend/pull/6#discussion_r499561812 :

@@ -46,4 +51,17 @@ public static ApplicationFacade getInstance() {

 public List<LinkedinNameProfilePair> getLinkedinNameProfilePairs(String token) throws Exception {

     return LinkedinDataHolder.getInstance().getLinkedinNameProfilePairs(token);

 }

+

  • public String getPublicKey() throws Exception {

  • ServiceAsymmetricKeysHolder service = ServiceAsymmetricKeysHolder.getInstance();

  • service.setPublicKeyFilePath(ConfigurationPropertyKeys.ALUMNI_PUBLIC_KEY);

Primeiro tem que recuperar o caminho do arquivo que é o valor da propriedade ConfigurationPropertyKeys.ALUMNI_PUBLICKEY_KEY (ver comentário anterior).

In src/main/java/br/edu/ufcg/computacao/alumni/api/http/request/PublicKey.java https://github.com/computacao-ufcg/alumni-backend/pull/6#discussion_r499562776 :

+package br.edu.ufcg.computacao.alumni.api.http.request;

+

+import br.edu.ufcg.computacao.alumni.constants.Messages;

+import br.edu.ufcg.computacao.alumni.constants.SystemConstants;

+import br.edu.ufcg.computacao.alumni.core.ApplicationFacade;

+import br.edu.ufcg.computacao.alumni.api.http.response.PublicKeyResponse;

+import org.apache.log4j.Logger;

+import org.springframework.http.HttpStatus;

+import org.springframework.http.ResponseEntity;

+import org.springframework.web.bind.annotation.*;

+

+@CrossOrigin

+@RestController

+@RequestMapping(value = PublicKey.PUBLIC_KEY_ENDPOINT)

+//@Api(description = ApiDocumentation.PublicKey.API)

+

Se possível, adicione a documentação da API. Basta criar os campos necessários na classe: br.edu.ufcg.computacao.alumni.constants.ApiDocumentation.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/computacao-ufcg/alumni-backend/pull/6#pullrequestreview-501999546, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANJJ3FSUEGBH6IFOEJEUBJDSJG4HPANCNFSM4SA2Q2RA .