Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.IOException;

import javax.management.InstanceNotFoundException;
import javax.management.MBeanException;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
import javax.management.ReflectionException;

public class Main {
    private static MBeanServerConnection connection;
    private static ObjectName defaultAuthenticator;

    public static void resetUserPassword(String username, String newPassword) {
        try {
            if (!username.equalsIgnoreCase("weblogic")) {
                connection.invoke(defaultAuthenticator, "resetUserPassword", new Object[] { username, newPassword },
                        new String[] { "java.lang.String", "java.lang.String" });
            }
        } catch (InstanceNotFoundException | MBeanException | ReflectionException | IOException e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }
    }
}