This is an automated email from the ASF dual-hosted git repository.
vavrtom pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-broker-j.git
The following commit(s) were added to refs/heads/main by this push:
new f76da5a765 QPID-8591: [Broker-J] Missing message id for
add/update/delete user (#129)
f76da5a765 is described below
commit f76da5a765eef8aeff0252454dd23a2c95cda3c7
Author: Daniil Kirilyuk <[email protected]>
AuthorDate: Mon Jul 11 10:24:53 2022 +0200
QPID-8591: [Broker-J] Missing message id for add/update/delete user (#129)
* QPID-8591: [Broker-J] Missing message id for add/update/delete user
* QPID-8591: [Broker-J] Added new line to end of file.
Co-authored-by: vavrtom <[email protected]>
---
.../qpid/server/logging/messages/UserMessages.java | 265 +++++++++++++++++++++
.../logging/messages/User_logmessages.properties | 33 +++
.../server/security/auth/manager/ManagedUser.java | 30 ++-
.../server/logging/messages/UserMessagesTest.java | 65 +++++
...roker-Appendix-Operational-Logging-Messages.xml | 88 ++++++-
5 files changed, 477 insertions(+), 4 deletions(-)
diff --git
a/broker-core/src/main/java/org/apache/qpid/server/logging/messages/UserMessages.java
b/broker-core/src/main/java/org/apache/qpid/server/logging/messages/UserMessages.java
new file mode 100644
index 0000000000..7d9a678b0d
--- /dev/null
+++
b/broker-core/src/main/java/org/apache/qpid/server/logging/messages/UserMessages.java
@@ -0,0 +1,265 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *
+ */
+package org.apache.qpid.server.logging.messages;
+
+import static
org.apache.qpid.server.logging.AbstractMessageLogger.DEFAULT_LOG_HIERARCHY_PREFIX;
+
+import java.text.MessageFormat;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import org.slf4j.LoggerFactory;
+
+import org.apache.qpid.server.logging.LogMessage;
+
+/**
+ * DO NOT EDIT DIRECTLY, THIS FILE WAS GENERATED.
+ *
+ * Generated using GenerateLogMessages and LogMessages.vm
+ * This file is based on the content of User_logmessages.properties
+ *
+ * To regenerate, use Maven lifecycle generates-sources with -Dgenerate=true
+ */
+public class UserMessages
+{
+ private static ResourceBundle _messages;
+ private static Locale _currentLocale;
+
+ static
+ {
+ Locale locale = Locale.US;
+ String localeSetting = System.getProperty("qpid.broker_locale");
+ if (localeSetting != null)
+ {
+ String[] localeParts = localeSetting.split("_");
+ String language = (localeParts.length > 0 ? localeParts[0] : "");
+ String country = (localeParts.length > 1 ? localeParts[1] : "");
+ String variant = "";
+ if (localeParts.length > 2)
+ {
+ variant = localeSetting.substring(language.length() + 1 +
country.length() + 1);
+ }
+ locale = new Locale(language, country, variant);
+ }
+ _currentLocale = locale;
+ }
+
+ public static final String USER_LOG_HIERARCHY =
DEFAULT_LOG_HIERARCHY_PREFIX + "user";
+ public static final String CREATE_LOG_HIERARCHY =
DEFAULT_LOG_HIERARCHY_PREFIX + "user.create";
+ public static final String DELETE_LOG_HIERARCHY =
DEFAULT_LOG_HIERARCHY_PREFIX + "user.delete";
+ public static final String UPDATE_LOG_HIERARCHY =
DEFAULT_LOG_HIERARCHY_PREFIX + "user.update";
+
+ static
+ {
+ LoggerFactory.getLogger(USER_LOG_HIERARCHY);
+ LoggerFactory.getLogger(CREATE_LOG_HIERARCHY);
+ LoggerFactory.getLogger(DELETE_LOG_HIERARCHY);
+ LoggerFactory.getLogger(UPDATE_LOG_HIERARCHY);
+
+ _messages =
ResourceBundle.getBundle("org.apache.qpid.server.logging.messages.User_logmessages",
_currentLocale);
+ }
+
+ /**
+ * Log a User message of the Format:
+ * <pre>USR-1001 : Create : "{0}" : {1} : {2}</pre>
+ * Optional values are contained in [square brackets] and are numbered
+ * sequentially in the method call.
+ *
+ */
+ public static LogMessage CREATE(String param1, String param2, String
param3)
+ {
+ String rawMessage = _messages.getString("CREATE");
+
+ final Object[] messageArguments = {param1, param2, param3};
+ // Create a new MessageFormat to ensure thread safety.
+ // Sharing a MessageFormat and using applyPattern is not thread safe
+ MessageFormat formatter = new MessageFormat(rawMessage,
_currentLocale);
+
+ final String message = formatter.format(messageArguments);
+
+ return new LogMessage()
+ {
+ @Override
+ public String toString()
+ {
+ return message;
+ }
+
+ @Override
+ public String getLogHierarchy()
+ {
+ return CREATE_LOG_HIERARCHY;
+ }
+
+ @Override
+ public boolean equals(final Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ final LogMessage that = (LogMessage) o;
+
+ return getLogHierarchy().equals(that.getLogHierarchy()) &&
toString().equals(that.toString());
+
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = toString().hashCode();
+ result = 31 * result + getLogHierarchy().hashCode();
+ return result;
+ }
+ };
+ }
+
+ /**
+ * Log a User message of the Format:
+ * <pre>USR-1003 : Delete : "{0}" : {1}</pre>
+ * Optional values are contained in [square brackets] and are numbered
+ * sequentially in the method call.
+ *
+ */
+ public static LogMessage DELETE(String param1, String param2)
+ {
+ String rawMessage = _messages.getString("DELETE");
+
+ final Object[] messageArguments = {param1, param2};
+ // Create a new MessageFormat to ensure thread safety.
+ // Sharing a MessageFormat and using applyPattern is not thread safe
+ MessageFormat formatter = new MessageFormat(rawMessage,
_currentLocale);
+
+ final String message = formatter.format(messageArguments);
+
+ return new LogMessage()
+ {
+ @Override
+ public String toString()
+ {
+ return message;
+ }
+
+ @Override
+ public String getLogHierarchy()
+ {
+ return DELETE_LOG_HIERARCHY;
+ }
+
+ @Override
+ public boolean equals(final Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ final LogMessage that = (LogMessage) o;
+
+ return getLogHierarchy().equals(that.getLogHierarchy()) &&
toString().equals(that.toString());
+
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = toString().hashCode();
+ result = 31 * result + getLogHierarchy().hashCode();
+ return result;
+ }
+ };
+ }
+
+ /**
+ * Log a User message of the Format:
+ * <pre>USR-1002 : Update : "{0}" : {1} : {2}</pre>
+ * Optional values are contained in [square brackets] and are numbered
+ * sequentially in the method call.
+ *
+ */
+ public static LogMessage UPDATE(String param1, String param2, String
param3)
+ {
+ String rawMessage = _messages.getString("UPDATE");
+
+ final Object[] messageArguments = {param1, param2, param3};
+ // Create a new MessageFormat to ensure thread safety.
+ // Sharing a MessageFormat and using applyPattern is not thread safe
+ MessageFormat formatter = new MessageFormat(rawMessage,
_currentLocale);
+
+ final String message = formatter.format(messageArguments);
+
+ return new LogMessage()
+ {
+ @Override
+ public String toString()
+ {
+ return message;
+ }
+
+ @Override
+ public String getLogHierarchy()
+ {
+ return UPDATE_LOG_HIERARCHY;
+ }
+
+ @Override
+ public boolean equals(final Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ final LogMessage that = (LogMessage) o;
+
+ return getLogHierarchy().equals(that.getLogHierarchy()) &&
toString().equals(that.toString());
+
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = toString().hashCode();
+ result = 31 * result + getLogHierarchy().hashCode();
+ return result;
+ }
+ };
+ }
+
+
+ private UserMessages()
+ {
+ }
+
+}
diff --git
a/broker-core/src/main/java/org/apache/qpid/server/logging/messages/User_logmessages.properties
b/broker-core/src/main/java/org/apache/qpid/server/logging/messages/User_logmessages.properties
new file mode 100644
index 0000000000..9760900720
--- /dev/null
+++
b/broker-core/src/main/java/org/apache/qpid/server/logging/messages/User_logmessages.properties
@@ -0,0 +1,33 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# Default File used for all non-defined locales.
+
+# 0 - object name
+# 1 - outcome
+# 2 - attributes
+CREATE = USR-1001 : Create : "{0}" : {1} : {2}
+
+# 0 - object name
+# 1 - outcome
+# 2 - attributes
+UPDATE = USR-1002 : Update : "{0}" : {1} : {2}
+
+# 0 - object name
+# 1 - outcome
+DELETE = USR-1003 : Delete : "{0}" : {1}
diff --git
a/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ManagedUser.java
b/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ManagedUser.java
index d7987f350f..ef0577c9bc 100644
---
a/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ManagedUser.java
+++
b/broker-core/src/main/java/org/apache/qpid/server/security/auth/manager/ManagedUser.java
@@ -26,7 +26,9 @@ import java.util.Map;
import com.google.common.util.concurrent.ListenableFuture;
+import org.apache.qpid.server.logging.Outcome;
import org.apache.qpid.server.logging.messages.AuthenticationProviderMessages;
+import org.apache.qpid.server.logging.messages.UserMessages;
import org.apache.qpid.server.model.AbstractConfiguredObject;
import org.apache.qpid.server.model.Container;
import org.apache.qpid.server.model.ManagedAttributeField;
@@ -40,7 +42,8 @@ class ManagedUser extends
AbstractConfiguredObject<ManagedUser> implements User<
{
public static final String MANAGED_USER_TYPE = "managed";
- private ConfigModelPasswordManagingAuthenticationProvider<?>
_authenticationManager;
+ private final ConfigModelPasswordManagingAuthenticationProvider<?>
_authenticationManager;
+
@ManagedAttributeField
private String _password;
@@ -103,13 +106,34 @@ class ManagedUser extends
AbstractConfiguredObject<ManagedUser> implements User<
@Override
public void setPassword(final String password)
{
- setAttributes(Collections.<String, Object>singletonMap(User.PASSWORD,
password));
+ setAttributes(Collections.singletonMap(User.PASSWORD, password));
}
@Override
protected void logOperation(final String operation)
{
- ((Container)
_authenticationManager.getParent()).getEventLogger().message(AuthenticationProviderMessages.OPERATION(operation));
+ ((Container<?>) _authenticationManager.getParent()).getEventLogger()
+ .message(AuthenticationProviderMessages.OPERATION(operation));
+ }
+
+ @Override
+ protected void logCreated(final Map<String, Object> attributes, final
Outcome outcome)
+ {
+ ((Container<?>) _authenticationManager.getParent()).getEventLogger()
+ .message(UserMessages.CREATE(getName(), outcome.name(),
String.valueOf(getActualAttributes())));
+ }
+
+ @Override
+ protected void logDeleted(final Outcome outcome)
+ {
+ ((Container<?>) _authenticationManager.getParent()).getEventLogger()
+ .message(UserMessages.DELETE(getName(), outcome.name()));
}
+ @Override
+ protected void logUpdated(final Map<String, Object> attributes, final
Outcome outcome)
+ {
+ ((Container<?>) _authenticationManager.getParent()).getEventLogger()
+ .message(UserMessages.UPDATE(getName(), outcome.name(),
String.valueOf(getActualAttributes())));
+ }
}
diff --git
a/broker-core/src/test/java/org/apache/qpid/server/logging/messages/UserMessagesTest.java
b/broker-core/src/test/java/org/apache/qpid/server/logging/messages/UserMessagesTest.java
new file mode 100644
index 0000000000..ea1e061948
--- /dev/null
+++
b/broker-core/src/test/java/org/apache/qpid/server/logging/messages/UserMessagesTest.java
@@ -0,0 +1,65 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.server.logging.messages;
+
+import java.util.List;
+
+import org.junit.Test;
+
+import org.apache.qpid.server.logging.Outcome;
+
+/**
+ * Test ManagedUser Log Messages
+ */
+public class UserMessagesTest extends AbstractTestMessages
+{
+ @Test
+ public void managedUserCreated()
+ {
+ final String name = "test";
+ final String attributes = "{\"type\": \"managed\"}";
+ _logMessage = UserMessages.CREATE(name,
String.valueOf(Outcome.SUCCESS), attributes);
+ final List<Object> log = performLog();
+ final String[] expected = {"Create : \"", name, "\" : ",
String.valueOf(Outcome.SUCCESS), " : ", attributes};
+ validateLogMessage(log, "USR-1001", expected);
+ }
+
+ @Test
+ public void managedUserUpdated()
+ {
+ final String name = "test";
+ final String attributes = "{\"type\": \"managed\"}";
+ _logMessage = UserMessages.UPDATE(name,
String.valueOf(Outcome.SUCCESS), attributes);
+ final List<Object> log = performLog();
+ final String[] expected = {"Update : \"", name, "\" : ",
String.valueOf(Outcome.SUCCESS), " : ", attributes};
+ validateLogMessage(log, "USR-1002", expected);
+ }
+
+ @Test
+ public void managedUserDeleted()
+ {
+ final String name = "test";
+ _logMessage = UserMessages.DELETE(name,
String.valueOf(Outcome.SUCCESS));
+ final List<Object> log = performLog();
+ final String[] expected = {"Delete : \"", name, "\" : ",
String.valueOf(Outcome.SUCCESS)};
+ validateLogMessage(log, "USR-1003", expected);
+ }
+}
diff --git
a/doc/java-broker/src/docbkx/Java-Broker-Appendix-Operational-Logging-Messages.xml
b/doc/java-broker/src/docbkx/Java-Broker-Appendix-Operational-Logging-Messages.xml
index 2b85278379..9b3eabbaf1 100644
---
a/doc/java-broker/src/docbkx/Java-Broker-Appendix-Operational-Logging-Messages.xml
+++
b/doc/java-broker/src/docbkx/Java-Broker-Appendix-Operational-Logging-Messages.xml
@@ -1565,6 +1565,92 @@
</row>
</tbody>
</tgroup>
-</table>
+ </table>
+
+ <table pgwide="1"
xml:id="Java-Broker-Appendix-Operation-Logging-Message-List-ResourceLimit">
+ <title>Resource Limit Log Messages</title>
+ <tgroup cols="2">
+ <colspec colnum="1" colname="messageId" colwidth="1*"/>
+ <colspec colnum="2" colname="messageText" colwidth="1*"/>
+ <thead>
+ <row>
+ <entry>Message Id</entry>
+ <entry>Message Text / Purpose</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row xml:id="Java-Broker-Appendix-Operation-Logging-Message-RL-1001">
+ <entry morerows="1">RL-1001</entry>
+ <entry>Accept</entry>
+ </row>
+ <row>
+ <entry>
+ <para>Connection has been accepted.</para>
+ </entry>
+ </row>
+ <row xml:id="Java-Broker-Appendix-Operation-Logging-Message-RL-1002">
+ <entry morerows="1">RL-1002</entry>
+ <entry>Reject</entry>
+ </row>
+ <row>
+ <entry>
+ <para>Connection has been rejected.</para>
+ </entry>
+ </row>
+ <row xml:id="Java-Broker-Appendix-Operation-Logging-Message-RL-1003">
+ <entry morerows="1">RL-1003</entry>
+ <entry>Info</entry>
+ </row>
+ <row>
+ <entry>
+ <para>An informational message regarding connection limits.</para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+
+ <table pgwide="1"
xml:id="Java-Broker-Appendix-Operation-Logging-Message-List-User">
+ <title>User Log Messages</title>
+ <tgroup cols="2">
+ <colspec colnum="1" colname="messageId" colwidth="1*"/>
+ <colspec colnum="2" colname="messageText" colwidth="1*"/>
+ <thead>
+ <row>
+ <entry>Message Id</entry>
+ <entry>Message Text / Purpose</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row xml:id="Java-Broker-Appendix-Operation-Logging-Message-USR-1001">
+ <entry morerows="1">USR-1001</entry>
+ <entry>Create</entry>
+ </row>
+ <row>
+ <entry>
+ <para>User has been created.</para>
+ </entry>
+ </row>
+ <row xml:id="Java-Broker-Appendix-Operation-Logging-Message-USR-1002">
+ <entry morerows="1">USR-1002</entry>
+ <entry>Update</entry>
+ </row>
+ <row>
+ <entry>
+ <para>User has been updated.</para>
+ </entry>
+ </row>
+ <row xml:id="Java-Broker-Appendix-Operation-Logging-Message-USR-1003">
+ <entry morerows="1">USR-1003</entry>
+ <entry>Delete</entry>
+ </row>
+ <row>
+ <entry>
+ <para>User has been deleted.</para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
</appendix>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]