[jboss-cvs] jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/plugin/flash ...

Christian Bauer christian at hibernate.org
Wed Nov 14 05:55:24 EST 2007


  User: cbauer  
  Date: 07/11/14 05:55:24

  Modified:    examples/wiki/src/main/org/jboss/seam/wiki/plugin/flash  
                        FlashPreferences.java
  Added:       examples/wiki/src/main/org/jboss/seam/wiki/plugin/flash  
                        Flash.java
  Log:
  Fixed flash plugin
  
  Revision  Changes    Path
  1.3       +23 -0     jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/plugin/flash/FlashPreferences.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: FlashPreferences.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/plugin/flash/FlashPreferences.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- FlashPreferences.java	12 Jun 2007 12:30:04 -0000	1.2
  +++ FlashPreferences.java	14 Nov 2007 10:55:24 -0000	1.3
  @@ -3,18 +3,21 @@
   import org.jboss.seam.annotations.Name;
   import org.jboss.seam.annotations.Scope;
   import org.jboss.seam.annotations.Observer;
  +import org.jboss.seam.annotations.AutoCreate;
   import org.jboss.seam.ScopeType;
   import org.jboss.seam.wiki.preferences.Preference;
   import org.jboss.seam.wiki.preferences.PreferenceVisibility;
   import org.jboss.seam.wiki.preferences.PreferenceSupport;
   import org.hibernate.validator.Range;
   import org.hibernate.validator.NotNull;
  +import org.hibernate.validator.Length;
   
   import java.io.Serializable;
   
   @Name("flashPreferences")
   @Scope(ScopeType.CONVERSATION)
   @Preference(description = "Plugin: Flash", visibility = PreferenceVisibility.INSTANCE)
  + at AutoCreate
   public class FlashPreferences extends PreferenceSupport implements Serializable {
   
       public String getCurrentUserVariable() { return "currentUser"; }
  @@ -24,6 +27,7 @@
       public void refreshProperties() { super.refreshProperties(); }
   
       @Preference(description = "01. URL of flash movie", visibility = PreferenceVisibility.INSTANCE)
  +    @Length(min = 0, max = 1024)
       private String flashURL;
   
       @Preference(description = "02. Width of embedded flash object (pixel)", visibility = PreferenceVisibility.INSTANCE)
  @@ -36,4 +40,23 @@
       @NotNull
       private Long objectHeight;
   
  +    @Preference(description = "04. Comma-separated list of allowed domain names", visibility = PreferenceVisibility.SYSTEM)
  +    @Length(min = 3, max = 1024)
  +    private String allowedDomains;
  +
  +    public String getFlashURL() {
  +        return flashURL;
  +    }
  +
  +    public Long getObjectWidth() {
  +        return objectWidth;
  +    }
  +
  +    public Long getObjectHeight() {
  +        return objectHeight;
  +    }
  +
  +    public String getAllowedDomains() {
  +        return allowedDomains;
  +    }
   }
  
  
  
  1.1      date: 2007/11/14 10:55:24;  author: cbauer;  state: Exp;jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/plugin/flash/Flash.java
  
  Index: Flash.java
  ===================================================================
  package org.jboss.seam.wiki.plugin.flash;
  
  import org.jboss.seam.annotations.Name;
  import org.jboss.seam.annotations.Scope;
  import org.jboss.seam.annotations.In;
  import org.jboss.seam.annotations.Logger;
  import org.jboss.seam.ScopeType;
  import org.jboss.seam.log.Log;
  
  import java.io.Serializable;
  import java.util.Arrays;
  import java.net.URI;
  
  @Name("flash")
  @Scope(ScopeType.PAGE)
  public class Flash implements Serializable {
  
      @In
      FlashPreferences flashPreferences;
  
      @Logger
      Log log;
  
      public boolean isURLAllowed() {
          String allowedDomains = flashPreferences.getAllowedDomains();
          if (allowedDomains == null || allowedDomains.length() == 0) return false;
  
          String desiredDomainName;
          try {
              URI uri = new URI(flashPreferences.getFlashURL());
              desiredDomainName = uri.getHost();
          } catch (Exception ex) {
              log.debug("Exception parsing flash movie URL into URI: " + ex.getMessage());
              return false;
          }
          allowedDomains = allowedDomains.replaceAll("\\s", ""); // Remove spaces
          String[] allowedDomainNames = allowedDomains.split(",");
          if (desiredDomainName == null || desiredDomainName.length() == 0) return true;
  
          Arrays.sort(allowedDomainNames);
          return Arrays.binarySearch(allowedDomainNames, desiredDomainName) >= 0;
      }
  }
  
  
  



More information about the jboss-cvs-commits mailing list