Implementing Java interfaces

You can find information about implementing the Java interfaces as part of the user-defined access in a credential management system.

You must be familiar with implementing Java interfaces and building an executable JAR file.

The PasswordProvider.java interface

Refer to the following example for the guidance on implementing the PasswordProvider.java interface:
/*******************************************************************************
 * Licensed Materials - Property of HCL
 * (c) Copyright HCL Technologies Ltd. 2022. All Rights Reserved.
 *
 * Note to U.S. Government Users Restricted Rights:
 * Use, duplication or disclosure restricted by GSA ADP Schedule
 * Contract with IBM Corp.
 *******************************************************************************/
package com.ghc.password.provider;

/**
 * Support for allowing users to provide configuration data which can be
 * resolved to an actual password at runtime.
 */
public interface PasswordProvider {

   /**
    * Create an instance of a UI implementation that can provide serialized
    * config which can then be resolved to a password at runtime.
    * 
    * @param listener
    *           that should be notified when a user makes changes to the UI
    *           content.
    * @return the UI implementation.
    */
   PasswordProviderGUI createGUI();

   /**
    * Given the serialized data that was persisted from the user interface,
    * resolve this into the actual password that should be used.
    * 
    * @param config
    *           serialized data from UI
    * @return the password corresponding to the config.
    */
   String resolvePassword(String config);

}

The PasswordProviderGUI.java interface

Refer to the following example for the guidance on implementing the PasswordProviderGUI.java interface:
/*******************************************************************************
 * Licensed Materials - Property of HCL
 * (c) Copyright HCL Technologies Ltd. 2022. All Rights Reserved.
 *
 * Note to U.S. Government Users Restricted Rights:
 * Use, duplication or disclosure restricted by GSA ADP Schedule
 * Contract with IBM Corp.
 *******************************************************************************/
package com.ghc.password.provider;

import javax.swing.JComponent;
import javax.swing.event.DocumentListener;

/**
 * Provision of UI allowing users to enter how a password can be obtained.
 */
public interface PasswordProviderGUI {

   /**
    * @return a UI component that users can supply input via.
    */
   JComponent getComponent();

   /**
    * Update the UI with previously saved data, note that this should not
    * trigger any document listeners.
    * 
    * @param config
    *           the previous data.
    */
   void setConfig(String config);

   /**
    * @return the UI contents as a serialized string.
    */
   String getConfig();

   /**
    * Add a document listner that should be notified if the serialised form
    * would change as a result of the user editing the value(s)
    * 
    * @param listener
    */
   void addDocumentListener(DocumentListener listener);

}

The PasswordProviderFactory.java interface

Refer to the following example for the guidance on implementing the PasswordProviderFactory.java interface:
/*******************************************************************************
 * Licensed Materials - Property of HCL
 * (c) Copyright HCL Technologies Ltd. 2022. All Rights Reserved.
 *
 * Note to U.S. Government Users Restricted Rights:
 * Use, duplication or disclosure restricted by GSA ADP Schedule
 * Contract with IBM Corp.
 *******************************************************************************/
package com.ghc.password.provider;

import com.ghc.tags.TagDataStore;

/**
 * Simple factory interface to bootstrap a password provider implementation.
 */
public interface PasswordProviderFactory {

   /**
    * Create a new instance of the provider
    * 
    * @param tds
    *           access to tags if required
    * @return the provider.
    */
   public PasswordProvider newInstance(TagDataStore tds);
}