コード例 #1
0
  /**
   * Creates an account for the given user and password.
   *
   * @param providerFactory the ProtocolProviderFactory which will create the account
   * @param user the user identifier
   * @return the <tt>ProtocolProviderService</tt> for the new account.
   */
  public ProtocolProviderService installAccount(
      ProtocolProviderFactory providerFactory, String user) throws OperationFailedException {
    Hashtable<String, String> accountProperties = new Hashtable<String, String>();

    accountProperties.put(
        ProtocolProviderFactory.ACCOUNT_ICON_PATH,
        "resources/images/protocol/gibberish/gibberish32x32.png");

    if (registration.isRememberPassword()) {
      accountProperties.put(ProtocolProviderFactory.PASSWORD, registration.getPassword());
    }

    if (isModification()) {
      providerFactory.uninstallAccount(protocolProvider.getAccountID());
      this.protocolProvider = null;
      setModification(false);
    }

    try {
      AccountID accountID = providerFactory.installAccount(user, accountProperties);

      ServiceReference serRef = providerFactory.getProviderForAccount(accountID);

      protocolProvider =
          (ProtocolProviderService) GibberishAccRegWizzActivator.bundleContext.getService(serRef);
    } catch (IllegalStateException exc) {
      logger.warn(exc.getMessage());

      throw new OperationFailedException(
          "Account already exists.", OperationFailedException.IDENTIFICATION_CONFLICT);
    } catch (Exception exc) {
      logger.warn(exc.getMessage());

      throw new OperationFailedException(
          "Failed to add account", OperationFailedException.GENERAL_ERROR);
    }

    return protocolProvider;
  }
コード例 #2
0
  /**
   * Creates an account for the given Account ID, Identity File and Known Hosts File
   *
   * @param providerFactory the ProtocolProviderFactory which will create the account
   * @param user the user identifier
   * @return the <tt>ProtocolProviderService</tt> for the new account.
   */
  public ProtocolProviderService installAccount(
      ProtocolProviderFactory providerFactory, String user) throws OperationFailedException {
    Hashtable<String, String> accountProperties = new Hashtable<String, String>();

    accountProperties.put(
        ProtocolProviderFactory.ACCOUNT_ICON_PATH, "resources/images/protocol/ssh/ssh32x32.png");

    accountProperties.put(
        ProtocolProviderFactory.NO_PASSWORD_REQUIRED, new Boolean(true).toString());

    accountProperties.put(
        ProtocolProviderFactorySSHImpl.IDENTITY_FILE, registration.getIdentityFile());

    accountProperties.put(
        ProtocolProviderFactorySSHImpl.KNOWN_HOSTS_FILE,
        String.valueOf(registration.getKnownHostsFile()));

    try {
      AccountID accountID = providerFactory.installAccount(user, accountProperties);

      ServiceReference serRef = providerFactory.getProviderForAccount(accountID);

      protocolProvider =
          (ProtocolProviderService) SSHAccRegWizzActivator.bundleContext.getService(serRef);
    } catch (IllegalStateException exc) {
      logger.warn(exc.getMessage());

      throw new OperationFailedException(
          "Account already exists.", OperationFailedException.IDENTIFICATION_CONFLICT);
    } catch (Exception exc) {
      logger.warn(exc.getMessage());

      throw new OperationFailedException(
          "Failed to add account", OperationFailedException.GENERAL_ERROR);
    }

    return protocolProvider;
  }
コード例 #3
0
 /**
  * Saves the password for the specified account after scrambling it a bit so that it is not
  * visible from first sight (Method remains highly insecure).
  *
  * @param accountID the AccountID for the account whose password we're storing.
  * @param passwd the password itself.
  * @throws java.lang.IllegalArgumentException if no account corresponding to <tt>accountID</tt>
  *     has been previously stored.
  */
 public void storePassword(AccountID accountID, String passwd) throws IllegalArgumentException {
   super.storePassword(SipActivator.getBundleContext(), accountID, passwd);
 }
コード例 #4
0
 /** Loads (and hence installs) all accounts previously stored in the configuration service. */
 public void loadStoredAccounts() {
   super.loadStoredAccounts(SipActivator.getBundleContext());
 }