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 * 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 * Copyright (C) 1996 - 2000 Dyade
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
...@@ -334,16 +334,16 @@ public final class AdminTopic extends Topic implements AdminTopicMBean { ...@@ -334,16 +334,16 @@ public final class AdminTopic extends Topic implements AdminTopicMBean {
Identity identity = adminNot.getIdentity(); Identity identity = adminNot.getIdentity();
try { try {
//identity.validate();
if (logger.isLoggable(BasicLevel.DEBUG)) if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, logger.log(BasicLevel.DEBUG,
"AdminTopic store identity = " + identity); "AdminTopic store identity = " + identity);
usersTable.put(identity.getUserName(), identity); usersTable.put(identity.getUserName(), identity);
proxiesTable.put(identity.getUserName(), adminNot.getProxyId()); if (adminNot.getProxyId() != null) {
// It's the first boot, registers the administrator proxy
clients.put(adminNot.getProxyId(), new Integer(READWRITE)); proxiesTable.put(identity.getUserName(), adminNot.getProxyId());
clients.put(adminNot.getProxyId(), new Integer(READWRITE));
}
if (logger.isLoggable(BasicLevel.DEBUG)) if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, logger.log(BasicLevel.DEBUG,
......
...@@ -315,62 +315,68 @@ public class ConnectionManager implements ConnectionManagerMBean { ...@@ -315,62 +315,68 @@ public class ConnectionManager implements ConnectionManagerMBean {
if (logger.isLoggable(BasicLevel.DEBUG)) if (logger.isLoggable(BasicLevel.DEBUG))
logger.log(BasicLevel.DEBUG, logger.log(BasicLevel.DEBUG,
"ConnectionManager.init(" + args + ',' + firstTime + ')'); "ConnectionManager.init(" + args + ',' + firstTime + ')');
// TODO (AF): Be careful, this default value is saved and retrieved by // TODO (AF): Be careful, this default value is saved and retrieved by AdminTopic agent.
// AdminTopic agent.
Integer delay = AgentServer.getInteger(AdminCommandConstant.REDELIVERY_DELAY); Integer delay = AgentServer.getInteger(AdminCommandConstant.REDELIVERY_DELAY);
if (delay != null) { if (delay != null) {
logger.log(BasicLevel.FATAL, logger.log(BasicLevel.FATAL,
"ConnectionManager.setDefaultRedeliveryDelay: " + AdminCommandConstant.REDELIVERY_DELAY + "=" + delay); "ConnectionManager.setDefaultRedeliveryDelay: " + AdminCommandConstant.REDELIVERY_DELAY + "=" + delay);
Queue.setDefaultRedeliveryDelay(delay); Queue.setDefaultRedeliveryDelay(delay);
} }
if (! firstTime) return;
AdminTopic adminTopic = new AdminTopic();
adminTopic.deploy();
inFlow = AgentServer.getInteger("ConnectionManager.inFlow", inFlow).intValue(); inFlow = AgentServer.getInteger("ConnectionManager.inFlow", inFlow).intValue();
String initialAdminName = null;
String initialAdminPass = null;
if (args != null) { if (args != null) {
String initialAdminName = null;
String initialAdminPass = null;
StringTokenizer st = new StringTokenizer(args); StringTokenizer st = new StringTokenizer(args);
if (st.countTokens() >= 1) { if (st.countTokens() >= 1) {
initialAdminName = st.nextToken(); initialAdminName = st.nextToken();
}
if (st.hasMoreTokens()) {
initialAdminPass = st.nextToken();
} }
// AF: deprecated, will be deleted.
if (st.hasMoreTokens()) { if (st.hasMoreTokens()) {
try { initialAdminPass = st.nextToken();
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) { if (initialAdminName != null) {
UserAgent userAgent = new UserAgent(initialAdminName, AgentId.JoramAdminPxStamp); UserAgent userAgent = new UserAgent(initialAdminName, AgentId.JoramAdminPxStamp);
userAgent.deploy(); userAgent.deploy();
Identity identity = createIdentity(Identity.getRootName(initialAdminName), Identity identity = createIdentity(Identity.getRootName(initialAdminName),
initialAdminPass, initialAdminPass,
Identity.getRootIdentityClass(initialAdminName)); Identity.getRootIdentityClass(initialAdminName));
AdminNotification adminNot = new AdminNotification(userAgent.getId(), identity); AdminNotification adminNot = new AdminNotification(userAgent.getId(), identity);
logger.log(BasicLevel.INFO,
"ConnectionManager.init send adminNot to " + adminTopic.getId());
Channel.sendTo(adminTopic.getId(), adminNot); Channel.sendTo(adminTopic.getId(), adminNot);
} }
} else {
try { if (AgentServer.updatecfg != null) {
MXWrapper.registerMBean(getCurrentInstance(), "Joram#" + AgentServer.getServerId(), MBEAN_NAME); // Updates the administrator identity.
} catch (Exception e) { Identity identity = createIdentity(Identity.getRootName(initialAdminName),
logger.log(BasicLevel.DEBUG, "registerMBean", e); 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);
} catch (Exception e) {
logger.log(BasicLevel.DEBUG, "registerMBean", e);
}
} }
/** /**
......
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