Exemplo n.º 1
0
 @Override
 protected RunTransactionalReturnData runTransactional() throws Exception {
   PrivateSignatory authorizer;
   if (statement instanceof RootContext) {
     if (!delegate.equals(statementAuthority.getAuthor(getTransaction())))
       throw new SignCommandException("Not the author");
     authorizer = delegate.getPrivateSignatory(getTransaction());
   } else {
     StatementAuthority parentAuth =
         statement.getContext(getTransaction()).getAuthority(getTransaction());
     Identifier identifier = statement.getIdentifier();
     Namespace namespace = identifier == null ? RootNamespace.instance : identifier;
     DelegateAuthorizer da =
         parentAuth.delegateAuthorizerMap(getTransaction(), namespace).get(delegate);
     if (da == null) throw new SignCommandException("Not a delegate");
     Signatory authorizer_ = da.getAuthorizer(getTransaction());
     if (authorizer_ == null) {
       authorizer = da.createAuthorizer(getTransaction());
       da.sign(getTransaction());
       da.persistenceUpdate(getTransaction());
     } else {
       if (!(authorizer_ instanceof PrivateSignatory))
         throw new SignCommandException(
             "Haven't got private data for this authorizer. Maybe try entering the passphrase?");
       authorizer = (PrivateSignatory) authorizer_;
     }
   }
   statementAuthority.createSignature(getTransaction(), authorizer);
   return null;
 }
Exemplo n.º 2
0
 @Override
 public Sign parse(CommandSource from, Transaction transaction, Void extra, List<String> split)
     throws CommandParseException {
   try {
     checkMinParameters(split);
     PrivatePerson delegate =
         from.getPersistenceManager().privatePersonsByNick(transaction).get(split.get(0));
     if (delegate == null) throw new CommandParseException("Invalid nick");
     Statement statement;
     if (split.size() > 1) {
       statement =
           findStatementSpec(
               from.getPersistenceManager(), transaction, from.getActiveContext(), split.get(1));
       if (statement == null) throw new CommandParseException("Invalid statement");
     } else {
       statement = from.getActiveContext();
       if (statement == null) throw new NotActiveContextException();
     }
     StatementAuthority statementAuthority = statement.getAuthority(transaction);
     if (statementAuthority == null) throw new CommandParseException("Statement not authored");
     return makeSign(from, transaction, statement, statementAuthority, delegate);
   } catch (NotActiveContextException e) {
     throw new CommandParseException(e);
   }
 }
Exemplo n.º 3
0
 @Override
 protected RunTransactionalReturnData runTransactional() throws Exception {
   for (StatementAuthoritySignature signature : signatures) {
     if (signature.isValid()) {
       Statement statement = signature.getStatement(getTransaction());
       if (!(statement instanceof RootContext)) {
         ContextAuthority contextAuthority =
             statement.getContext(getTransaction()).getAuthority(getTransaction());
         if (contextAuthority != null) {
           DelegateAuthorizer da =
               contextAuthority
                   .delegateAuthorizerByAuthorizerMap(
                       getTransaction(), statement.prefix(getTransaction()))
                   .get(signature.getAuthorizer(getTransaction()));
           if (da != null) {
             if (da.isSigned() && (da.getDelegate(getTransaction()) instanceof PrivatePerson)) {
               DelegateTreeRootNode rn = da.getDelegateTreeRootNode(getTransaction());
               if (rn.isSigned()) {
                 da.addRevokedSignatureUuid(signature.getSignatureUuid());
                 da.sign(getTransaction());
                 da.persistenceUpdate(getTransaction());
               } else
                 getErr()
                     .println(
                         "Signature: "
                             + signature.getAuthorizer(getTransaction())
                             + "'s delegate tree root node is not signed");
             } else
               getErr()
                   .println(
                       "Signature: "
                           + signature.getAuthorizer(getTransaction())
                           + " non-revokable");
           } else
             getErr()
                 .println(
                     "Signature: "
                         + signature.getAuthorizer(getTransaction())
                         + " has no delegate authorizer");
         } else
           getErr()
               .println(
                   "Signature: "
                       + signature.getAuthorizer(getTransaction())
                       + " has no context authority (!?)");
       } else
         getErr()
             .println(
                 "Signature: "
                     + signature.getAuthorizer(getTransaction())
                     + " is for a root context");
     } else
       getErr().println("Signature: " + signature.getAuthorizer(getTransaction()) + " not valid");
   }
   return null;
 }
  public AuthorityHeaderJPanel(
      AuthorityJPanel authorityJPanel, StatementAuthority statementAuthority) {
    super();
    this.authorityJPanel = authorityJPanel;
    this.statementAuthority = statementAuthority;
    GridBagLayout gridBagLayout = new GridBagLayout();
    setLayout(gridBagLayout);
    setBackground(Color.white);
    Transaction transaction = getPersistenceManager().beginTransaction(transactionTimeOut);
    try {
      Insets insets = new Insets(0, 0, 0, 10);
      {
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.insets = insets;
        gbc.anchor = GridBagConstraints.WEST;
        add(new BoldTextLabelRenderer("Author"), gbc);
      }
      {
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = 0;
        gbc.insets = insets;
        gbc.anchor = GridBagConstraints.WEST;
        add(new PersonLabelRenderer(statementAuthority.getAuthor(transaction)), gbc);
      }
      {
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 1;
        gbc.insets = insets;
        gbc.anchor = GridBagConstraints.WEST;
        add(new BoldTextLabelRenderer("Created"), gbc);
      }
      {
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = 1;
        gbc.insets = insets;
        gbc.anchor = GridBagConstraints.WEST;
        add(new DateLabelRenderer(statementAuthority.getCreationDate()), gbc);
      }
      {
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 2;
        gbc.insets = insets;
        gbc.anchor = GridBagConstraints.WEST;
        add(new BoldTextLabelRenderer("Status"), gbc);
      }
      {
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = 2;
        gbc.insets = insets;
        gbc.anchor = GridBagConstraints.WEST;
        add(new SignatureStatusLabelRenderer(statementAuthority.signatureStatus()), gbc);
      }
      Statement statement = statementAuthority.getStatement(transaction);
      if (statement != null) {
        this.dependenciesListJTable =
            new MyStatementListJTable(
                "Dependencies", new BufferedList<>(statement.dependencies(transaction)));
        {
          GridBagConstraints gbc = new GridBagConstraints();
          gbc.gridx = 2;
          gbc.gridy = 0;
          gbc.gridheight = 4;
          gbc.insets = insets;
          gbc.anchor = GridBagConstraints.WEST;
          gbc.fill = GridBagConstraints.BOTH;
          JScrollPane depPane = new JScrollPane(this.dependenciesListJTable);
          add(depPane, gbc);
          this.dependenciesListFocusBorderManager =
              new FocusBorderManager(depPane, dependenciesListJTable);
        }
        if (statement instanceof Context) {
          Context context = (Context) statement;
          this.solverListJTable =
              new MyStatementListJTable(
                  "Solvers", new BufferedList<>(context.solvers(transaction)));
          {
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.gridx = 3;
            gbc.gridy = 0;
            gbc.gridheight = 4;
            gbc.insets = insets;
            gbc.anchor = GridBagConstraints.WEST;
            gbc.fill = GridBagConstraints.BOTH;
            JScrollPane solPane = new JScrollPane(this.solverListJTable);
            add(solPane, gbc);
            this.solverListFocusBorderManager = new FocusBorderManager(solPane, solverListJTable);
          }
        } else {
          this.solverListJTable = null;
          this.solverListFocusBorderManager = null;
        }
        DelegateTreeRootNode delegateTreeRootNode =
            statementAuthority.getDelegateTreeRootNode(transaction);
        if (delegateTreeRootNode != null && !delegateTreeRootNode.successorEntries().isEmpty()) {

          {
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.gridx = 4;
            gbc.gridy = 0;
            gbc.gridheight = 4;
            gbc.insets = insets;
            gbc.anchor = GridBagConstraints.WEST;
            gbc.fill = GridBagConstraints.BOTH;
            JLabel label = new JLabel("             ");
            label.setFont(FontManager.instance.defaultFont());
            add(label, gbc);
          }
          this.successorListJTable =
              new SuccessorsJTable(getPersistenceManager(), delegateTreeRootNode);
          {
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.gridx = 5;
            gbc.gridy = 0;
            gbc.gridheight = 4;
            gbc.insets = insets;
            gbc.anchor = GridBagConstraints.WEST;
            gbc.fill = GridBagConstraints.BOTH;
            JScrollPane sucPane = new JScrollPane(this.successorListJTable);
            add(sucPane, gbc);
            this.successorListFocusBorderManager =
                new FocusBorderManager(sucPane, successorListJTable);
          }
        } else {
          this.successorListJTable = null;
          this.successorListFocusBorderManager = null;
        }
      } else {
        this.dependenciesListJTable = null;
        this.dependenciesListFocusBorderManager = null;
        this.solverListJTable = null;
        this.solverListFocusBorderManager = null;
        this.successorListJTable = null;
        this.successorListFocusBorderManager = null;
      }

    } finally {
      transaction.abort();
    }
  }