Package com.hp.hpl.jena.rdf.model

Examples of com.hp.hpl.jena.rdf.model.Resource


      tempPrincipals.add(anonymousUserPrincipal);
      return true;
    }
    //get userInfo and check pwd
    try {
      Resource userResource = getUserResource(username);
      if (userResource == null) {
        if (logger.isInfoEnabled()) {
          logger.info("No user-resource with shortname "+username+" found");
        }
        throw new LoginException("Authentication failed: Password does not match");
      }
      success =
        userResource
          .getProperty(ACCOUNTMANAGER.passwordSha1)
          .getLiteral()
          .getString()
          .equals(
          Util.sha1(password));
View Full Code Here


    Source identity = new SourceImpl("http://example.org/tests/identity");
    Set<Source> trustedSources  = new HashSet<Source>();
    trustedSources.add(identity);
    NamedNode configuration = new NamedNodeImpl("http://example.org/tests/configuration#");
    Model authorizationModel = ModelFactory.createDefaultModel();
    Resource user = authorizationModel.createResource(FOAF.Agent);
    user.addProperty(ACCOUNTMANAGER.userName, "beta");
    user.addProperty(ACCOUNTMANAGER.passwordSha1, Util.sha1("tester"));
    user.addProperty(AUTHORIZATION.mayImpersonate, authorizationModel.createResource(sourceURL.toString()));
    store.assertGraph(identity, new FCAGraphImpl(authorizationModel));
    WebServer webServer = GVSServerLauncher.launchGVSServer(store, serverBinding, identity ,
        trustedSources, configuration);

    Model model = ModelFactory.createDefaultModel();
View Full Code Here

   */
  private void writeMetaInf(File directory, NamedNode node, Resource type,
      Object component) throws IOException {
    File metaInfFile = new File(directory, "meta-inf");
    Model metaInfModel = ModelFactory.createDefaultModel();
    Resource componentRes = metaInfModel.createResource(node.getURIRef());
    componentRes.addProperty(RDF.type, type);
    componentRes.addProperty(METAMODEL.hashCode, metaInfModel
        .createTypedLiteral(component.hashCode()));

    OutputStream metaInfOut = new FileOutputStream(metaInfFile);
    try {
      metaInfModel.write(metaInfOut, "N-TRIPLE");
View Full Code Here

      directory.mkdirs();
      // writeMetaInf(directory, componentDirectory.getNode(),
      // METAMODEL.FunctionallyGroundedNode, functionallyGroundedNode);
      File metaInfFile = new File(directory, "meta-inf");
      Model metaInfModel = ModelFactory.createDefaultModel();
      Resource componentRes = metaInfModel
          .createResource(componentDirectory.getNode().getURIRef());
      componentRes.addProperty(RDF.type,
          METAMODEL.FunctionallyGroundedNode);
      componentRes.addProperty(METAMODEL.hashCode, metaInfModel
          .createTypedLiteral(functionallyGroundedNode.hashCode()));
      componentRes.addProperty(METAMODEL.strongHashCode, metaInfModel
          .createTypedLiteral(functionallyGroundedNode
              .strongHashCode()));
      for (NonTerminalMolecule molecule : functionallyGroundedNode
          .getGroundingMolecules()) {
        // storeNTMolecule doesn't add duplicate
        NamedNode moleculeName;
        try {
          moleculeName = storeNTMolecule(molecule);
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
        componentRes.addProperty(METAMODEL.containsNonTerminalMolecule,
            metaInfModel.createResource(moleculeName.getURIRef()));
      }
      OutputStream metaInfOut = new FileOutputStream(metaInfFile);
      try {
        metaInfModel.write(metaInfOut, "N-TRIPLE");
View Full Code Here

    FunctionallyGroundedNode result = null;
    result = currentlyBeingAdded.getKey(functionallyGroundedNodeRef);
    if (result != null) {
      return result;
    }
    Resource fgRes = indexModel.getResource(functionallyGroundedNodeRef
        .getURIRef());
    if (!fgRes.hasProperty(RDF.type, METAMODEL.FunctionallyGroundedNode)) {
      throw new RuntimeException(functionallyGroundedNodeRef
          + ": what's that?");
    }
    WeakReference<FunctionallyGroundedNode> resultRef = fgNodeCache
        .get(functionallyGroundedNodeRef);
View Full Code Here

          if (groundingMolecules == null) {

            StmtIterator containsStmts = resource
                .listProperties(METAMODEL.containsNonTerminalMolecule);
            while (containsStmts.hasNext()) {
              Resource ntMolRes = containsStmts.nextStatement()
                  .getResource();
              resultList.add(new FSNTMolecule(ntMolRes));
            }
            groundingMolecules = new AbstractSet<NonTerminalMolecule>() {
View Full Code Here

          cannedDefaultConfigURLString);
      cannedDefaultConfigInputStream.close();
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
    Resource cannedDefaultConfigResource = cannedDefaultConfigModel
        .getResource(cannedDefaultConfigURLString+"#");
    Statement cannedVersionDateStmt = cannedDefaultConfigResource
        .getRequiredProperty(DC.date);
    final Date cannedVersionDate = ((XSDDateTime) cannedVersionDateStmt
        .getLiteral().getValue()).asCalendar().getTime();
    cannedVersionDateStmt.remove();
   
View Full Code Here

    String password = parameterMap.get("password");
    if (parameterMap.containsKey("email")) {
      String email = parameterMap.get("email");
      String passwordSha1 = Util.sha1(password);
      String mboxSha1 = Util.sha1("mbox" + email);
      Resource user = getUserByUsername(username);
      if (user != null) {
        if (!user.hasProperty(FOAF.mbox_sha1sum, mboxSha1)) {
          throw new HandlerException(
              "user already exists with a differen email address");
        } else {
          log
              .info("Username/Email combination exist, will delete exitisting on confirmation");
        }
      }

      LoginData loginData = new LoginData(username, passwordSha1,
          mboxSha1);
      String verificationKey = Util.createRandomString(28);
      verificationMap.put(verificationKey, loginData);
      log.info("sending login link to " + email);
      loginLinkSender.sendLoginLink(email, getVerificationLink(request,
          verificationKey));
      response.setResponseStatus(ResponseStatus.MOVED_TEMPORARILY);
      response.setHeader(HeaderName.LOCATION,
          "/application/verification-sent");
    } else {
      String[] verificationParameters = request.getRequestURI()
          .getParameterValues("verification");
      if (verificationParameters != null) {
        if (verificationParameters.length == 1) {
          LoginData loginData = verificationMap
              .get(verificationParameters[0]);
          if (loginData == null) {
            throw new HandlerException(
                "Verification string not found, probably expired");
          }
          Graph graph = new SimpleGraph();
          addUser(loginData, graph, request);
          response
              .setDefaultStylesheet("/application/stylesheets/verification-result");
          response.setBody(graph);
          Resource user = getUserByUsernameInIdentityGOT(loginData.userName);
          FCAGraph revokeGraphTmp = null;
          if (user != null) {
            log
                .info("Username already exist, removing previous password");
            Model revokeModel = ModelFactory.createDefaultModel();
            revokeModel.add(user
                .listProperties(ACCOUNTMANAGER.passwordSha1));
            revokeModel.add(user.listProperties(FOAF.mbox_sha1sum));
            revokeModel.add(user
                .listProperties(ACCOUNTMANAGER.userName));
            revokeGraphTmp = new FCAGraphImpl(revokeModel);
            // store.revokeGraph(identity, new
            // FCAGraphImpl(revokeModel), now);
          }
View Full Code Here

   * @param username
   * @param password
   * @return
   */
  private boolean loginValid(String username, String password) {
    Resource user = getUserByUsername(username);
    if (user == null) {
      return false;
    }
    return user.hasProperty(ACCOUNTMANAGER.passwordSha1, Util
        .sha1(password));
  }
View Full Code Here

    ResIterator subjectIter = model.listSubjectsWithProperty(
        ACCOUNTMANAGER.userName, username);
    if (!subjectIter.hasNext()) {
      return null;
    }
    Resource subject = subjectIter.nextResource();
    if (subjectIter.hasNext()) {
      throw new RuntimeException("Username ambiguos");
    }
    return subject;
  }
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.rdf.model.Resource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.