Exemplo n.º 1
0
  /** Builds the Network panel. */
  protected JPanel buildNetworkPanel() {
    JGridBagPanel p = new JGridBagPanel();
    p.setBorder(BorderFactory.createEmptyBorder(16, 16, 16, 16));

    JLabel proxyLabel = new JLabel(Resources.getString(PREFERENCE_KEY_LABEL_HTTP_PROXY));
    JLabel hostLabel = new JLabel(Resources.getString(PREFERENCE_KEY_LABEL_HOST));
    JLabel portLabel = new JLabel(Resources.getString(PREFERENCE_KEY_LABEL_PORT));
    JLabel colonLabel = new JLabel(Resources.getString(PREFERENCE_KEY_LABEL_COLON));
    Font f = hostLabel.getFont();
    float size = f.getSize2D() * 0.85f;
    f = f.deriveFont(size);
    hostLabel.setFont(f);
    portLabel.setFont(f);
    host = new JTextField();
    host.setPreferredSize(new Dimension(200, 20));
    port = new JTextField();
    port.setPreferredSize(new Dimension(40, 20));

    p.add(proxyLabel, 0, 0, 1, 1, EAST, NONE, 0, 0);
    p.add(host, 1, 0, 1, 1, WEST, HORIZONTAL, 0, 0);
    p.add(colonLabel, 2, 0, 1, 1, WEST, NONE, 0, 0);
    p.add(port, 3, 0, 1, 1, WEST, HORIZONTAL, 0, 0);
    p.add(hostLabel, 1, 1, 1, 1, WEST, NONE, 0, 0);
    p.add(portLabel, 3, 1, 1, 1, WEST, NONE, 0, 0);

    return p;
  }
Exemplo n.º 2
0
  private void setContextOptions(GameOptions gameType) {
    JPopupMenu contextOptions = new JPopupMenu();

    JMenu addPieces = new JMenu(Resources.getString(Resources.ADD_PIECE));

    String[] pieces = gameType.getPieceList();
    for (int i = 0; i < pieces.length; i++) {
      JMenuItem newPieceName = new JMenuItem(pieces[i]);

      newPieceName.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              System.out.println(((JMenuItem) e.getSource()).getText());
            }
          });

      addPieces.add(newPieceName);
    }

    contextOptions.add(addPieces);

    contextOptions.add(new JMenuItem(Resources.getString(Resources.DELETE_PIECE)));

    this.setComponentPopupMenu(contextOptions);
  }
Exemplo n.º 3
0
 /** Adds a panel to the configuration panel. */
 protected void addConfigPanel(String id, JPanel c) {
   String name = Resources.getString(PREFERENCE_KEY_TITLE_PREFIX + id);
   ImageIcon icon1 =
       new ImageIcon(PreferenceDialog.class.getResource("resources/icon-" + id + ".png"));
   ImageIcon icon2 =
       new ImageIcon(PreferenceDialog.class.getResource("resources/icon-" + id + "-dark.png"));
   configurationPanel.addPanel(name, icon1, icon2, c);
 }
Exemplo n.º 4
0
  /** Creates the OK/Cancel button panel. */
  protected JPanel buildButtonsPanel() {
    JPanel p = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    JButton okButton = new JButton(Resources.getString(LABEL_OK));
    JButton cancelButton = new JButton(Resources.getString(LABEL_CANCEL));
    p.add(okButton);
    p.add(cancelButton);

    okButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setVisible(false);
            returnCode = OK_OPTION;
            savePreferences();
            dispose();
          }
        });

    cancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setVisible(false);
            returnCode = CANCEL_OPTION;
            dispose();
          }
        });

    addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            switch (e.getKeyCode()) {
              case KeyEvent.VK_ESCAPE:
                returnCode = CANCEL_OPTION;
                break;
              case KeyEvent.VK_ENTER:
                returnCode = OK_OPTION;
                break;
              default:
                return;
            }
            setVisible(false);
            dispose();
          }
        });

    return p;
  }
  /** The default constructor for the SSH protocol provider. */
  public ProtocolProviderServiceSSHImpl() {
    logger.trace("Creating a ssh provider.");

    try {
      // converting to milliseconds
      connectionTimeout = Integer.parseInt(Resources.getString("connectionTimeout")) * 1000;
    } catch (NumberFormatException ex) {
      logger.error("Connection Timeout set to 30 seconds");
    }
  }
  /**
   * Called to accept an incoming invitation. Adds the invitation chat room to the list of chat
   * rooms and joins it.
   *
   * @param invitation the invitation to accept.
   */
  public void acceptInvitation(WhiteboardInvitation invitation) {
    WhiteboardSession whiteboard = invitation.getTargetWhiteboard();

    byte[] password = invitation.getWhiteboardPassword();

    try {
      if (password == null) whiteboard.join();
      else whiteboard.join(password);
    } catch (OperationFailedException e) {
      WhiteboardActivator.getUiService()
          .getPopupDialog()
          .showMessagePopupDialog(
              Resources.getString(
                  "failedToJoinWhiteboard", new String[] {whiteboard.getWhiteboardID()}),
              Resources.getString("error"),
              PopupDialog.ERROR_MESSAGE);

      logger.error("Failed to join whiteboard: " + whiteboard.getWhiteboardID(), e);
    }
  }
  /**
   * Returns the set of data that user has entered through this wizard.
   *
   * @return Iterator
   */
  @Override
  public Iterator<Map.Entry<String, String>> getSummary() {
    Hashtable<String, String> summaryTable = new Hashtable<String, String>();

    summaryTable.put(
        Resources.getString("plugin.jabberaccregwizz.USERNAME"), registration.getUserID());

    summaryTable.put(
        Resources.getString("service.gui.REMEMBER_PASSWORD"),
        Boolean.toString(registration.isRememberPassword()));

    summaryTable.put(
        Resources.getString("plugin.jabberaccregwizz.SERVER"), registration.getServerAddress());

    summaryTable.put(
        Resources.getString("service.gui.PORT"), String.valueOf(registration.getServerPort()));

    summaryTable.put(
        Resources.getString("plugin.jabberaccregwizz.ENABLE_KEEP_ALIVE"),
        String.valueOf(registration.isSendKeepAlive()));

    summaryTable.put(
        Resources.getString("plugin.jabberaccregwizz.ENABLE_GMAIL_NOTIFICATIONS"),
        String.valueOf(registration.isGmailNotificationEnabled()));

    summaryTable.put(
        Resources.getString("plugin.jabberaccregwizz.RESOURCE"), registration.getResource());

    summaryTable.put(
        Resources.getString("plugin.jabberaccregwizz.PRIORITY"),
        String.valueOf(registration.getPriority()));

    summaryTable.put(
        Resources.getString("plugin.sipaccregwizz.DTMF_METHOD"), registration.getDTMFMethod());

    summaryTable.put(
        Resources.getString("plugin.sipaccregwizz.DTMF_MINIMAL_TONE_DURATION"),
        registration.getDtmfMinimalToneDuration());

    return summaryTable.entrySet().iterator();
  }
    /**
     * Implements the <tt>WhiteboardSessionPresenceListener .whiteboardSessionPresenceChanged</tt>
     * method.
     */
    public void whiteboardSessionPresenceChanged(WhiteboardSessionPresenceChangeEvent evt) {
      WhiteboardSession whiteboardSession = evt.getWhiteboardSession();

      if (evt.getEventType().equals(WhiteboardSessionPresenceChangeEvent.LOCAL_USER_JOINED)) {
        whiteboardSession.addWhiteboardObjectListener(WhiteboardSessionManager.this);

        WhiteboardFrame frame = getWhiteboardFrame(evt.getWhiteboardSession());

        if (frame == null) {
          frame = new WhiteboardFrame(WhiteboardSessionManager.this, whiteboardSession);

          frame.setVisible(true);
          wbFrames.add(frame);
        }
      } else if (evt.getEventType()
          .equals(WhiteboardSessionPresenceChangeEvent.LOCAL_USER_JOIN_FAILED)) {
        WhiteboardActivator.getUiService()
            .getPopupDialog()
            .showMessagePopupDialog(
                Resources.getString(
                        "failedToJoinWhiteboard",
                        new String[] {whiteboardSession.getWhiteboardID()})
                    + evt.getReason(),
                Resources.getString("error"),
                PopupDialog.ERROR_MESSAGE);
      } else if (evt.getEventType().equals(WhiteboardSessionPresenceChangeEvent.LOCAL_USER_LEFT)) {
        WhiteboardFrame frame = getWhiteboardFrame(whiteboardSession);

        if (frame == null) return;

        wbFrames.remove(frame);
        frame.dispose();
        whiteboardSession.removeWhiteboardObjectListener(WhiteboardSessionManager.this);
      } else if (evt.getEventType()
          .equals(WhiteboardSessionPresenceChangeEvent.LOCAL_USER_KICKED)) {

      } else if (evt.getEventType()
          .equals(WhiteboardSessionPresenceChangeEvent.LOCAL_USER_DROPPED)) {

      }
    }
Exemplo n.º 9
0
  /**
   * Creates an instance of <tt>StatusSubMenu</tt>.
   *
   * @param tray a reference of the parent <tt>Systray</tt>
   */
  public StatusSubMenu(SystrayServiceJdicImpl tray) {

    parentSystray = tray;

    this.setText(Resources.getString("setStatus"));
    this.setIcon(Resources.getImage("statusMenuIcon"));

    /* makes the menu look better */
    this.setPreferredSize(new java.awt.Dimension(28, 24));

    this.init();
  }
  /**
   * This method will convert a string that represents an integer to an integer value. If it cannot
   * be converted, 0 will be returned.
   *
   * @param value Value to be converted.
   * @return The converted value; 0 if conversion fails or the value is empty.
   */
  public static int parseInt(String value) {
    int retval = 0; // default value if it cannot be converted

    if (isValued(value)) {
      try {
        retval = Integer.parseInt(value);
      } catch (Exception e) {
        logger.error(Resources.getString("parseIntError", value), e);
      }
    }

    return retval;
  }
Exemplo n.º 11
0
 /** set / update the text of the <code>footerButton</code>. */
 private void updateFooter() {
   if (footer != null) {
     Locale locale = cdt.getLocale();
     if (today != null) {
       if (cdt.builder.hasFooter(Footer.VERBOSE_TODAY)) {
         Calendar cal = cdt.getCalendarInstance(System.currentTimeMillis());
         Object[] margs = {
           cal.getTime(),
           Resources.getString("date_ordinal_" + cal.get(Calendar.DATE), locale) // $NON-NLS-1$
         };
         MessageFormat formatter =
             new MessageFormat(
                 Resources.getString("today_verbose.text", locale), locale); // $NON-NLS-1$
         today.setText(formatter.format(margs));
       } else {
         today.setText(Resources.getString("today.text", locale)); // $NON-NLS-1$
       }
     }
     if (clear != null) {
       clear.setText(Resources.getString("clear.text", locale)); // $NON-NLS-1$
     }
     footer.layout();
   }
 }
Exemplo n.º 12
0
 /**
  * set / update, or calls methods to set / update, all components affected by the <code>locale
  * </code>
  *
  * @see #updateHeader
  * @see #updateDayLabels
  * @see #updateDays
  * @see #updateFooter
  */
 private void updateLocale() {
   Locale locale = cdt.getLocale();
   if (monthPrev != null)
     monthPrev.setToolTipText(Resources.getString("nav_prev_month", locale)); // $NON-NLS-1$
   if (monthNext != null)
     monthNext.setToolTipText(Resources.getString("nav_next_month", locale)); // $NON-NLS-1$
   if (dateNow != null)
     dateNow.setToolTipText(Resources.getString("nav_current_day", locale)); // $NON-NLS-1$
   if (yearPrev != null)
     yearPrev.setToolTipText(Resources.getString("nav_prev_year", locale)); // $NON-NLS-1$
   if (yearNext != null)
     yearNext.setToolTipText(Resources.getString("nav_next_year", locale)); // $NON-NLS-1$
   if (today != null)
     today.setToolTipText(Resources.getString("nav_current_day", locale)); // $NON-NLS-1$
   if (todayMenuItem != null)
     todayMenuItem.setText(Resources.getString("nav_current_day", locale)); // $NON-NLS-1$
   if (showSelMenuItem != null)
     showSelMenuItem.setText(Resources.getString("show_selection", locale)); // $NON-NLS-1$
 }
Exemplo n.º 13
0
  /** Builds the UI for this dialog. */
  protected void buildGUI() {
    JPanel panel = new JPanel(new BorderLayout());

    configurationPanel = new JConfigurationPanel();
    addConfigPanel("general", buildGeneralPanel());
    addConfigPanel("security", buildSecurityPanel());
    addConfigPanel("language", buildLanguagePanel());
    addConfigPanel("stylesheet", buildStylesheetPanel());
    addConfigPanel("network", buildNetworkPanel());

    panel.add(configurationPanel);

    if (!Platform.isOSX) {
      setTitle(Resources.getString(PREFERENCE_KEY_TITLE_DIALOG));
      panel.add(buildButtonsPanel(), BorderLayout.SOUTH);
    }
    setResizable(false);

    getContentPane().add(panel);
  }
/**
 * A SSH implementation of the ProtocolProviderService.
 *
 * @author Shobhit Jindal
 */
public class ProtocolProviderServiceSSHImpl implements ProtocolProviderService {
  private static final Logger logger = Logger.getLogger(ProtocolProviderServiceSSHImpl.class);

  /** The name of this protocol. */
  public static final String SSH_PROTOCOL_NAME = ProtocolNames.SSH;

  //    /**
  //     * The identifier for SSH Stack
  //     * Java Secure Channel JSch
  //     */
  //    JSch jsch = new JSch();

  /** The test command given after each command to determine the reply length of the command */
  private final String testCommand = Resources.getString("testCommand");

  /** A reference to the protocol provider of UIService */
  private static ServiceReference ppUIServiceRef;

  /** Connection timeout to a remote server in milliseconds */
  private static int connectionTimeout = 30000;

  /** A reference to UI Service */
  private static UIService uiService;

  /** The id of the account that this protocol provider represents. */
  private AccountID accountID = null;

  /** We use this to lock access to initialization. */
  private Object initializationLock = new Object();

  /** The hashtable with the operation sets that we support locally. */
  private final Hashtable supportedOperationSets = new Hashtable();

  private OperationSetBasicInstantMessagingSSHImpl basicInstantMessaging;

  private OperationSetFileTransferSSHImpl fileTranfer;

  /** A list of listeners interested in changes in our registration state. */
  private Vector registrationStateListeners = new Vector();

  /** Indicates whether or not the provider is initialized and ready for use. */
  private boolean isInitialized = false;

  /** The logo corresponding to the ssh protocol. */
  private ProtocolIconSSHImpl sshIcon = new ProtocolIconSSHImpl();

  /**
   * The registration state of SSH Provider is taken to be registered by default as it doesn't
   * correspond to the state on remote server
   */
  private RegistrationState currentRegistrationState = RegistrationState.REGISTERED;

  /** The default constructor for the SSH protocol provider. */
  public ProtocolProviderServiceSSHImpl() {
    logger.trace("Creating a ssh provider.");

    try {
      // converting to milliseconds
      connectionTimeout = Integer.parseInt(Resources.getString("connectionTimeout")) * 1000;
    } catch (NumberFormatException ex) {
      logger.error("Connection Timeout set to 30 seconds");
    }
  }

  /**
   * Initializes the service implementation, and puts it in a sate where it could interoperate with
   * other services. It is strongly recomended that properties in this Map be mapped to property
   * names as specified by <tt>AccountProperties</tt>.
   *
   * @param userID the user id of the ssh account we're currently initializing
   * @param accountID the identifier of the account that this protocol provider represents.
   * @see net.java.sip.communicator.service.protocol.AccountID
   */
  protected void initialize(String userID, AccountID accountID) {
    synchronized (initializationLock) {
      this.accountID = accountID;

      // initialize the presence operationset
      OperationSetPersistentPresenceSSHImpl persistentPresence =
          new OperationSetPersistentPresenceSSHImpl(this);

      supportedOperationSets.put(
          OperationSetPersistentPresence.class.getName(), persistentPresence);

      // register it once again for those that simply need presence and
      // won't be smart enough to check for a persistent presence
      // alternative
      supportedOperationSets.put(OperationSetPresence.class.getName(), persistentPresence);

      // initialize the IM operation set
      basicInstantMessaging = new OperationSetBasicInstantMessagingSSHImpl(this);

      supportedOperationSets.put(
          OperationSetBasicInstantMessaging.class.getName(), basicInstantMessaging);

      // initialze the file transfer operation set
      fileTranfer = new OperationSetFileTransferSSHImpl(this);

      supportedOperationSets.put(OperationSetFileTransfer.class.getName(), fileTranfer);

      isInitialized = true;
    }
  }

  /**
   * Determines whether a vaild session exists for the contact of remote machine.
   *
   * @param sshContact ID of SSH Contact
   * @return <tt>true</tt> if the session is connected <tt>false</tt> otherwise
   */
  public boolean isSessionValid(ContactSSH sshContact) {
    Session sshSession = sshContact.getSSHSession();
    if (sshSession != null) if (sshSession.isConnected()) return true;

    // remove reference to an unconnected SSH Session, if any
    sshContact.setSSHSession(null);
    return false;
  }

  /**
   * Determines whether the contact is connected to shell of remote machine as a precheck for any
   * further operation
   *
   * @param sshContact ID of SSH Contact
   * @return <tt>true</tt> if the contact is connected <tt>false</tt> if the contact is not
   *     connected
   */
  public boolean isShellConnected(ContactSSH sshContact) {
    // a test command may also be run here

    if (isSessionValid(sshContact)) {
      return (sshContact.getShellChannel() != null);
    }

    /*
     * Above should be return(sshContact.getShellChannel() != null
     *                     && sshContact.getShellChannel().isConnected());
     *
     * but incorrect reply from stack for isConnected()
     */

    return false;
  }

  /**
   * Creates a shell channel to the remote machine a new jsch session is also created if the current
   * one is invalid
   *
   * @param sshContact the contact of the remote machine
   * @param firstMessage the first message
   */
  public void connectShell(final ContactSSH sshContact, final Message firstMessage) {
    sshContact.setConnectionInProgress(true);

    final UIService uiService = this.uiService;

    final Thread newConnection =
        new Thread(
            (new Runnable() {
              public void run() {
                OperationSetPersistentPresenceSSHImpl persistentPresence =
                    (OperationSetPersistentPresenceSSHImpl)
                        sshContact.getParentPresenceOperationSet();

                persistentPresence.changeContactPresenceStatus(
                    sshContact, SSHStatusEnum.CONNECTING);

                try {
                  if (!isSessionValid(sshContact)) createSSHSessionAndLogin(sshContact);

                  createShellChannel(sshContact);

                  // initalizing the reader and writers of ssh contact

                  persistentPresence.changeContactPresenceStatus(
                      sshContact, SSHStatusEnum.CONNECTED);

                  showWelcomeMessage(sshContact);

                  sshContact.setMessageType(sshContact.CONVERSATION_MESSAGE_RECEIVED);

                  sshContact.setConnectionInProgress(false);

                  Thread.sleep(1500);

                  sshContact.setCommandSent(true);

                  basicInstantMessaging.sendInstantMessage(sshContact, firstMessage);
                }
                // rigoruos Exception Checking in future
                catch (Exception ex) {
                  persistentPresence.changeContactPresenceStatus(
                      sshContact, SSHStatusEnum.NOT_AVAILABLE);

                  ex.printStackTrace();
                } finally {
                  sshContact.setConnectionInProgress(false);
                }
              }
            }));

    newConnection.start();
  }

  /**
   * Creates a channel for shell type in the current session channel types = shell, sftp, exec(X
   * forwarding), direct-tcpip(stream forwarding) etc
   *
   * @param sshContact ID of SSH Contact
   */
  public void createShellChannel(ContactSSH sshContact) throws IOException {
    try {
      Channel shellChannel = sshContact.getSSHSession().openChannel("shell");

      // initalizing the reader and writers of ssh contact
      sshContact.initializeShellIO(shellChannel.getInputStream(), shellChannel.getOutputStream());

      ((ChannelShell) shellChannel)
          .setPtyType(sshContact.getSSHConfigurationForm().getTerminalType());

      // initializing the shell
      shellChannel.connect(1000);

      sshContact.setShellChannel(shellChannel);

      sshContact.sendLine("export PS1=");
    } catch (JSchException ex) {
      sshContact.setSSHSession(null);
      throw new IOException("Unable to create shell channel to remote" + " server");
    }
  }

  /**
   * Closes the Shell channel are associated IO Streams
   *
   * @param sshContact ID of SSH Contact
   */
  public void closeShellChannel(ContactSSH sshContact) throws JSchException, IOException {
    sshContact.closeShellIO();
    sshContact.getShellChannel().disconnect();
    sshContact.setShellChannel(null);
  }

  /**
   * Creates a SSH Session with a remote machine and tries to login according to the details
   * specified by Contact An appropriate message is shown to the end user in case the login fails
   *
   * @param sshContact ID of SSH Contact
   * @throws JSchException if a JSch is unable to create a SSH Session with the remote machine
   * @throws InterruptedException if the thread is interrupted before session connected or is timed
   *     out
   * @throws OperationFailedException if not of above reasons :-)
   */
  public void createSSHSessionAndLogin(ContactSSH sshContact)
      throws JSchException, OperationFailedException, InterruptedException {
    logger.info("Creating a new SSH Session to " + sshContact.getHostName());

    // creating a new JSch Stack identifier for contact
    JSch jsch = new JSch();

    String knownHosts = (String) accountID.getAccountProperties().get("KNOWN_HOSTS_FILE");

    if (!knownHosts.equals("Optional")) jsch.setKnownHosts(knownHosts);

    String identitiyKey = (String) accountID.getAccountProperties().get("IDENTITY_FILE");

    String userName = sshContact.getUserName();

    // use the name of system user if the contact has not supplied SSH
    // details
    if (userName.equals("")) userName = System.getProperty("user.name");

    if (!identitiyKey.equals("Optional")) jsch.addIdentity(identitiyKey);

    // creating a new session for the contact
    Session session =
        jsch.getSession(
            userName, sshContact.getHostName(), sshContact.getSSHConfigurationForm().getPort());

    /**
     * Creating and associating User Info with the session User Info passes authentication from
     * sshContact to SSH Stack
     */
    SSHUserInfo sshUserInfo = new SSHUserInfo(sshContact);

    session.setUserInfo(sshUserInfo);

    /** initializing the session */
    session.connect(connectionTimeout);

    int count = 0;

    // wait for session to get connected
    while (!session.isConnected() && count <= 30000) {
      Thread.sleep(1000);
      count += 1000;
      logger.trace("SSH:" + sshContact.getHostName() + ": Sleep zzz .. ");
    }

    // if timeout have exceeded
    if (count > 30000) {
      sshContact.setSSHSession(null);
      JOptionPane.showMessageDialog(
          null, "SSH Connection attempt to " + sshContact.getHostName() + " timed out");

      // error codes are not defined yet
      throw new OperationFailedException(
          "SSH Connection attempt to " + sshContact.getHostName() + " timed out", 2);
    }

    sshContact.setJSch(jsch);
    sshContact.setSSHSession(session);

    logger.info("A new SSH Session to " + sshContact.getHostName() + " Created");
  }

  /**
   * Closes the SSH Session associated with the contact
   *
   * @param sshContact ID of SSH Contact
   */
  void closeSSHSession(ContactSSH sshContact) {
    sshContact.getSSHSession().disconnect();
    sshContact.setSSHSession(null);
  }

  /**
   * Presents the login welcome message to user
   *
   * @param sshContact ID of SSH Contact
   */
  public void showWelcomeMessage(ContactSSH sshContact) throws IOException {
    /*      //sending the command
            sshContact.sendLine(testCommand);

            String reply = "", line = "";

            // message is extracted until the test Command ie echoed back
            while(line.indexOf(testCommand) == -1)
            {
                reply += line + "\n";
                line = sshContact.getLine();
            }

            uiService.getPopupDialog().showMessagePopupDialog
                    (reply,"Message from " + sshContact.getDisplayName(),
                    uiService.getPopupDialog().INFORMATION_MESSAGE);

            if(line.startsWith(testCommand))
                while(!sshContact.getLine().contains(testCommand));

            //one line output of testCommand
            sshContact.getLine();
    */
    logger.debug("SSH: Welcome message shown");
  }

  /**
   * Returns a reference to UIServce for accessing UI related services
   *
   * @return uiService a reference to UIService
   */
  public static UIService getUIService() {
    return uiService;
  }

  /**
   * Registers the specified listener with this provider so that it would receive notifications on
   * changes of its state or other properties such as its local address and display name.
   *
   * @param listener the listener to register.
   */
  public void addRegistrationStateChangeListener(RegistrationStateChangeListener listener) {
    synchronized (registrationStateListeners) {
      if (!registrationStateListeners.contains(listener)) registrationStateListeners.add(listener);
    }
  }

  /**
   * Removes the specified registration listener so that it won't receive further notifications when
   * our registration state changes.
   *
   * @param listener the listener to remove.
   */
  public void removeRegistrationStateChangeListener(RegistrationStateChangeListener listener) {
    synchronized (registrationStateListeners) {
      registrationStateListeners.remove(listener);
    }
  }

  /**
   * Creates a <tt>RegistrationStateChangeEvent</tt> corresponding to the specified old and new
   * states and notifies all currently registered listeners.
   *
   * @param oldState the state that the provider had before the change occurred
   * @param newState the state that the provider is currently in.
   * @param reasonCode a value corresponding to one of the REASON_XXX fields of the
   *     RegistrationStateChangeEvent class, indicating the reason for this state transition.
   * @param reason a String further explaining the reason code or null if no such explanation is
   *     necessary.
   */
  private void fireRegistrationStateChanged(
      RegistrationState oldState, RegistrationState newState, int reasonCode, String reason) {
    RegistrationStateChangeEvent event =
        new RegistrationStateChangeEvent(this, oldState, newState, reasonCode, reason);

    logger.debug(
        "Dispatching " + event + " to " + registrationStateListeners.size() + " listeners.");

    Iterator listeners = null;
    synchronized (registrationStateListeners) {
      listeners = new ArrayList(registrationStateListeners).iterator();
    }

    while (listeners.hasNext()) {
      RegistrationStateChangeListener listener = (RegistrationStateChangeListener) listeners.next();

      listener.registrationStateChanged(event);
    }

    logger.trace("Done.");
  }

  /**
   * Returns the AccountID that uniquely identifies the account represented by this instance of the
   * ProtocolProviderService.
   *
   * @return the id of the account represented by this provider.
   */
  public AccountID getAccountID() {
    return accountID;
  }

  /**
   * Returns the operation set corresponding to the specified class or null if this operation set is
   * not supported by the provider implementation.
   *
   * @param opsetClass the <tt>Class</tt> of the operation set that we're looking for.
   * @return returns an OperationSet of the specified <tt>Class</tt> if the undelying implementation
   *     supports it or null otherwise.
   */
  public OperationSet getOperationSet(Class opsetClass) {
    return (OperationSet) getSupportedOperationSets().get(opsetClass.getName());
  }

  /**
   * Returns the short name of the protocol that the implementation of this provider is based upon
   * (like SIP, Jabber, ICQ/AIM, or others for example).
   *
   * @return a String containing the short name of the protocol this service is implementing (most
   *     often that would be a name in ProtocolNames).
   */
  public String getProtocolName() {
    return SSH_PROTOCOL_NAME;
  }

  /**
   * Returns the protocol display name. This is the name that would be used by the GUI to display
   * the protocol name.
   *
   * @return a String containing the display name of the protocol this service is implementing
   */
  public String getProtocolDisplayName() {
    return SSH_PROTOCOL_NAME;
  }

  /**
   * Returns the state of the registration of this protocol provider with the corresponding
   * registration service.
   *
   * @return ProviderRegistrationState
   */
  public RegistrationState getRegistrationState() {
    return currentRegistrationState;
  }

  /**
   * Returns an array containing all operation sets supported by the current implementation.
   *
   * @return a java.util.Map containing instance of all supported operation sets mapped against
   *     their class names (e.g. OperationSetPresence.class.getName()) .
   */
  public Map getSupportedOperationSets() {
    // Copy the map so that the caller is not able to modify it.
    return (Map) supportedOperationSets.clone();
  }

  /**
   * Indicates whether or not this provider is registered
   *
   * @return true if the provider is currently registered and false otherwise.
   */
  public boolean isRegistered() {
    return currentRegistrationState.equals(RegistrationState.REGISTERED);
  }

  /**
   * Starts the registration process.
   *
   * @param authority the security authority that will be used for resolving any security challenges
   *     that may be returned during the registration or at any moment while wer're registered.
   * @throws OperationFailedException with the corresponding code it the registration fails for some
   *     reason (e.g. a networking error or an implementation problem).
   */
  public void register(SecurityAuthority authority) throws OperationFailedException {
    RegistrationState oldState = currentRegistrationState;
    currentRegistrationState = RegistrationState.REGISTERED;

    // get a reference to UI Service via its Service Reference
    ppUIServiceRef = SSHActivator.getBundleContext().getServiceReference(UIService.class.getName());

    uiService = (UIService) SSHActivator.getBundleContext().getService(ppUIServiceRef);

    fireRegistrationStateChanged(
        oldState, currentRegistrationState, RegistrationStateChangeEvent.REASON_USER_REQUEST, null);
  }

  /**
   * Makes the service implementation close all open sockets and release any resources that it might
   * have taken and prepare for shutdown/garbage collection.
   */
  public void shutdown() {
    if (!isInitialized) {
      return;
    }
    logger.trace("Killing the SSH Protocol Provider.");

    if (isRegistered()) {
      try {
        // do the unregistration
        unregister();
      } catch (OperationFailedException ex) {
        // we're shutting down so we need to silence the exception here
        logger.error("Failed to properly unregister before shutting down. " + getAccountID(), ex);
      }
    }

    isInitialized = false;
  }

  /**
   * Ends the registration of this protocol provider with the current registration service.
   *
   * @throws OperationFailedException with the corresponding code it the registration fails for some
   *     reason (e.g. a networking error or an implementation problem).
   */
  public void unregister() throws OperationFailedException {
    RegistrationState oldState = currentRegistrationState;
    currentRegistrationState = RegistrationState.UNREGISTERED;

    fireRegistrationStateChanged(
        oldState, currentRegistrationState, RegistrationStateChangeEvent.REASON_USER_REQUEST, null);
  }

  /**
   * Returns the ssh protocol icon.
   *
   * @return the ssh protocol icon
   */
  public ProtocolIcon getProtocolIcon() {
    return sshIcon;
  }
}
Exemplo n.º 15
0
  /** Builds the Stylesheet panel. */
  protected JPanel buildStylesheetPanel() {
    JGridBagPanel.InsetsManager im =
        new JGridBagPanel.InsetsManager() {
          protected Insets i1 = new Insets(5, 5, 0, 0);
          protected Insets i2 = new Insets(5, 0, 0, 0);
          protected Insets i3 = new Insets(0, 5, 0, 0);
          protected Insets i4 = new Insets(0, 0, 0, 0);

          public Insets getInsets(int x, int y) {
            if (y >= 1 && y <= 5) {
              return x == 0 ? i2 : i1;
            }
            return x == 0 ? i4 : i3;
          }
        };

    JGridBagPanel p = new JGridBagPanel(im);
    p.setBorder(BorderFactory.createEmptyBorder(16, 16, 16, 16));

    userStylesheetEnabled =
        new JCheckBox(Resources.getString(PREFERENCE_KEY_LABEL_ENABLE_USER_STYLESHEET));
    userStylesheetEnabled.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            boolean b = userStylesheetEnabled.isSelected();
            userStylesheetLabel.setEnabled(b);
            userStylesheet.setEnabled(b);
            userStylesheetBrowse.setEnabled(b);
          }
        });

    userStylesheetLabel = new JLabel(Resources.getString(PREFERENCE_KEY_LABEL_USER_STYLESHEET));
    userStylesheet = new JTextField();
    userStylesheetBrowse = new JButton(Resources.getString(PREFERENCE_KEY_LABEL_BROWSE));
    userStylesheetBrowse.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            File f = null;
            if (Platform.isOSX) {
              FileDialog fileDialog =
                  new FileDialog(
                      (Frame) getOwner(), Resources.getString(PREFERENCE_KEY_BROWSE_TITLE));
              fileDialog.setVisible(true);
              String filename = fileDialog.getFile();
              if (filename != null) {
                String dirname = fileDialog.getDirectory();
                f = new File(dirname, filename);
              }
            } else {
              JFileChooser fileChooser = new JFileChooser(new File("."));
              fileChooser.setDialogTitle(Resources.getString(PREFERENCE_KEY_BROWSE_TITLE));
              fileChooser.setFileHidingEnabled(false);

              int choice = fileChooser.showOpenDialog(PreferenceDialog.this);
              if (choice == JFileChooser.APPROVE_OPTION) {
                f = fileChooser.getSelectedFile();
              }
            }
            if (f != null) {
              try {
                userStylesheet.setText(f.getCanonicalPath());
              } catch (IOException ex) {
              }
            }
          }
        });

    JLabel mediaLabel = new JLabel(Resources.getString(PREFERENCE_KEY_LABEL_CSS_MEDIA_TYPES));
    mediaLabel.setVerticalAlignment(SwingConstants.TOP);
    mediaList = new JList();
    mediaList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    mediaList.setModel(mediaListModel);
    mediaList.addListSelectionListener(
        new ListSelectionListener() {
          public void valueChanged(ListSelectionEvent e) {
            updateMediaListButtons();
          }
        });
    mediaListModel.addListDataListener(
        new ListDataListener() {
          public void contentsChanged(ListDataEvent e) {
            updateMediaListButtons();
          }

          public void intervalAdded(ListDataEvent e) {
            updateMediaListButtons();
          }

          public void intervalRemoved(ListDataEvent e) {
            updateMediaListButtons();
          }
        });
    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBorder(BorderFactory.createLoweredBevelBorder());
    scrollPane.getViewport().add(mediaList);

    JButton addButton = new JButton(Resources.getString(PREFERENCE_KEY_LABEL_ADD));
    addButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            CSSMediaPanel.AddMediumDialog dialog =
                new CSSMediaPanel.AddMediumDialog(PreferenceDialog.this);
            dialog.pack();
            dialog.setVisible(true);

            if (dialog.getReturnCode() == CSSMediaPanel.AddMediumDialog.CANCEL_OPTION
                || dialog.getMedium() == null) {
              return;
            }

            String medium = dialog.getMedium().trim();
            if (medium.length() == 0 || mediaListModel.contains(medium)) {
              return;
            }

            for (int i = 0; i < mediaListModel.size() && medium != null; ++i) {
              String s = (String) mediaListModel.getElementAt(i);
              int c = medium.compareTo(s);
              if (c == 0) {
                medium = null;
              } else if (c < 0) {
                mediaListModel.insertElementAt(medium, i);
                medium = null;
              }
            }
            if (medium != null) {
              mediaListModel.addElement(medium);
            }
          }
        });

    mediaListRemoveButton = new JButton(Resources.getString(PREFERENCE_KEY_LABEL_REMOVE));
    mediaListRemoveButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            int index = mediaList.getSelectedIndex();
            mediaList.clearSelection();
            if (index >= 0) {
              mediaListModel.removeElementAt(index);
            }
          }
        });

    mediaListClearButton = new JButton(Resources.getString(PREFERENCE_KEY_LABEL_CLEAR));
    mediaListClearButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            mediaList.clearSelection();
            mediaListModel.removeAllElements();
          }
        });

    p.add(userStylesheetEnabled, 1, 0, 2, 1, WEST, NONE, 0, 0);
    p.add(userStylesheetLabel, 0, 1, 1, 1, EAST, NONE, 0, 0);
    p.add(userStylesheet, 1, 1, 1, 1, WEST, HORIZONTAL, 1, 0);
    p.add(userStylesheetBrowse, 2, 1, 1, 1, WEST, HORIZONTAL, 0, 0);
    p.add(mediaLabel, 0, 2, 1, 1, EAST, VERTICAL, 0, 0);
    p.add(scrollPane, 1, 2, 1, 4, WEST, BOTH, 1, 1);
    p.add(new JPanel(), 2, 2, 1, 1, WEST, BOTH, 0, 1);
    p.add(addButton, 2, 3, 1, 1, SOUTHWEST, HORIZONTAL, 0, 0);
    p.add(mediaListRemoveButton, 2, 4, 1, 1, SOUTHWEST, HORIZONTAL, 0, 0);
    p.add(mediaListClearButton, 2, 5, 1, 1, SOUTHWEST, HORIZONTAL, 0, 0);

    return p;
  }
Exemplo n.º 16
0
  /** Builds the Security panel. */
  protected JPanel buildSecurityPanel() {
    JGridBagPanel.InsetsManager im =
        new JGridBagPanel.InsetsManager() {
          protected Insets i1 = new Insets(5, 5, 0, 0);
          protected Insets i2 = new Insets(5, 0, 0, 0);
          protected Insets i3 = new Insets(0, 5, 0, 0);
          protected Insets i4 = new Insets(0, 0, 0, 0);

          public Insets getInsets(int x, int y) {
            if (y == 1 || y == 3 || y == 5 || y == 6) {
              return x == 0 ? i2 : i1;
            }
            return x == 0 ? i4 : i3;
          }
        };

    JGridBagPanel p = new JGridBagPanel(im);
    p.setBorder(BorderFactory.createEmptyBorder(16, 16, 16, 16));

    enforceSecureScripting =
        new JCheckBox(Resources.getString(PREFERENCE_KEY_LABEL_ENFORCE_SECURE_SCRIPTING));
    enforceSecureScripting.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            boolean b = enforceSecureScripting.isSelected();
            grantScriptFileAccess.setEnabled(b);
            grantScriptNetworkAccess.setEnabled(b);
          }
        });

    JLabel grantScript =
        new JLabel(Resources.getString(PREFERENCE_KEY_LABEL_GRANT_SCRIPTS_ACCESS_TO));
    grantScript.setVerticalAlignment(SwingConstants.TOP);
    grantScript.setOpaque(true);
    grantScriptFileAccess = new JCheckBox(Resources.getString(PREFERENCE_KEY_LABEL_FILE_SYSTEM));
    grantScriptNetworkAccess = new JCheckBox(Resources.getString(PREFERENCE_KEY_LABEL_ALL_NETWORK));

    JLabel loadScripts = new JLabel(Resources.getString(PREFERENCE_KEY_LABEL_LOAD_SCRIPTS));
    loadScripts.setVerticalAlignment(SwingConstants.TOP);
    loadJava = new JCheckBox(Resources.getString(PREFERENCE_KEY_LABEL_JAVA_JAR_FILES));
    loadEcmascript = new JCheckBox(Resources.getString(PREFERENCE_KEY_LABEL_ECMASCRIPT));

    String[] origins = {
      Resources.getString(PREFERENCE_KEY_LABEL_ORIGIN_ANY),
      Resources.getString(PREFERENCE_KEY_LABEL_ORIGIN_DOCUMENT),
      Resources.getString(PREFERENCE_KEY_LABEL_ORIGIN_EMBEDDED),
      Resources.getString(PREFERENCE_KEY_LABEL_ORIGIN_NONE)
    };
    JLabel scriptOriginLabel =
        new JLabel(Resources.getString(PREFERENCE_KEY_LABEL_ALLOWED_SCRIPT_ORIGIN));
    allowedScriptOrigin = new JComboBox(origins);
    JLabel resourceOriginLabel =
        new JLabel(Resources.getString(PREFERENCE_KEY_LABEL_ALLOWED_RESOURCE_ORIGIN));
    allowedResourceOrigin = new JComboBox(origins);

    p.add(enforceSecureScripting, 1, 0, 1, 1, WEST, NONE, 1, 0);
    p.add(grantScript, 0, 1, 1, 1, EAST, NONE, 1, 0);
    p.add(grantScriptFileAccess, 1, 1, 1, 1, WEST, NONE, 1, 0);
    p.add(grantScriptNetworkAccess, 1, 2, 1, 1, WEST, NONE, 1, 0);
    p.add(loadScripts, 0, 3, 1, 1, EAST, NONE, 1, 0);
    p.add(loadJava, 1, 3, 1, 1, WEST, NONE, 1, 0);
    p.add(loadEcmascript, 1, 4, 1, 1, WEST, NONE, 1, 0);
    p.add(scriptOriginLabel, 0, 5, 1, 1, EAST, NONE, 1, 0);
    p.add(allowedScriptOrigin, 1, 5, 1, 1, WEST, NONE, 1, 0);
    p.add(resourceOriginLabel, 0, 6, 1, 1, EAST, NONE, 1, 0);
    p.add(allowedResourceOrigin, 1, 6, 1, 1, WEST, NONE, 1, 0);

    return p;
  }
Exemplo n.º 17
0
  /** Builds the General panel. */
  protected JPanel buildGeneralPanel() {
    JGridBagPanel.InsetsManager im =
        new JGridBagPanel.InsetsManager() {
          protected Insets i1 = new Insets(5, 5, 0, 0);
          protected Insets i2 = new Insets(5, 0, 0, 0);
          protected Insets i3 = new Insets(0, 5, 0, 0);
          protected Insets i4 = new Insets(0, 0, 0, 0);

          public Insets getInsets(int x, int y) {
            if (y == 4 || y == 9) {
              return x == 0 ? i2 : i1;
            }
            return x == 0 ? i4 : i3;
          }
        };

    JGridBagPanel p = new JGridBagPanel(im);
    p.setBorder(BorderFactory.createEmptyBorder(16, 16, 16, 16));

    JLabel renderingLabel = new JLabel(Resources.getString(PREFERENCE_KEY_LABEL_RENDERING_OPTIONS));
    enableDoubleBuffering =
        new JCheckBox(Resources.getString(PREFERENCE_KEY_LABEL_ENABLE_DOUBLE_BUFFERING));
    enableDoubleBuffering.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            showRendering.setEnabled(enableDoubleBuffering.isSelected());
          }
        });
    showRendering = new JCheckBox(Resources.getString(PREFERENCE_KEY_LABEL_SHOW_RENDERING));
    Insets in = showRendering.getMargin();
    showRendering.setMargin(new Insets(in.top, in.left + 24, in.bottom, in.right));
    selectionXorMode = new JCheckBox(Resources.getString(PREFERENCE_KEY_LABEL_SELECTION_XOR_MODE));
    autoAdjustWindow = new JCheckBox(Resources.getString(PREFERENCE_KEY_LABEL_AUTO_ADJUST_WINDOW));
    JLabel animLabel =
        new JLabel(Resources.getString(PREFERENCE_KEY_LABEL_ANIMATION_RATE_LIMITING));
    animationLimitCPU =
        new JRadioButton(Resources.getString(PREFERENCE_KEY_LABEL_ANIMATION_LIMIT_CPU));
    JPanel cpuPanel = new JPanel();
    cpuPanel.setLayout(new FlowLayout(FlowLayout.LEADING, 3, 0));
    cpuPanel.setBorder(BorderFactory.createEmptyBorder(0, 24, 0, 0));
    animationLimitCPUAmount = new JTextField();
    animationLimitCPUAmount.setPreferredSize(new Dimension(40, 20));
    cpuPanel.add(animationLimitCPUAmount);
    animationLimitCPULabel = new JLabel(Resources.getString(PREFERENCE_KEY_LABEL_PERCENT));
    cpuPanel.add(animationLimitCPULabel);
    animationLimitFPS =
        new JRadioButton(Resources.getString(PREFERENCE_KEY_LABEL_ANIMATION_LIMIT_FPS));
    JPanel fpsPanel = new JPanel();
    fpsPanel.setLayout(new FlowLayout(FlowLayout.LEADING, 3, 0));
    fpsPanel.setBorder(BorderFactory.createEmptyBorder(0, 24, 0, 0));
    animationLimitFPSAmount = new JTextField();
    animationLimitFPSAmount.setPreferredSize(new Dimension(40, 20));
    fpsPanel.add(animationLimitFPSAmount);
    animationLimitFPSLabel = new JLabel(Resources.getString(PREFERENCE_KEY_LABEL_FPS));
    fpsPanel.add(animationLimitFPSLabel);
    animationLimitUnlimited =
        new JRadioButton(Resources.getString(PREFERENCE_KEY_LABEL_ANIMATION_LIMIT_UNLIMITED));
    ButtonGroup g = new ButtonGroup();
    g.add(animationLimitCPU);
    g.add(animationLimitFPS);
    g.add(animationLimitUnlimited);
    ActionListener l =
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            boolean b = animationLimitCPU.isSelected();
            animationLimitCPUAmount.setEnabled(b);
            animationLimitCPULabel.setEnabled(b);
            b = animationLimitFPS.isSelected();
            animationLimitFPSAmount.setEnabled(b);
            animationLimitFPSLabel.setEnabled(b);
          }
        };
    animationLimitCPU.addActionListener(l);
    animationLimitFPS.addActionListener(l);
    animationLimitUnlimited.addActionListener(l);
    JLabel otherLabel = new JLabel(Resources.getString(PREFERENCE_KEY_LABEL_OTHER_OPTIONS));
    showDebugTrace = new JCheckBox(Resources.getString(PREFERENCE_KEY_LABEL_SHOW_DEBUG_TRACE));
    isXMLParserValidating =
        new JCheckBox(Resources.getString(PREFERENCE_KEY_LABEL_IS_XML_PARSER_VALIDATING));

    p.add(renderingLabel, 0, 0, 1, 1, EAST, NONE, 0, 0);
    p.add(enableDoubleBuffering, 1, 0, 1, 1, WEST, NONE, 0, 0);
    p.add(showRendering, 1, 1, 1, 1, WEST, NONE, 0, 0);
    p.add(autoAdjustWindow, 1, 2, 1, 1, WEST, NONE, 0, 0);
    p.add(selectionXorMode, 1, 3, 1, 1, WEST, NONE, 0, 0);
    p.add(animLabel, 0, 4, 1, 1, EAST, NONE, 0, 0);
    p.add(animationLimitCPU, 1, 4, 1, 1, WEST, NONE, 0, 0);
    p.add(cpuPanel, 1, 5, 1, 1, WEST, NONE, 0, 0);
    p.add(animationLimitFPS, 1, 6, 1, 1, WEST, NONE, 0, 0);
    p.add(fpsPanel, 1, 7, 1, 1, WEST, NONE, 0, 0);
    p.add(animationLimitUnlimited, 1, 8, 1, 1, WEST, NONE, 0, 0);
    p.add(otherLabel, 0, 9, 1, 1, EAST, NONE, 0, 0);
    p.add(showDebugTrace, 1, 9, 1, 1, WEST, NONE, 0, 0);
    p.add(isXMLParserValidating, 1, 10, 1, 1, WEST, NONE, 0, 0);

    return p;
  }
 /**
  * Return the string for add existing account button.
  *
  * @return the string for add existing account button.
  */
 protected String getExistingAccountLabel() {
   return Resources.getString("plugin.jabberaccregwizz.EXISTING_ACCOUNT");
 }
 /**
  * Implements the <code>AccountRegistrationWizard.getProtocolName</code> method. Returns the
  * protocol name for this wizard.
  *
  * @return String
  */
 public String getProtocolName() {
   return Resources.getString("plugin.gibberishaccregwizz.PROTOCOL_NAME");
 }
 /**
  * Return the string for add existing account button.
  *
  * @return the string for add existing account button.
  */
 protected String getCreateAccountButtonLabel() {
   return Resources.getString("plugin.jabberaccregwizz.NEW_ACCOUNT_TITLE");
 }
  /**
   * This method will use reflection to log an object to the specified logger using the provided log
   * level. The object is reflected upon looking for "get*" and "is*" methods JavaBean pattern. The
   * methods are invoked and the results written to the log. If the result is another object, the
   * reference information will be displayed - all this is good for is to determine if the property
   * is null or not. If the logger parameter is not enabled for the level requested, nothing will be
   * written.
   *
   * @param obj Object to be logged.
   * @param logger Logger to which the information will be written.
   * @param level Logging level to be used; if null, the DEFAULT_LEVEL value will be used.
   * @param recursive True if recursive logging should be used.
   * @param indentLevel Number of levels to indent for printing.
   * @return String representation of the object.
   */
  public static String logObject(
      Object obj, Logger logger, Level level, boolean recursive, int indentLevel) {
    StringBuilder buf = new StringBuilder();
    String indentStr = "    "; // used for formatting pretty printing
    String indent = ""; // used for formatting pretty printing
    String prefix = "--- "; // used for formatting pretty printing
    String seperator = ": "; // used for formatting pretty printing

    indentLevel = (indentLevel < 1 ? 1 : indentLevel);

    for (int i = 1; i < indentLevel; i++) {
      indent += indentStr;
    }

    indent += indentLevel;

    // if no level is provided, it will use the default
    level = (level == null ? DEFAULT_LEVEL : level);

    boolean isEnabled = (logger != null ? logger.isEnabledFor(level) : false);
    if ((obj != null) && (logger != null) && isEnabled) {
      buf.append(
          "\n"
              + indent
              + prefix
              + Resources.getString("loggingInfo", obj.getClass().getName())
              + "\n");

      Method[] methods = obj.getClass().getMethods();

      for (Method m : methods) {
        String methodName = m.getName();
        boolean hasParams = (m.getParameterTypes().length > 0);

        // just process methods that match the javaBean pattern
        if ((methodName.startsWith("get") || methodName.startsWith("is")) && !hasParams) {
          int start = (methodName.startsWith("get") ? 3 : 2);
          String label = indent + prefix + methodName.substring(start) + seperator;

          try {
            Object o = m.invoke(obj, new Object[] {});

            if (recursive && (o != null) && o.getClass().getName().startsWith("com.servicemesh")) {
              buf.append(label + "\n");
              buf.append(logObject(o, logger, level, recursive, (indentLevel + 1)));
            } else {
              // do not print private key value to log
              if (methodName.toLowerCase().contains("privatekey")) {
                buf.append(label);
                buf.append(AWSUtil.maskPrivateKey((String) o));
              } else {
                buf.append(label);
                buf.append(o);
              }
            }
          } catch (Exception e) {
            buf.append(e.getMessage());
          }

          buf.append("\n");
        }
      }

      logger.log(level, buf.toString());
    }

    return buf.toString();
  }
 /**
  * Implements the <code>AccountRegistrationWizard.getProtocolName</code> method. Returns the
  * protocol name for this wizard.
  *
  * @return String
  */
 @Override
 public String getProtocolName() {
   return Resources.getString("plugin.jabberaccregwizz.PROTOCOL_NAME");
 }
  /**
   * Creates an instance of <tt>GibberishAccountRegistrationWizard</tt>.
   *
   * @param wizardContainer the wizard container, where this wizard is added
   */
  public GibberishAccountRegistrationWizard(WizardContainer wizardContainer) {
    setWizardContainer(wizardContainer);

    wizardContainer.setFinishButtonText(Resources.getString("service.gui.SIGN_IN"));
  }
 /**
  * Returns the display label used for the jabber id field.
  *
  * @return the jabber id display label string.
  */
 protected String getUsernameLabel() {
   return Resources.getString("plugin.jabberaccregwizz.USERNAME");
 }
 /**
  * Implements the <code>AccountRegistrationWizard.getProtocolDescription
  * </code> method. Returns the description of the protocol for this wizard.
  *
  * @return String
  */
 public String getProtocolDescription() {
   return Resources.getString("plugin.gibberishaccregwizz.PROTOCOL_DESCRIPTION");
 }
 /**
  * Return the string for create new account button.
  *
  * @return the string for create new account button.
  */
 protected String getCreateAccountLabel() {
   return Resources.getString("plugin.jabberaccregwizz.REGISTER_NEW_ACCOUNT_TEXT");
 }