@@ -0,0 +1,3054 @@
+package com.blogspot.oraclestack.utilities;%0A%0Aimport java.io.File;%0Aimport java.io.FileInputStream;%0Aimport java.io.FileNotFoundException;%0Aimport java.io.IOException;%0Aimport oracle.iam.platform.OIMClient;%0Aimport oracle.iam.platform.pluginframework.PluginException;%0Aimport oracle.iam.platformservice.api.PlatformService;%0Aimport oracle.iam.platformservice.api.PlatformUtilsService;%0Aimport oracle.iam.platformservice.exception.InvalidCacheCategoryException;%0Aimport oracle.iam.platformservice.exception.PlatformServiceAccessDeniedException;%0A%0A/**%0A * Registers or unregisters an OIM Plug-in.%0A * @author oracle%0A */%0Apublic class PluginRegistration %0A%7B%0A    private final PlatformService platformService;%0A    private final PlatformUtilsService platUtilOps;%0A    %0A    public PluginRegistration(OIMClient oimClient)%0A    %7B%0A        this.platformService = oimClient.getService(PlatformService.class);%0A        this.platUtilOps = oimClient.getService(PlatformUtilsService.class);%0A    %7D%0A    %0A    /**%0A     * Registers an plug-in to OIM%0A     * @param pathToPluginZipFile       Absolute Path to Plug-in zip file%0A     * @throws FileNotFoundException%0A     * @throws IOException%0A     * @throws PlatformServiceAccessDeniedException%0A     * @throws PluginException%0A     * @throws InvalidCacheCategoryException %0A     */%0A    public void registerOIMPlugin(String pathToPluginZipFile) throws FileNotFoundException, IOException, PlatformServiceAccessDeniedException, PluginException, InvalidCacheCategoryException%0A    %7B%0A        FileInputStream fis = null;%0A        %0A        try%0A        %7B%0A            // Zip file conversion to byte%0A            File zipFile = new File(pathToPluginZipFile);%0A            fis = new FileInputStream(zipFile);%0A            int size = (int) zipFile.length();%0A            byte%5B%5D b = new byte%5Bsize%5D;%0A            int bytesRead = fis.read(b, 0, size);%0A            %0A            while (bytesRead %3C size)%0A            %7B%0A                bytesRead += fis.read(b, bytesRead, size - bytesRead);%0A            %7D%0A            %0A            // Register Plugin to OIM%0A            this.platformService.registerPlugin(b);%0A            System.out.println(%22Successfully registered plugin.%22);%0A %0A            // Purge Cache%0A            this.platUtilOps.purgeCache(%22ALL%22);%0A            System.out.println(%22Cache Purged.%22);%0A        %7D%0A        %0A        finally%0A        %7B%0A            if (fis != null)%0A            %7B%0A                fis.close(); %0A            %7D%0A        %7D%0A    %7D%0A    %0A    /**%0A     * Unregister an OIM Plug-in%0A     * @param pluginId          PLUGIN_ID%0A     * @param pluginVersion     PLUGIN_VERSION%0A     * @throws PlatformServiceAccessDeniedException%0A     * @throws InvalidCacheCategoryException%0A     * @throws PluginException %0A     */%0A    public void unRegisterOIMPlugin(String pluginId, String pluginVersion) throws PlatformServiceAccessDeniedException, InvalidCacheCategoryException, PluginException%0A    %7B%0A        // Remove single plugin%0A        this.platformService.unRegisterPlugin(pluginId, pluginVersion);%0A%0A        // Purge Cache;%0A        this.platUtilOps.purgeCache(%22ALL%22);%0A    %7D%0A%7D%0A

Add utility to register and remove OIM plugins