Commit f28e9791 authored by Andre Freyssinet's avatar Andre Freyssinet

JMQ-229: Allows to update the administrator password using the configuration update.

parent 14b323ec
/*
* JORAM: Java(TM) Open Reliable Asynchronous Messaging
* Copyright (C) 2001 - 2019 ScalAgent Distributed Technologies
* Copyright (C) 2001 - 2020 ScalAgent Distributed Technologies
* Copyright (C) 1996 - 2000 Dyade
*
* This library is free software; you can redistribute it and/or
......@@ -334,16 +334,16 @@ public final class AdminTopic extends Topic implements AdminTopicMBean {
Identity identity = adminNot.getIdentity();
try {
//identity.validate();
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG,
"AdminTopic store identity = " + identity);
usersTable.put(identity.getUserName(), identity);
if (adminNot.getProxyId() != null) {
// It's the first boot, registers the administrator proxy
proxiesTable.put(identity.getUserName(), adminNot.getProxyId());
clients.put(adminNot.getProxyId(), new Integer(READWRITE));
}
if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG,
......
......@@ -316,8 +316,7 @@ public class ConnectionManager implements ConnectionManagerMBean {
logger.log(BasicLevel.DEBUG,
"ConnectionManager.init(" + args + ',' + firstTime + ')');
// TODO (AF): Be careful, this default value is saved and retrieved by
// AdminTopic agent.
// TODO (AF): Be careful, this default value is saved and retrieved by AdminTopic agent.
Integer delay = AgentServer.getInteger(AdminCommandConstant.REDELIVERY_DELAY);
if (delay != null) {
logger.log(BasicLevel.FATAL,
......@@ -325,16 +324,11 @@ public class ConnectionManager implements ConnectionManagerMBean {
Queue.setDefaultRedeliveryDelay(delay);
}
if (! firstTime) return;
AdminTopic adminTopic = new AdminTopic();
adminTopic.deploy();
inFlow = AgentServer.getInteger("ConnectionManager.inFlow", inFlow).intValue();
if (args != null) {
String initialAdminName = null;
String initialAdminPass = null;
if (args != null) {
StringTokenizer st = new StringTokenizer(args);
if (st.countTokens() >= 1) {
......@@ -343,16 +337,14 @@ public class ConnectionManager implements ConnectionManagerMBean {
if (st.hasMoreTokens()) {
initialAdminPass = st.nextToken();
}
// AF: deprecated, will be deleted.
if (st.hasMoreTokens()) {
try {
inFlow = Integer.parseInt(st.nextToken());
} catch (Exception exc) {
inFlow = -1;
}
logger.log(BasicLevel.INFO,
"ConnectionManager.init admin=(" + initialAdminName + ',' + initialAdminPass + ')');
}
if (firstTime) {
AdminTopic adminTopic = new AdminTopic();
adminTopic.deploy();
if (initialAdminName != null) {
UserAgent userAgent = new UserAgent(initialAdminName, AgentId.JoramAdminPxStamp);
userAgent.deploy();
......@@ -362,8 +354,23 @@ public class ConnectionManager implements ConnectionManagerMBean {
Identity.getRootIdentityClass(initialAdminName));
AdminNotification adminNot = new AdminNotification(userAgent.getId(), identity);
logger.log(BasicLevel.INFO,
"ConnectionManager.init send adminNot to " + adminTopic.getId());
Channel.sendTo(adminTopic.getId(), adminNot);
}
} else {
if (AgentServer.updatecfg != null) {
// Updates the administrator identity.
Identity identity = createIdentity(Identity.getRootName(initialAdminName),
initialAdminPass,
Identity.getRootIdentityClass(initialAdminName));
AdminNotification adminNot = new AdminNotification(null, identity);
AgentId adminId = new AgentId(AgentServer.getServerId(), AgentServer.getServerId(), AgentId.JoramAdminStamp);
logger.log(BasicLevel.INFO,
"ConnectionManager.init send adminNot to " + adminId);
Channel.sendTo(adminId, adminNot);
}
}
try {
MXWrapper.registerMBean(getCurrentInstance(), "Joram#" + AgentServer.getServerId(), MBEAN_NAME);
......@@ -371,7 +378,6 @@ public class ConnectionManager implements ConnectionManagerMBean {
logger.log(BasicLevel.DEBUG, "registerMBean", e);
}
}
}
/**
* Create an admin Identity.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment