| securis/src/main/java/net/curisit/securis/SeCurisServer.java | patch | view | blame | history | |
| securis/src/main/java/net/curisit/securis/beans/MetadataType.java | patch | view | blame | history | |
| securis/src/main/java/net/curisit/securis/db/Application.java | patch | view | blame | history | |
| securis/src/main/java/net/curisit/securis/db/ApplicationMetadata.java | patch | view | blame | history | |
| securis/src/main/java/net/curisit/securis/db/LicenseType.java | patch | view | blame | history | |
| securis/src/main/java/net/curisit/securis/db/LicenseTypeMetadata.java | patch | view | blame | history | |
| securis/src/main/java/net/curisit/securis/db/PackMetadata.java | patch | view | blame | history |
securis/src/main/java/net/curisit/securis/SeCurisServer.java
.. .. @@ -118,7 +118,7 @@ 118 118 Properties props = new Properties(); 119 119 props.put("javax.persistence.jdbc.password", securisModule.getPassword()); 120 120 props.put("javax.persistence.jdbc.url", securisModule.getUrl(securisModule.getAppDir())); 121 - LOG.info("BD Url: {} {}", securisModule.getUrl(securisModule.getAppDir()), securisModule.getPassword());121 + //LOG.info("BD Url: {} {}", securisModule.getUrl(securisModule.getAppDir()), securisModule.getPassword());122 122 jpaPersistModule.properties(props); 123 123 124 124 injector = Guice.createInjector(securisModule, new RequestsModule(), jpaPersistModule); .. .. @@ -150,7 +150,13 @@ 150 150 QueuedThreadPool threadPool = new QueuedThreadPool(); 151 151 threadPool.setMaxThreads(50); 152 152 153 - server = new Server(Config.getInt(Config.KEYS.SERVER_PORT, 9080));153 + server = new Server();154 +155 + ServerConnector httpConnector = new ServerConnector(server);156 + httpConnector.setPort(Config.getInt(Config.KEYS.SERVER_PORT, 9080));157 + httpConnector.setHost(Config.get(Config.KEYS.SERVER_HOSTNAME, "0.0.0.0"));158 + server.addConnector(httpConnector);159 +154 160 ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS); 155 161 context.setContextPath("/"); 156 162 context.addEventListener(injector.getInstance(GuiceResteasyBootstrapServletContextListener.class)); .. .. @@ -176,7 +182,6 @@ 176 182 177 183 ErrorPageErrorHandler errorHandler = new ErrorPageErrorHandler(); 178 184 context.setErrorHandler(errorHandler); 179 - LOG.info("Error Handlers: " + context.getErrorHandler());180 185 ContextHandlerCollection contexts = new ContextHandlerCollection(); 181 186 182 187 contexts.setHandlers(new Handler[] { .. .. @@ -204,7 +209,6 @@ 204 209 // sslContextFactory.setTrustStorePassword("curist3c"); 205 210 sslContextFactory.checkKeyStore(); 206 211 sslContextFactory.setNeedClientAuth(false); 207 - LOG.info("Protocol: {}", sslContextFactory.getProtocol());208 212 209 213 ServerConnector sslConnector = new ServerConnector(server, new SslConnectionFactory(sslContextFactory,HttpVersion.HTTP_1_1.asString()), new HttpConnectionFactory(https_config)); 210 214 sslConnector.setPort(Config.getInt(Config.KEYS.SERVER_SSL_PORT, 9443)); .. .. @@ -217,6 +221,7 @@ 217 221 try { 218 222 server.start(); 219 223 savePID(); 224 + CONSOLE.info("Server running in: {}", String.format("http://%s:%d", httpConnector.getHost(), httpConnector.getPort()));220 225 server.join(); 221 226 } catch (Exception e) { 222 227 LOG.error("Error starting SeCurisServer", e); securis/src/main/java/net/curisit/securis/beans/MetadataType.java
.. .. @@ -0,0 +1,16 @@ 1 +package net.curisit.securis.beans;2 +3 +public enum MetadataType {4 +5 + NUMBER(1),6 + STRING(2),7 + BOOLEAN(3);8 +9 + private final int id;10 + MetadataType(int id) {11 + this.id = id;12 + }13 + public int getId() {14 + return id;15 + }16 +}securis/src/main/java/net/curisit/securis/db/Application.java
.. .. @@ -49,6 +49,12 @@ 49 49 @OneToMany(fetch = FetchType.LAZY, mappedBy = "application") 50 50 private Set<LicenseType> licenseTypes; 51 51 52 + @JsonIgnore53 + // We don't include the referenced entities to limit the size of each row at54 + // the listing55 + @OneToMany(fetch = FetchType.LAZY, mappedBy = "application")56 + private Set<ApplicationMetadata> metadata;57 +52 58 public int getId() { 53 59 return id; 54 60 } .. .. @@ -89,4 +95,12 @@ 89 95 this.licenseTypes = licenseTypes; 90 96 } 91 97 98 + public Set<ApplicationMetadata> getApplicationMetadata() {99 + return metadata;100 + }101 +102 + public void setApplicationMetadata(Set<ApplicationMetadata> metadata) {103 + this.metadata = metadata;104 + }105 +92 106 } securis/src/main/java/net/curisit/securis/db/ApplicationMetadata.java
.. .. @@ -0,0 +1,123 @@ 1 +package net.curisit.securis.db;2 +3 +import java.io.Serializable;4 +import java.util.Date;5 +import java.util.Set;6 +7 +import javax.persistence.Column;8 +import javax.persistence.Entity;9 +import javax.persistence.FetchType;10 +import javax.persistence.GeneratedValue;11 +import javax.persistence.Id;12 +import javax.persistence.JoinColumn;13 +import javax.persistence.ManyToOne;14 +import javax.persistence.NamedQueries;15 +import javax.persistence.NamedQuery;16 +import javax.persistence.OneToMany;17 +import javax.persistence.Table;18 +19 +import net.curisit.securis.beans.MetadataType;20 +21 +import org.codehaus.jackson.annotate.JsonAutoDetect;22 +import org.codehaus.jackson.annotate.JsonIgnore;23 +import org.codehaus.jackson.annotate.JsonProperty;24 +import org.codehaus.jackson.map.annotate.JsonSerialize;25 +26 +/**27 + * Entity implementation class for Entity: application_metadata28 + *29 + */30 +@JsonAutoDetect31 +@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)32 +@Entity33 +@Table(name = "application_metadata")34 +@NamedQueries({35 + @NamedQuery(name = "list-application-metadata", query = "SELECT a FROM ApplicationMetadata a where a.application.id = :applicationId")36 +})37 +public class ApplicationMetadata implements Serializable {38 +39 + private static final long serialVersionUID = 1L;40 +41 + @Id42 + @GeneratedValue43 + private int id;44 +45 + private String key;46 +47 + private String description;48 +49 + private MetadataType dataType;50 +51 + @JsonIgnore52 + @ManyToOne53 + @JoinColumn(name = "application_id")54 + private Application application;55 +56 + @Column(name = "creation_timestamp")57 + private Date creationTimestamp;58 +59 + public int getId() {60 + return id;61 + }62 +63 + public void setId(int id) {64 + this.id = id;65 + }66 +67 + public String getKey() {68 + return key;69 + }70 +71 + public void setKey(String key) {72 + this.key = key;73 + }74 +75 + public String getDescription() {76 + return description;77 + }78 +79 + public void setDescription(String description) {80 + this.description = description;81 + }82 +83 + public MetadataType getDataType() {84 + return dataType;85 + }86 +87 + public void setDataType(MetadataType dataType) {88 + this.dataType = dataType;89 + }90 +91 + public Application getApplication() {92 + return application;93 + }94 +95 + public void setApplication(Application application) {96 + this.application = application;97 + }98 +99 + public Date getCreationTimestamp() {100 + return creationTimestamp;101 + }102 +103 + public void setCreationTimestamp(Date creationTimestamp) {104 + this.creationTimestamp = creationTimestamp;105 + }106 +107 +108 + @JsonProperty("application_id")109 + public Integer getApplicationId() {110 + return application == null ? null : application.getId();111 + }112 +113 + @JsonProperty("application_id")114 + public void setApplicationId(Integer idApplication) {115 + if (idApplication == null) {116 + application = null;117 + } else {118 + application = new Application();119 + application.setId(idApplication);120 + }121 + }122 +123 +}securis/src/main/java/net/curisit/securis/db/LicenseType.java
.. .. @@ -2,15 +2,18 @@ 2 2 3 3 import java.io.Serializable; 4 4 import java.util.Date; 5 +import java.util.Set;5 6 6 7 import javax.persistence.Column; 7 8 import javax.persistence.Entity; 9 +import javax.persistence.FetchType;8 10 import javax.persistence.GeneratedValue; 9 11 import javax.persistence.Id; 10 12 import javax.persistence.JoinColumn; 11 13 import javax.persistence.ManyToOne; 12 14 import javax.persistence.NamedQueries; 13 15 import javax.persistence.NamedQuery; 16 +import javax.persistence.OneToMany;14 17 import javax.persistence.Table; 15 18 16 19 import org.apache.logging.log4j.LogManager; .. .. @@ -31,10 +34,12 @@ 31 34 @Entity 32 35 @Table(name = "license_type") 33 36 @NamedQueries({ 34 - @NamedQuery(name = "list-license_types", query = "SELECT lt FROM LicenseType lt")37 + @NamedQuery(name = "list-license_types", query = "SELECT lt FROM LicenseType lt"),38 + @NamedQuery(name = "list-application-license_types", query = "SELECT lt FROM LicenseType lt where lt.application.id = :appId")35 39 }) 36 40 public class LicenseType implements Serializable { 37 41 42 + @SuppressWarnings("unused")38 43 private static final Logger LOG = LogManager.getLogger(LicenseType.class); 39 44 private static final long serialVersionUID = 1L; 40 45 .. .. @@ -53,6 +58,20 @@ 53 58 @ManyToOne 54 59 @JoinColumn(name = "application_id") 55 60 private Application application; 61 +62 + @JsonIgnore63 + // We don't include the referenced entities to limit the size of each row at64 + // the listing65 + @OneToMany(fetch = FetchType.LAZY, mappedBy = "license_type")66 + private Set<LicenseTypeMetadata> metadata;67 +68 + public Set<LicenseTypeMetadata> getMetadata() {69 + return metadata;70 + }71 +72 + public void setMetadata(Set<LicenseTypeMetadata> metadata) {73 + this.metadata = metadata;74 + }56 75 57 76 public int getId() { 58 77 return id; .. .. @@ -91,21 +110,23 @@ 91 110 } 92 111 93 112 @JsonProperty("application_name") 94 - public String getParentOrgName() {113 + public String getApplicationName() {95 114 return application == null ? null : application.getName(); 96 115 } 97 116 98 117 @JsonProperty("application_id") 99 118 public Integer getApplicationId() { 100 - LOG.info("application " + application);101 119 return application == null ? null : application.getId(); 102 120 } 103 121 104 122 @JsonProperty("application_id") 105 123 public void setApplicationId(Integer appId) { 106 - LOG.info("setApplicationId(Integer appId) " + appId);107 - application = new Application();108 - application.setId(appId);124 + if (appId == null) {125 + application = null;126 + } else {127 + application = new Application();128 + application.setId(appId);129 + }109 130 } 110 131 111 132 public void setApplication(Application application) { securis/src/main/java/net/curisit/securis/db/LicenseTypeMetadata.java
.. .. @@ -0,0 +1,116 @@ 1 +package net.curisit.securis.db;2 +3 +import java.io.Serializable;4 +import java.util.Date;5 +6 +import javax.persistence.Column;7 +import javax.persistence.Entity;8 +import javax.persistence.GeneratedValue;9 +import javax.persistence.Id;10 +import javax.persistence.JoinColumn;11 +import javax.persistence.ManyToOne;12 +import javax.persistence.NamedQueries;13 +import javax.persistence.NamedQuery;14 +import javax.persistence.Table;15 +16 +import net.curisit.securis.beans.MetadataType;17 +18 +import org.codehaus.jackson.annotate.JsonAutoDetect;19 +import org.codehaus.jackson.annotate.JsonIgnore;20 +import org.codehaus.jackson.annotate.JsonProperty;21 +import org.codehaus.jackson.map.annotate.JsonSerialize;22 +23 +/**24 + * Entity implementation class for Entity: licensetype_metadata25 + *26 + */27 +@JsonAutoDetect28 +@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)29 +@Entity30 +@Table(name = "licensetype_metadata")31 +@NamedQueries({32 + @NamedQuery(name = "list-licensetype-metadata", query = "SELECT a FROM LicenseTypeMetadata a where a.licenseType.id = :licenseTypeId")33 +})34 +public class LicenseTypeMetadata implements Serializable {35 +36 + private static final long serialVersionUID = 1L;37 +38 + @Id39 + @GeneratedValue40 + private int id;41 +42 + private String value;43 +44 + @JsonIgnore45 + @ManyToOne46 + @JoinColumn(name = "metadata_id")47 + private ApplicationMetadata metadata;48 +49 + @JsonIgnore50 + @ManyToOne51 + @JoinColumn(name = "licensetype_id")52 + private LicenseType licenseType;53 +54 + public int getId() {55 + return id;56 + }57 +58 + public void setId(int id) {59 + this.id = id;60 + }61 +62 + @JsonProperty("licensetype_id")63 + public Integer getLicenseTypeId() {64 + return licenseType == null ? null : licenseType.getId();65 + }66 +67 + @JsonProperty("licensetype_id")68 + public void setLicenseTypeId(Integer idLicenseType) {69 + if (idLicenseType == null) {70 + licenseType = null;71 + } else {72 + licenseType = new LicenseType();73 + licenseType.setId(idLicenseType);74 + }75 + }76 +77 + @JsonProperty("metadata_id")78 + public Integer getMetadataId() {79 + return metadata == null ? null : metadata.getId();80 + }81 +82 + @JsonProperty("metadata_id")83 + public void setMetadataId(Integer idMetadata) {84 + if (idMetadata == null) {85 + metadata = null;86 + } else {87 + metadata = new ApplicationMetadata();88 + metadata.setId(idMetadata);89 + }90 + }91 +92 + public ApplicationMetadata getMetadata() {93 + return metadata;94 + }95 +96 + public void setMetadata(ApplicationMetadata metadata) {97 + this.metadata = metadata;98 + }99 +100 + public LicenseType getLicenseType() {101 + return licenseType;102 + }103 +104 + public void setLicenseType(LicenseType licenseType) {105 + this.licenseType = licenseType;106 + }107 +108 + public String getValue() {109 + return value;110 + }111 +112 + public void setValue(String value) {113 + this.value = value;114 + }115 +116 +}securis/src/main/java/net/curisit/securis/db/PackMetadata.java
.. .. @@ -0,0 +1,114 @@ 1 +package net.curisit.securis.db;2 +3 +import java.io.Serializable;4 +import java.util.Date;5 +6 +import javax.persistence.Column;7 +import javax.persistence.Entity;8 +import javax.persistence.GeneratedValue;9 +import javax.persistence.Id;10 +import javax.persistence.JoinColumn;11 +import javax.persistence.ManyToOne;12 +import javax.persistence.NamedQueries;13 +import javax.persistence.NamedQuery;14 +import javax.persistence.Table;15 +16 +import org.codehaus.jackson.annotate.JsonAutoDetect;17 +import org.codehaus.jackson.annotate.JsonIgnore;18 +import org.codehaus.jackson.annotate.JsonProperty;19 +import org.codehaus.jackson.map.annotate.JsonSerialize;20 +21 +/**22 + * Entity implementation class for Entity: pack_metadata23 + *24 + */25 +@JsonAutoDetect26 +@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)27 +@Entity28 +@Table(name = "pack_metadata")29 +@NamedQueries({30 + @NamedQuery(name = "list-pack-metadata", query = "SELECT a FROM PackMetadata a where a.pack.id = :packId")31 +})32 +public class PackMetadata implements Serializable {33 +34 + private static final long serialVersionUID = 1L;35 +36 + @Id37 + @GeneratedValue38 + private int id;39 +40 + private String value;41 +42 + @JsonIgnore43 + @ManyToOne44 + @JoinColumn(name = "metadata_id")45 + private ApplicationMetadata metadata;46 +47 + @JsonIgnore48 + @ManyToOne49 + @JoinColumn(name = "pack_id")50 + private Pack pack;51 +52 + public int getId() {53 + return id;54 + }55 +56 + public void setId(int id) {57 + this.id = id;58 + }59 +60 + @JsonProperty("pack_id")61 + public Integer getPackId() {62 + return pack == null ? null : pack.getId();63 + }64 +65 + @JsonProperty("pack_id")66 + public void setLicenseTypeId(Integer idPack) {67 + if (idPack == null) {68 + pack = null;69 + } else {70 + pack = new Pack();71 + pack.setId(idPack);72 + }73 + }74 +75 + @JsonProperty("metadata_id")76 + public Integer getMetadataId() {77 + return metadata == null ? null : metadata.getId();78 + }79 +80 + @JsonProperty("metadata_id")81 + public void setMetadataId(Integer idMetadata) {82 + if (idMetadata == null) {83 + metadata = null;84 + } else {85 + metadata = new ApplicationMetadata();86 + metadata.setId(idMetadata);87 + }88 + }89 +90 + public ApplicationMetadata getMetadata() {91 + return metadata;92 + }93 +94 + public void setMetadata(ApplicationMetadata metadata) {95 + this.metadata = metadata;96 + }97 +98 + public Pack getPack() {99 + return pack;100 + }101 +102 + public void setPack(Pack pack) {103 + this.pack = pack;104 + }105 +106 + public String getValue() {107 + return value;108 + }109 +110 + public void setValue(String value) {111 + this.value = value;112 + }113 +114 +}