brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grk...@apache.org
Subject [07/13] git commit: Remove deprecation and type coercion adapter from ProxySslConfig
Date Sun, 05 Oct 2014 22:44:31 GMT
Remove deprecation and type coercion adapter from ProxySslConfig


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/0c2bd483
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/0c2bd483
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/0c2bd483

Branch: refs/heads/master
Commit: 0c2bd483132e29cee5c47d0acce05eea50970078
Parents: 1d91627
Author: Andrew Kennedy <grkvlt@apache.org>
Authored: Thu Sep 25 21:14:02 2014 +0100
Committer: Andrew Kennedy <grkvlt@apache.org>
Committed: Sun Oct 5 19:45:54 2014 +0100

----------------------------------------------------------------------
 .../brooklyn/entity/proxy/ProxySslConfig.java   | 192 ++++++-------------
 1 file changed, 62 insertions(+), 130 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/0c2bd483/software/webapp/src/main/java/brooklyn/entity/proxy/ProxySslConfig.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/main/java/brooklyn/entity/proxy/ProxySslConfig.java b/software/webapp/src/main/java/brooklyn/entity/proxy/ProxySslConfig.java
index a61d401..219bf27 100644
--- a/software/webapp/src/main/java/brooklyn/entity/proxy/ProxySslConfig.java
+++ b/software/webapp/src/main/java/brooklyn/entity/proxy/ProxySslConfig.java
@@ -19,64 +19,17 @@
 package brooklyn.entity.proxy;
 
 import java.io.Serializable;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicBoolean;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import brooklyn.util.collections.MutableMap;
-import brooklyn.util.flags.TypeCoercions;
-
-import com.google.common.base.Function;
-import com.google.common.base.Joiner;
 import com.google.common.base.Objects;
 
 public class ProxySslConfig implements Serializable {
 
     private static final long serialVersionUID = -2692754611458939617L;
-    private static final Logger LOG = LoggerFactory.getLogger(ProxySslConfig.class);
-    private static final AtomicBoolean initialized = new AtomicBoolean(false);
-
-    /** Setup type coercion. */
-    @SuppressWarnings("rawtypes")
-    public static void init() {
-        if (initialized.getAndSet(true)) return;
-
-        TypeCoercions.registerAdapter(Map.class, ProxySslConfig.class, new Function<Map,
ProxySslConfig>() {
-            @Override
-            public ProxySslConfig apply(final Map input) {
-                Map map = MutableMap.copyOf(input);
-                ProxySslConfig.Builder sslConfig = ProxySslConfig.builder()
-                        .certificateSourceUrl((String) map.remove("certificateSourceUrl"))
-                        .keySourceUrl((String) map.remove("keySourceUrl"))
-                        .certificateDestination((String) map.remove("certificateDestination"))
-                        .keyDestination((String) map.remove("keyDestination"));
-                Object targetIsSsl = map.remove("targetIsSsl");
-                if (targetIsSsl != null) {
-                    sslConfig.targetIsSsl(TypeCoercions.coerce(targetIsSsl, Boolean.TYPE));
-                }
-                Object reuseSessions = map.remove("reuseSessions");
-                if (reuseSessions != null) {
-                    sslConfig.reuseSessions(TypeCoercions.coerce(reuseSessions, Boolean.TYPE));
-                }
-                if (!map.isEmpty()) {
-                    LOG.info("Extra unused keys found in ProxySslConfig config: [{}]",
-                            Joiner.on(",").withKeyValueSeparator("=").join(map));
-                }
-                return sslConfig.build();
-            }
-        });
-    }
-
-    static {
-        init();
-    }
 
     public static Builder builder() {
         return new Builder();
     }
-    
+
     public static class Builder {
         protected String certificateSourceUrl;
         protected String keySourceUrl;
@@ -84,7 +37,7 @@ public class ProxySslConfig implements Serializable {
         protected String keyDestination;
         protected boolean targetIsSsl = false;
         protected boolean reuseSessions = false;
-        
+
         public Builder certificateSourceUrl(String val) {
             certificateSourceUrl = val; return this;
         }
@@ -108,63 +61,16 @@ public class ProxySslConfig implements Serializable {
             return result;
         }
     }
-    
-    /** 
-     * url's for the SSL certificates required at the server
-     * <p>
-     * nginx settings:
-     *     ssl                  on;
-     *     ssl_certificate      www.example.com.crt;
-     *     ssl_certificate_key  www.example.com.key;
-     *  <p>
-     *  okay (in nginx) for key to be null if certificate contains both as per setup at
-     *  http://nginx.org/en/docs/http/configuring_https_servers.html
-     *  <p>
-     *  proxy object can be set on nginx instance to apply site-wide,
-     *  and to put multiple servers in the certificate file
-     *  <p>
-     *  the brooklyn entity will install the certificate/key(s) on the server.
-     *  (however it will not currently merge multiple certificates.
-     *  if conflicting certificates are attempted to be installed nginx will complain.) 
-     */
-    String certificateSourceUrl;
 
-    String keySourceUrl;
+    private String certificateSourceUrl;
+    private String keySourceUrl;
+    private String certificateDestination;
+    private String keyDestination;
+    private boolean targetIsSsl = false;
+    private boolean reuseSessions = false;
 
-    /**
-     * Sets the ssl_certificate path to be used within the generated LoadBalancer configuration.
If set to null,
-     * Brooklyn will use an auto generated path.
-     *
-     * If certificateSourceUrl, then Brooklyn will copy the certificate the certificateDestination.
-     *
-     * Setting this field is useful if there is a certificate on the nginx machine you want
to make use of.
-     */
-    String certificateDestination;
+    public ProxySslConfig() { }
 
-    /**
-     * Sets the ssl_certificate_key path to be used within the generated LoadBalancer configuration.
If set to null,
-     * Brooklyn will use an auto generated path.
-     *
-     * If keySourceUrl, then Brooklyn will copy the certificate the keyDestination.
-     *
-     * Setting this field is useful if there is a certificate_key on the nginx machine you
want to make use of.
-     */
-    String keyDestination;
-
-    /** whether the downstream server (if mapping) also expects https; default false */
-    boolean targetIsSsl = false;
-
-    /** whether to reuse SSL validation in the server (performance).
-     * corresponds to nginx setting: proxy_ssl_session_reuse on|off */
-    boolean reuseSessions = false;
-
-    /**
-     * @deprecated since 0.7.0; use {@link ProxySslConfig#builder()}
-     */
-    @Deprecated
-    public ProxySslConfig() {
-    }
-    
     protected ProxySslConfig(Builder builder) {
         certificateSourceUrl = builder.certificateSourceUrl;
         keySourceUrl = builder.keySourceUrl;
@@ -173,81 +79,107 @@ public class ProxySslConfig implements Serializable {
         targetIsSsl = builder.targetIsSsl;
         reuseSessions = builder.reuseSessions;
     }
-    
+
+    /**
+     * URL for the SSL certificates required at the server.
+     * <p>
+     * Corresponding nginx settings:
+     * <pre>
+     *     ssl                  on;
+     *     ssl_certificate      www.example.com.crt;
+     *     ssl_certificate_key  www.example.com.key;
+     * </pre>
+     * Okay (in nginx) for key to be null if certificate contains both as per setup at
+     * http://nginx.org/en/docs/http/configuring_https_servers.html
+     * <p>
+     * Proxy object can be set on nginx instance to apply site-wide,
+     * and to put multiple servers in the certificate file
+     * <p>
+     * The brooklyn entity will install the certificate/key(s) on the server.
+     * (however it will not currently merge multiple certificates.
+     * if conflicting certificates are attempted to be installed nginx will complain.)
+     */
     public String getCertificateSourceUrl() {
         return certificateSourceUrl;
     }
 
-    /**
-     * @deprecated since 0.7.0; use {@link ProxySslConfig#builder()}
-     */
-    @Deprecated
     public void setCertificateSourceUrl(String certificateSourceUrl) {
         this.certificateSourceUrl = certificateSourceUrl;
     }
 
+    /** @see #getCertificateSourceUrl()} */
     public String getKeySourceUrl() {
         return keySourceUrl;
     }
 
-    /**
-     * @deprecated since 0.7.0; use {@link ProxySslConfig#builder()}
-     */
-    @Deprecated
     public void setKeySourceUrl(String keySourceUrl) {
         this.keySourceUrl = keySourceUrl;
     }
 
+    /**
+     * Sets the {@code ssl_certificate_path} to be used within the generated
+     * {@link LoadBalancer} configuration.
+     * <p>
+     * If set to null, Brooklyn will use an auto generated path.
+     * <p>
+     * If {@link #getCertificateSourceUrl() certificateSourceUrl} is set     *
+     * then Brooklyn will copy the certificate the destination.
+     * <p>
+     * Setting this field is useful if there is a {@code certificate} on the
+     * nginx machine you want to make use of.
+     */
     public String getCertificateDestination() {
         return certificateDestination;
     }
 
-    /**
-     * @deprecated since 0.7.0; use {@link ProxySslConfig#builder()}
-     */
-    @Deprecated
     public void setCertificateDestination(String certificateDestination) {
         this.certificateDestination = certificateDestination;
     }
 
+    /**
+     * Sets the {@code ssl_certificate_key} path to be used within the generated
+     * {@link LoadBalancer} configuration.
+     * <p>
+     * If set to null, Brooklyn will use an auto generated path.
+     * <p>
+     * If {@link #getKeySourceUrl() keySourceUrl} is set then Brooklyn will copy the
+     * certificate to the destination.
+     * <p>
+     * Setting this field is useful if there is a {@code certificate_key} on the
+     * nginx machine you want to make use of.
+     */
     public String getKeyDestination() {
         return keyDestination;
     }
 
-    /**
-     * @deprecated since 0.7.0; use {@link ProxySslConfig#builder()}
-     */
-    @Deprecated
     public void setKeyDestination(String keyDestination) {
         this.keyDestination = keyDestination;
     }
 
+    /**
+     * Whether the downstream server (if mapping) also expects https; default false.
+     */
     public boolean getTargetIsSsl() {
         return targetIsSsl;
     }
 
-    /**
-     * @deprecated since 0.7.0; use {@link ProxySslConfig#builder()}
-     */
-    @Deprecated
     public void setTargetIsSsl(boolean targetIsSsl) {
         this.targetIsSsl = targetIsSsl;
     }
 
+    /**
+     * Whether to reuse SSL validation in the server (performance).
+     * <p>
+     * Corresponds to nginx setting {@code proxy_ssl_session_reuse on|off}.
+     */
     public boolean getReuseSessions() {
         return reuseSessions;
     }
 
-    /**
-     * @deprecated since 0.7.0; use {@link ProxySslConfig#builder()}
-     */
-    @Deprecated
     public void setReuseSessions(boolean reuseSessions) {
         this.reuseSessions = reuseSessions;
     }
 
-    // autogenerated hash code and equals; nothing special required
-
     @Override
     public int hashCode() {
         return Objects.hashCode(certificateSourceUrl, keySourceUrl, certificateDestination,
keyDestination, reuseSessions, targetIsSsl);


Mime
View raw message