From 017977b497abf5faf54f2c4be2b582133679a8aa Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 27 Sep 2018 23:14:55 +0300 Subject: code cleanup --- .../src/main/java/com/juick/ApiServer.java | 11 +---- .../java/com/juick/server/KeystoreManager.java | 2 +- .../src/main/java/com/juick/server/XMPPServer.java | 7 +--- .../juick/server/api/apple/AppSiteAssociation.java | 49 ++++++++++++++++++++++ .../server/configuration/WwwAppConfiguration.java | 3 +- .../server/www/controllers/AppSiteAssociation.java | 49 ---------------------- 6 files changed, 54 insertions(+), 67 deletions(-) create mode 100644 juick-server/src/main/java/com/juick/server/api/apple/AppSiteAssociation.java delete mode 100644 juick-server/src/main/java/com/juick/server/www/controllers/AppSiteAssociation.java (limited to 'juick-server/src/main/java/com') diff --git a/juick-server/src/main/java/com/juick/ApiServer.java b/juick-server/src/main/java/com/juick/ApiServer.java index cdd8bb20..fb2d9701 100644 --- a/juick-server/src/main/java/com/juick/ApiServer.java +++ b/juick-server/src/main/java/com/juick/ApiServer.java @@ -4,21 +4,12 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.mail.MailSenderAutoConfiguration; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.context.annotation.ComponentScan; @SpringBootApplication @EnableAutoConfiguration(exclude = { MailSenderAutoConfiguration.class }) @ComponentScan(basePackages = {"com.juick.server", "com.juick.service"}) -public class ApiServer extends SpringBootServletInitializer { - - @Override - protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { - setRegisterErrorPageFilter(false); - return builder.sources(ApiServer.class); - } - +public class ApiServer { public static void main(String[] args) { SpringApplication.run(ApiServer.class, args); } diff --git a/juick-server/src/main/java/com/juick/server/KeystoreManager.java b/juick-server/src/main/java/com/juick/server/KeystoreManager.java index 44b0b90e..8bf93a7b 100644 --- a/juick-server/src/main/java/com/juick/server/KeystoreManager.java +++ b/juick-server/src/main/java/com/juick/server/KeystoreManager.java @@ -28,7 +28,7 @@ public class KeystoreManager { private KeyManagerFactory kmf; @PostConstruct - public void init() throws GeneralSecurityException, IOException { + public void init() { try (InputStream ksIs = new FileInputStream(keystore)) { ks = KeyStore.getInstance("PKCS12"); ks.load(ksIs, keystorePassword.toCharArray()); diff --git a/juick-server/src/main/java/com/juick/server/XMPPServer.java b/juick-server/src/main/java/com/juick/server/XMPPServer.java index f9d0169e..86ab6a78 100644 --- a/juick-server/src/main/java/com/juick/server/XMPPServer.java +++ b/juick-server/src/main/java/com/juick/server/XMPPServer.java @@ -24,7 +24,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; import org.xmlpull.v1.XmlPullParserException; import rocks.xmpp.addr.Jid; import rocks.xmpp.core.stanza.model.Stanza; @@ -33,20 +32,18 @@ import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import javax.inject.Inject; import javax.net.ssl.*; -import java.security.InvalidAlgorithmParameterException; -import java.security.cert.*; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; -import java.io.FileInputStream; import java.io.IOException; -import java.io.InputStream; import java.io.StringReader; import java.net.ServerSocket; import java.net.Socket; import java.net.SocketException; +import java.security.InvalidAlgorithmParameterException; import java.security.KeyStore; import java.security.KeyStoreException; import java.security.SecureRandom; +import java.security.cert.*; import java.time.Duration; import java.time.Instant; import java.util.*; diff --git a/juick-server/src/main/java/com/juick/server/api/apple/AppSiteAssociation.java b/juick-server/src/main/java/com/juick/server/api/apple/AppSiteAssociation.java new file mode 100644 index 00000000..81ab6960 --- /dev/null +++ b/juick-server/src/main/java/com/juick/server/api/apple/AppSiteAssociation.java @@ -0,0 +1,49 @@ +package com.juick.server.api.apple; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Collections; +import java.util.List; + +@RestController +public class AppSiteAssociation { + @Value("${ios_app_id:}") + private String appId; + + @GetMapping("/.well-known/apple-app-site-association") + @ResponseBody + public SiteAssociations appSiteAssociations() { + WebCredentials webCredentials = new WebCredentials(); + webCredentials.setApps(Collections.singletonList(appId)); + SiteAssociations siteAssociations = new SiteAssociations(); + siteAssociations.setWebcredentials(webCredentials); + return siteAssociations; + } + + private class SiteAssociations { + private WebCredentials webcredentials; + + public WebCredentials getWebcredentials() { + return webcredentials; + } + + public void setWebcredentials(WebCredentials webcredentials) { + this.webcredentials = webcredentials; + } + } + + private class WebCredentials { + private List apps; + + public List getApps() { + return apps; + } + + public void setApps(List apps) { + this.apps = apps; + } + } +} diff --git a/juick-server/src/main/java/com/juick/server/configuration/WwwAppConfiguration.java b/juick-server/src/main/java/com/juick/server/configuration/WwwAppConfiguration.java index 9f68032d..e4612a84 100644 --- a/juick-server/src/main/java/com/juick/server/configuration/WwwAppConfiguration.java +++ b/juick-server/src/main/java/com/juick/server/configuration/WwwAppConfiguration.java @@ -17,9 +17,9 @@ package com.juick.server.configuration; +import com.juick.server.www.HelpService; import com.juick.service.TagService; import com.juick.service.UserService; -import com.juick.server.www.HelpService; import com.mitchellbosecke.pebble.PebbleEngine; import com.mitchellbosecke.pebble.extension.FormatterExtension; import com.mitchellbosecke.pebble.loader.ClasspathLoader; @@ -35,7 +35,6 @@ import org.springframework.cache.annotation.EnableCaching; import org.springframework.cache.caffeine.CaffeineCacheManager; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Import; import org.springframework.web.servlet.ViewResolver; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; diff --git a/juick-server/src/main/java/com/juick/server/www/controllers/AppSiteAssociation.java b/juick-server/src/main/java/com/juick/server/www/controllers/AppSiteAssociation.java deleted file mode 100644 index 7ba7405a..00000000 --- a/juick-server/src/main/java/com/juick/server/www/controllers/AppSiteAssociation.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.juick.server.www.controllers; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.RestController; - -import java.util.Collections; -import java.util.List; - -@RestController -public class AppSiteAssociation { - @Value("${ios_app_id:}") - private String appId; - - @GetMapping("/.well-known/apple-app-site-association") - @ResponseBody - public SiteAssociations appSiteAssociations() { - WebCredentials webCredentials = new WebCredentials(); - webCredentials.setApps(Collections.singletonList(appId)); - SiteAssociations siteAssociations = new SiteAssociations(); - siteAssociations.setWebcredentials(webCredentials); - return siteAssociations; - } - - private class SiteAssociations { - private WebCredentials webcredentials; - - public WebCredentials getWebcredentials() { - return webcredentials; - } - - public void setWebcredentials(WebCredentials webcredentials) { - this.webcredentials = webcredentials; - } - } - - private class WebCredentials { - private List apps; - - public List getApps() { - return apps; - } - - public void setApps(List apps) { - this.apps = apps; - } - } -} -- cgit v1.2.3