public void init(String name, Attributes atts) {

      logger.log(LogService.LOG_DEBUG, "Here is IconHandler:init()"); // $NON-NLS-1$
      super.init(name, atts);
      String icon_resource_val = atts.getValue(RESOURCE);
      if (icon_resource_val == null) {
        _isParsedDataValid = false;
        logger.log(
            LogService.LOG_ERROR,
            NLS.bind(
                MetaTypeMsg.MISSING_ATTRIBUTE,
                new Object[] {
                  RESOURCE,
                  name,
                  atts.getValue(ID),
                  _dp_url,
                  _dp_bundle.getBundleId(),
                  _dp_bundle.getSymbolicName()
                }));
        return;
      }

      String icon_size_val = atts.getValue(SIZE);
      if (icon_size_val == null) {
        // Not a problem, because SIZE is an optional attribute.
        icon_size_val = "0"; // $NON-NLS-1$
      } else if (icon_size_val.equalsIgnoreCase("")) { // $NON-NLS-1$
        icon_size_val = "0"; // $NON-NLS-1$
      }

      _icon = new Icon(icon_resource_val, Integer.parseInt(icon_size_val), _dp_bundle);
    }
Example #2
0
 public static int verifyMaliciousPassword(String login, String mail) {
   String mailAdresse = "";
   Ldap adminConnection = new Ldap();
   adminConnection.SetEnv(
       Play.configuration.getProperty("ldap.host"),
       Play.configuration.getProperty("ldap.admin.dn"),
       Play.configuration.getProperty("ldap.admin.password"));
   Attributes f = adminConnection.getUserInfo(adminConnection.getLdapEnv(), login);
   try {
     NamingEnumeration e = f.getAll();
     while (e.hasMore()) {
       javax.naming.directory.Attribute a = (javax.naming.directory.Attribute) e.next();
       String attributeName = a.getID();
       String attributeValue = "";
       Enumeration values = a.getAll();
       while (values.hasMoreElements()) {
         attributeValue = values.nextElement().toString();
       }
       if (attributeName.equals("mail")) {
         mailAdresse = attributeValue;
       }
     }
   } catch (javax.naming.NamingException e) {
     System.out.println(e.getMessage());
     return 0;
   } finally {
     if (mailAdresse.equals("")) {
       return Invitation.USER_NOTEXIST;
     } else if (mailAdresse.equals(mail)) {
       return Invitation.ADDRESSES_MATCHE;
     } else {
       return Invitation.ADDRESSES_NOTMATCHE;
     }
   }
 }
Example #3
0
  /**
   * Returs the type of the dataset 0-Modelling, 1-Clasiffication, 2-Clustering
   *
   * @return type of the dataset 0-Modelling, 1-Clasiffication, 2-Clustering
   */
  public int datasetType() {

    if (Attributes.getOutputNumAttributes() >= 1) {
      if (Attributes.hasNominalAttributes()) return (1);
      else return (0);
    } else return (2);
  }
  /**
   * after a user has successfully logged in we want to build an access object for use in the
   * scheduling system
   *
   * @param String username
   * @param String group a group name to check for username in (via memberUid string)
   * @return boolean yes or no in the group
   * @throws NamingException when the search fails by DN this will be thrown
   */
  private boolean userInGroup(String username, String group) throws NamingException {
    // assume they are not
    boolean inGroup = false;

    // Specify the attributes to match
    Attributes matchAttrs = new BasicAttributes(true); // ignore attribute name case
    // set the common name for the group using defined prefix ie 'cn' or 'ou'
    matchAttrs.put(
        new BasicAttribute(
            this.GROUPS_LOC.substring(0, this.GROUPS_LOC.indexOf("=")),
            group)); // named group for access rights

    // Search for objects that have those matching attributes in the specified group location
    NamingEnumeration answer = ctx.search(this.GROUPS_LOC + this.BASE_DN, matchAttrs);

    // search for that user id in the member list
    while (answer.hasMore()) {
      SearchResult sr = (SearchResult) answer.next();
      if ((sr.getAttributes().get("memberuid").toString()).indexOf(username) >= 0) {
        // this user is in the specified group
        inGroup = true;
      }
    }
    System.err.println(username + " in " + group + ": " + new Boolean(inGroup).toString());
    return inGroup;
  }
Example #5
0
  /** Creates the total selector's set for get all the possible rules */
  private Complejo hazSelectores(Dataset train) {

    Complejo almacenSelectores;
    int nClases = train.getnclases();
    almacenSelectores =
        new Complejo(nClases); // Aqui voy a almacenar los selectores (numVariable,operador,valor)
    Attribute[] atributos = null;
    int num_atributos, type;
    Vector nominalValues;
    atributos = Attributes.getAttributes();
    num_atributos = Attributes.getNumAttributes();
    Selector s;

    for (int i = 0; i < train.getnentradas(); i++) {
      type = atributos[i].getType();
      switch (type) {
        case 0: // NOMINAL
          nominalValues = atributos[i].getNominalValuesList();
          // System.out.print("{");
          for (int j = 0; j < nominalValues.size(); j++) {
            // System.out.print ((String)nominalValues.elementAt(j)+"  ");
            s = new Selector(i, 0, (String) nominalValues.elementAt(j), true); // [atr,op,valor]
            // incluimos tb los valores en double para facilitar algunas funciones
            s.setValor((double) j);
            almacenSelectores.addSelector(s);
            // s.print();
          }
          // System.out.println("}");
          break;
      }
      // System.out.println(num_atributos);
    }
    return almacenSelectores;
  }
    public void startElement(
        String uri, String localName, String qName, org.xml.sax.Attributes atts)
        throws SAXException {
      if (DICTIONARY_ELEMENT.equals(localName)) {

        mAttributes = new Attributes();

        for (int i = 0; i < atts.getLength(); i++) {
          mAttributes.setValue(atts.getLocalName(i), atts.getValue(i));
        }
        /* get the attribute here ... */
        if (mAttributes.getValue(ATTRIBUTE_CASE_SENSITIVE) != null) {
          mIsCaseSensitiveDictionary =
              Boolean.valueOf(mAttributes.getValue(ATTRIBUTE_CASE_SENSITIVE));
        }
        mAttributes = null;
      } else if (ENTRY_ELEMENT.equals(localName)) {

        mAttributes = new Attributes();

        for (int i = 0; i < atts.getLength(); i++) {
          mAttributes.setValue(atts.getLocalName(i), atts.getValue(i));
        }
      } else if (TOKEN_ELEMENT.equals(localName)) {
        mIsInsideTokenElement = true;
      }
    }
Example #7
0
 @Override
 public <E extends T, K> E findByKey(Class<E> type, K key) {
   Type<E> entityType = entityModel.typeOf(type);
   if (entityType.isCacheable() && entityCache != null) {
     E entity = entityCache.get(type, key);
     if (entity != null) {
       return entity;
     }
   }
   Set<Attribute<E, ?>> keys = entityType.getKeyAttributes();
   if (keys.isEmpty()) {
     throw new MissingKeyException();
   }
   Selection<? extends Result<E>> selection = select(type);
   if (keys.size() == 1) {
     QueryAttribute<E, Object> attribute = Attributes.query(keys.iterator().next());
     selection.where(attribute.equal(key));
   } else {
     if (key instanceof CompositeKey) {
       CompositeKey compositeKey = (CompositeKey) key;
       for (Attribute<E, ?> attribute : keys) {
         QueryAttribute<E, Object> keyAttribute = Attributes.query(attribute);
         Object value = compositeKey.get(keyAttribute);
         selection.where(keyAttribute.equal(value));
       }
     } else {
       throw new IllegalArgumentException("CompositeKey required");
     }
   }
   return selection.get().firstOrNull();
 }
Example #8
0
  public static String saxElementToDebugString(String uri, String qName, Attributes attributes) {
    // Open start tag
    final StringBuilder sb = new StringBuilder("<");
    sb.append(qName);

    final Set<String> declaredPrefixes = new HashSet<String>();
    mapPrefixIfNeeded(declaredPrefixes, uri, qName, sb);

    // Attributes if any
    for (int i = 0; i < attributes.getLength(); i++) {
      mapPrefixIfNeeded(declaredPrefixes, attributes.getURI(i), attributes.getQName(i), sb);

      sb.append(' ');
      sb.append(attributes.getQName(i));
      sb.append("=\"");
      sb.append(attributes.getValue(i));
      sb.append('\"');
    }

    // Close start tag
    sb.append('>');

    // Content
    sb.append("[...]");

    // Close element with end tag
    sb.append("</");
    sb.append(qName);
    sb.append('>');

    return sb.toString();
  }
  /* goodG2B() - use goodsource and badsink */
  public void goodG2B_sink(String data, HttpServletRequest request, HttpServletResponse response)
      throws Throwable {

    Hashtable<String, String> env = new Hashtable<String, String>();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, "ldap://localhost:389");
    DirContext ctx = new InitialDirContext(env);

    String search =
        "(cn=" + data + ")"; /* POTENTIAL FLAW: unsanitized data from untrusted source */

    NamingEnumeration<SearchResult> answer = ctx.search("", search, null);
    while (answer.hasMore()) {
      SearchResult sr = answer.next();
      Attributes a = sr.getAttributes();
      NamingEnumeration<?> attrs = a.getAll();
      while (attrs.hasMore()) {
        Attribute attr = (Attribute) attrs.next();
        NamingEnumeration<?> values = attr.getAll();
        while (values.hasMore()) {
          response.getWriter().println(" Value: " + values.next().toString());
        }
      }
    }
  }
  /** Registers an action to copy Swift standard library dylibs into app bundle. */
  private void registerSwiftStdlibActionsIfNecessary() {
    if (!objcProvider.is(USES_SWIFT)) {
      return;
    }

    ObjcConfiguration objcConfiguration = ObjcRuleClasses.objcConfiguration(ruleContext);

    CustomCommandLine.Builder commandLine =
        CustomCommandLine.builder()
            .addPath(intermediateArtifacts.swiftFrameworksFileZip().getExecPath())
            .add("--platform")
            .add(IosSdkCommands.swiftPlatform(objcConfiguration))
            .addExecPath("--scan-executable", intermediateArtifacts.combinedArchitectureBinary());

    ruleContext.registerAction(
        ObjcRuleClasses.spawnOnDarwinActionBuilder(ruleContext)
            .setMnemonic("SwiftStdlibCopy")
            .setExecutable(attributes.swiftStdlibToolWrapper())
            .setCommandLine(commandLine.build())
            .addOutput(intermediateArtifacts.swiftFrameworksFileZip())
            .addInput(intermediateArtifacts.combinedArchitectureBinary())
            // TODO(dmaclach): Adding realpath and xcrunwrapper should not be required once
            // https://github.com/google/bazel/issues/285 is fixed.
            .addInput(attributes.realpath())
            .addInput(CompilationSupport.xcrunwrapper(ruleContext).getExecutable())
            .build(ruleContext));
  }
  /**
   * Construtor de um objeto da classe User que já inicializa os valores dos atributos do objeto com
   * os valores corretos.
   *
   * @param attributesOfUser
   */
  public User(String[] attributesOfUser) {

    this.listOfAttributes = new String[Attributes.values().length];
    for (int i = 0; i < Attributes.values().length; i++) {
      this.listOfAttributes[i] = attributesOfUser[i];
    }
  }
  /** Registers an action to generate a runner script based on a template. */
  ReleaseBundlingSupport registerGenerateRunnerScriptAction(
      Artifact runnerScript, Artifact ipaInput) {
    ObjcConfiguration objcConfiguration = ObjcRuleClasses.objcConfiguration(ruleContext);
    String escapedSimDevice = ShellUtils.shellEscape(objcConfiguration.getIosSimulatorDevice());
    String escapedSdkVersion = ShellUtils.shellEscape(objcConfiguration.getIosSimulatorVersion());
    ImmutableList<Substitution> substitutions =
        ImmutableList.of(
            Substitution.of("%app_name%", ruleContext.getLabel().getName()),
            Substitution.of("%ipa_file%", ipaInput.getRootRelativePath().getPathString()),
            Substitution.of("%sim_device%", escapedSimDevice),
            Substitution.of("%sdk_version%", escapedSdkVersion),
            Substitution.of("%iossim%", attributes.iossim().getRootRelativePath().getPathString()),
            Substitution.of(
                "%std_redirect_dylib_path%",
                attributes.stdRedirectDylib().getRootRelativePath().getPathString()));

    ruleContext.registerAction(
        new TemplateExpansionAction(
            ruleContext.getActionOwner(),
            attributes.runnerScriptTemplate(),
            runnerScript,
            substitutions,
            true));
    return this;
  }
Example #13
0
  private CustomCommandLine getPb2CommandLine() {
    CustomCommandLine.Builder commandLineBuilder =
        new CustomCommandLine.Builder()
            .add(attributes.getProtoCompiler().getExecPathString())
            .add("--input-file-list")
            .add(getProtoInputListFile().getExecPathString())
            .add("--output-dir")
            .add(getWorkspaceRelativeOutputDir().getSafePathString())
            .add("--working-dir")
            .add(".");

    if (attributes.getOptionsFile() != null) {
      commandLineBuilder
          .add("--compiler-options-path")
          .add(attributes.getOptionsFile().getExecPathString());
    }

    if (attributes.outputsCpp()) {
      commandLineBuilder.add("--generate-cpp");
    }

    if (attributes.usesObjcHeaderNames()) {
      commandLineBuilder.add("--use-objc-header-names");
    }
    return commandLineBuilder.build();
  }
Example #14
0
 public Vector getRangos() {
   Vector salida = new Vector();
   double[][] rangos = this.devuelveRangos();
   for (int i = 0; i < nVars; i++) {
     Vector rango = new Vector();
     if (this.getTiposIndex2(i).equals("real")) {
       // if (this.getTiposIndex(i).equals("real")) {
       rango.add(new Double(rangos[i][0]));
       rango.add(new Double(rangos[i][1]));
       /*}else if(this.getTiposIndex2(i).equals("integer")){
          rango.add(new Integer((int)rangos[i][0]));
          rango.add(new Integer((int)rangos[i][1]));
       */
     } else {
       if (i == nVars - 1) {
         for (int j = 0; j < Attributes.getOutputAttribute(0).getNumNominalValues(); j++) {
           rango.add(Attributes.getOutputAttribute(0).getNominalValue(j));
         }
       } else {
         for (int j = 0; j < Attributes.getAttribute(i).getNumNominalValues(); j++) {
           rango.add(Attributes.getAttribute(i).getNominalValue(j));
         }
       }
     }
     salida.add(rango);
   }
   return salida;
 }
Example #15
0
 /* Devuelve el tipo del atributo de indice index */
 public String getTiposIndex(int index) {
   int tipo = Attributes.getAttribute(index).getType();
   if ((tipo == Attributes.getAttribute(0).INTEGER) || (tipo == Attributes.getAttribute(0).REAL)) {
     return "real";
   }
   return "enumerado";
 }
Example #16
0
  static ScenarioForEvalData createNullfall() {
    // set up the base case:
    ScenarioForEvalData nullfall = new ScenarioForEvalData();

    // construct values for one OD relation:
    Values nullfallForOD = new Values();
    nullfall.setValuesForODRelation("AB", nullfallForOD);
    {
      // construct values for the road mode for this OD relation:
      ValuesForAMode roadValues = nullfallForOD.getByMode(Mode.road);
      {
        //				// passenger traffic:
        //				ValuesForAUserType pvValues = roadValues.getByType(Type.PV) ;
        //				pvValues.setByEntry( Entry.amount, 1000. ) ; // number of persons
        //				pvValues.setByEntry( Entry.km, 10. ) ;
        //				pvValues.setByEntry( Entry.hrs, 1. ) ;
      }
      {
        // freight traffic:
        Attributes gvValues = roadValues.getByDemandSegment(DemandSegment.GV);
        gvValues.setByEntry(Attribute.XX, 1000.); // tons
        gvValues.setByEntry(Attribute.km, 10.);
        gvValues.setByEntry(Attribute.hrs, 1.);
      }

      // rail values are just a copy of the road values:
      ValuesForAMode railValues = roadValues.createDeepCopy();
      nullfallForOD.setValuesForMode(Mode.rail, railValues);
    }

    // return the base case:
    return nullfall;
  }
Example #17
0
  public static Attributes attributes(String... attrs) {
    Attributes res = new Attributes();
    for (String attr : attrs) {
      res.generic(attr, attr);
    }

    return res;
  }
Example #18
0
 public void mustSuitablyOverrideAttributeHandlingMethods() {
   @SuppressWarnings("unused")
   final Source<Integer, NotUsed> f =
       Source.single(42)
           .withAttributes(Attributes.name(""))
           .addAttributes(Attributes.asyncBoundary())
           .named("");
 }
Example #19
0
  public static Attributes attributes(Enum<?>... attrs) {
    Attributes res = new Attributes();
    for (Enum<?> attr : attrs) {
      res.generic(attr.toString(), attr.toString());
    }

    return res;
  }
 @Override
 public CompoundExplainer getExplainer(ExplainContext context) {
   Attributes atts = new Attributes();
   atts.put(Label.NAME, PrimitiveExplainer.getInstance(getName()));
   atts.put(Label.LIMIT, PrimitiveExplainer.getInstance(limit));
   atts.put(Label.INPUT_OPERATOR, inputOperator.getExplainer(context));
   return new CompoundExplainer(Type.LIMIT_OPERATOR, atts);
 }
Example #21
0
 public void startElement(String nm, String ln, String qn, Attributes as) throws SAXException {
   if (level++ == 0)
     for (int i = 0; i < as.getLength(); i++)
       if (attributename.equals("*") || attributename.equals(as.getQName(i))) {
         char[] s = as.getValue(i).toCharArray();
         next.characters(s, 0, s.length);
       }
 }
  /**
   * Generates an entry for a backup directory based on the provided DN. The DN must contain an RDN
   * component that specifies the path to the backup directory, and that directory must exist and be
   * a valid backup directory.
   *
   * @param entryDN The DN of the backup directory entry to retrieve.
   * @return The requested backup directory entry.
   * @throws DirectoryException If the specified directory does not exist or is not a valid backup
   *     directory, or if the DN does not specify any backup directory.
   */
  private Entry getBackupDirectoryEntry(DN entryDN) throws DirectoryException {
    // Make sure that the DN specifies a backup directory.
    AttributeType t = DirectoryServer.getAttributeType(ATTR_BACKUP_DIRECTORY_PATH, true);
    AttributeValue v = entryDN.getRDN().getAttributeValue(t);
    if (v == null) {
      Message message = ERR_BACKUP_DN_DOES_NOT_SPECIFY_DIRECTORY.get(String.valueOf(entryDN));
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message, backupBaseDN, null);
    }

    // Get a handle to the backup directory and the information that it
    // contains.
    BackupDirectory backupDirectory;
    try {
      backupDirectory = BackupDirectory.readBackupDirectoryDescriptor(v.getValue().toString());
    } catch (ConfigException ce) {
      if (debugEnabled()) {
        TRACER.debugCaught(DebugLogLevel.ERROR, ce);
      }

      Message message =
          ERR_BACKUP_INVALID_BACKUP_DIRECTORY.get(String.valueOf(entryDN), ce.getMessage());
      throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message);
    } catch (Exception e) {
      if (debugEnabled()) {
        TRACER.debugCaught(DebugLogLevel.ERROR, e);
      }

      Message message = ERR_BACKUP_ERROR_GETTING_BACKUP_DIRECTORY.get(getExceptionMessage(e));
      throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), message);
    }

    // Construct the backup directory entry to return.
    LinkedHashMap<ObjectClass, String> ocMap = new LinkedHashMap<ObjectClass, String>(2);
    ocMap.put(DirectoryServer.getTopObjectClass(), OC_TOP);

    ObjectClass backupDirOC = DirectoryServer.getObjectClass(OC_BACKUP_DIRECTORY, true);
    ocMap.put(backupDirOC, OC_BACKUP_DIRECTORY);

    LinkedHashMap<AttributeType, List<Attribute>> opAttrs =
        new LinkedHashMap<AttributeType, List<Attribute>>(0);
    LinkedHashMap<AttributeType, List<Attribute>> userAttrs =
        new LinkedHashMap<AttributeType, List<Attribute>>(3);

    ArrayList<Attribute> attrList = new ArrayList<Attribute>(1);
    attrList.add(Attributes.create(t, v));
    userAttrs.put(t, attrList);

    t = DirectoryServer.getAttributeType(ATTR_BACKUP_BACKEND_DN, true);
    attrList = new ArrayList<Attribute>(1);
    attrList.add(
        Attributes.create(
            t, AttributeValues.create(t, backupDirectory.getConfigEntryDN().toString())));
    userAttrs.put(t, attrList);

    Entry e = new Entry(entryDN, ocMap, userAttrs, opAttrs);
    e.processVirtualAttributes();
    return e;
  }
Example #23
0
 @Override
 public void emitStartTagToken(ResizableCharBuilder name, Attributes attrs, boolean selfClosing) {
   Map<String, AttributeNode> m = new LinkedHashMap<>();
   for (String key : attrs.keySet()) {
     m.put(key, attrs.get(key));
   }
   // ENSURE that name.toLowerCase() is called in the TreeConstructor!
   tokens.add(new Token.StartTagToken(name.toLowerCase(), m, selfClosing));
 }
Example #24
0
  /**
   * Compute the number of all possible conditions that could appear in a rule of a given data. For
   * nominal attributes, it's the number of values that could appear; for numeric attributes, it's
   * the number of values * 2, i.e. <= and >= are counted as different possible conditions.
   *
   * @return number of all conditions of the data
   */
  public double numAllConditions() {
    double total = 0;

    for (int i = 0; i < Attributes.getInputNumAttributes(); i++) {
      Attribute att = Attributes.getInputAttribute(i);
      if (att.getType() == Attribute.NOMINAL) total += (double) att.getNumNominalValues();
      else total += 2.0 * (double) numDistinctValues(i);
    }
    return total;
  }
 /**
  * Método que imprime os valores dos attributos do objeto instanciado
  *
  * @return
  */
 public void printListOfAttributes() {
   for (int i = 0; i < Attributes.values().length; i++) {
     System.out.println(
         i
             + " : "
             + Attributes.values()[i].toString()
             + " : "
             + this.listOfAttributes[i].toString());
   }
 }
 private ExtraActoolArgs extraActoolArgs() {
   ImmutableList.Builder<String> extraArgs = ImmutableList.builder();
   if (attributes.appIcon() != null) {
     extraArgs.add("--app-icon", attributes.appIcon());
   }
   if (attributes.launchImage() != null) {
     extraArgs.add("--launch-image", attributes.launchImage());
   }
   return new ExtraActoolArgs(extraArgs.build());
 }
Example #27
0
 /**
  * Converts the given X.500 principal to a list of type/value attributes.
  *
  * @param principal Principal to convert.
  * @return List of type/value attributes.
  */
 public static Attributes readX500Principal(final X500Principal principal) {
   final X500Name name = X500Name.getInstance(principal.getEncoded());
   final Attributes attributes = new Attributes();
   for (RDN rdn : name.getRDNs()) {
     for (AttributeTypeAndValue tv : rdn.getTypesAndValues()) {
       attributes.add(tv.getType().getId(), tv.getValue().toString());
     }
   }
   return attributes;
 }
Example #28
0
 public AbstractModification(
     String keyspace, String columnFamily, String keyAlias, Attributes attrs) {
   this(
       keyspace,
       columnFamily,
       keyAlias,
       attrs.getConsistencyLevel(),
       attrs.getTimestamp(),
       attrs.getTimeToLive());
 }
Example #29
0
  /**
   * Generating the header of the output file @ param p PrintStream
   *
   * @return Nothing
   */
  private void CopyHeaderTest(PrintStream p) {

    // Header of the output file
    p.println("@relation " + Attributes.getRelationName());
    p.print(Attributes.getInputAttributesHeader());
    p.print(Attributes.getOutputAttributesHeader());
    p.println(Attributes.getInputHeader());
    p.println(Attributes.getOutputHeader());
    p.println("@data");
  }
Example #30
0
 /**
  * It copies the header of the dataset
  *
  * @return String A string containing all the data-set information
  */
 public String copyHeader() {
   String p = new String("");
   p = "@relation " + Attributes.getRelationName() + "\n";
   p += Attributes.getInputAttributesHeader();
   p += Attributes.getOutputAttributesHeader();
   p += Attributes.getInputHeader() + "\n";
   p += Attributes.getOutputHeader() + "\n";
   p += "@data\n";
   return p;
 }