Openfire Custom Database Login - mysql

I'm trying to connect Openfire with my custom my sql database which I created using Mysql workbench..
I modified openfire.xml file as follow :
<jive>
<adminConsole>
<!-- Disable either port by setting the value to -1 -->
<port>9090</port>
<securePort>9091</securePort>
</adminConsole>
<locale>en</locale>
<!-- Network settings. By default, Openfire will bind to all network interfaces.
Alternatively, you can specify a specific network interfaces that the server
will listen on. For example, 127.0.0.1. This setting is generally only useful
on multi-homed servers. -->
<!--
<network>
<interface></interface>
</network>
-->
<connectionProvider>
<className>org.jivesoftware.database.DefaultConnectionProvider</className>
</connectionProvider>
<database>
<defaultProvider>
<driver>com.mysql.jdbc.Driver</driver>
<serverURL>jdbc:mysql://localhost:3306/openfire_db?rewriteBatchedStatements=true</serverURL>
<username encrypted="true">c130d8786ef86071bcb73f1d8da0eb34f544f389f480f60e</username>
<password encrypted="true">f15df01c5d651451f5f38c29332cf655ff1621d7c0e741ec</password>
<testSQL>select 1</testSQL>
<testBeforeUse>false</testBeforeUse>
<testAfterUse>false</testAfterUse>
<minConnections>5</minConnections>
<maxConnections>25</maxConnections>
<connectionTimeout>1.0</connectionTimeout>
</defaultProvider>
</database>
<setup>true</setup>
<jdbcProvider>
<driver>com.mysql.jdbc.Driver</driver>
<connectionString>jdbc:mysql://localhost/openfire_db?user=root&password=hello</connectionString>
</jdbcProvider>
<provider/>
<jdbcAuthProvider>
<passwordSQL>SELECT plainPassword FROM users WHERE username=?</passwordSQL>
<passwordType>plain</passwordType>
</jdbcAuthProvider>
<jdbcUserProvider>
<loadUserSQL>SELECT name,email FROM users WHERE username=?</loadUserSQL>
<userCountSQL>SELECT COUNT(*) FROM users</userCountSQL>
<allUsersSQL>SELECT username FROM users</allUsersSQL>
<searchSQL>SELECT username FROM users WHERE</searchSQL>
<usernameField>username</usernameField>
<nameField>name</nameField>
<emailField>email</emailField>
</jdbcUserProvider>
</jive>
I get no errors, no warns.. But when I try to login to the admin console I get :
Login failed: make sure your username and password are correct and that you're an admin or moderator.
And in warns:
2015.01.28 11:31:20 org.jivesoftware.admin.LoginLimitManager - Failed admin console login attempt by user from 127.0.0.1
I have in my database table users which has columns : username, plainPassword, encryptedPassword, name, email, creationDate
Thanks.. :)

Problem Solved ^_^.. I needed to add the following to openfire.xml :
<provider>
<auth>
<className>org.jivesoftware.openfire.auth.JDBCAuthProvider</className>
</auth>
<user>
<className>org.jivesoftware.openfire.user.JDBCUserProvider</className>
</user>
<group>
<className>org.jivesoftware.openfire.group.JDBCGroupProvider</className>
</group>
</provider>
and change properties of ofProperty table..

Related

Connection issue with org.jboss.as.quickstarts servlet-security example when migrating to MySQL8 database with Wildfly25, Elytron and MySQL8

I’m trying to connect to MySQL 8, through Elytron on wildfly 25 with Eclipse, to run a servlet-security example from org.jboss.as.quickstarts. The Quickstart can be found at https://github.com/wildfly/quickstart/tree/main/servlet-security The original servlet makes a connection to Wildfly’s built in database H2, after running the batch script below:
# Batch script to configure the security domain and define the database query used to authenticate users
batch
# Start by creating the JDBC datasource
/subsystem=datasources/data-source=ServletSecurityDS:add(connection- url="jdbc:h2:mem:servlet-security;DB_CLOSE_ON_EXIT=FALSE", jndi-name="java:jboss/datasources/ServletSecurityDS", driver-name=h2, user-name="sa", password="sa")
# Add the JDBC security realm creation
/subsystem=elytron/jdbc-realm=servlet-security-jdbc-realm:add(principal-query=[{sql="SELECT PASSWORD FROM USERS WHERE USERNAME = ?", data-source="ServletSecurityDS", clear-password-mapper={password-index=1}},{sql="SELECT R.NAME, 'Roles' FROM USERS_ROLES UR INNER JOIN ROLES R ON R.ID = UR.ROLE_ID INNER JOIN USERS U ON U.ID = UR.USER_ID WHERE U.USERNAME = ?", data-source="ServletSecurityDS", attribute-mapping=[{index=1, to=roles}]}])
# Add a simple role decoder for the "roles" attribute mapping
/subsystem=elytron/simple-role-decoder=from-roles-attribute:add(attribute=roles)
# Configure the servlet-security-quickstart security domain
/subsystem=elytron/security-domain=servlet-security-quickstart-sd:add(default-realm=servlet-security-jdbc-realm, realms=[{realm=servlet-security-jdbc-realm, role-decoder=from-roles-attribute}], permission-mapper=default-permission-mapper)
# Configure the HTTP Authentication Factory
/subsystem=elytron/http-authentication-factory=servlet-security-quickstart-http-auth:add(http-server-mechanism-factory=global,security-domain=servlet-security-quickstart-sd,mechanism-configurations=[{mechanism-name=BASIC,mechanism-realm-configurations=[{realm-name=RealmUsersRoles}]}])
# Configure Undertow's application security domain
/subsystem=undertow/application-security-domain=servlet-security-quickstart:add(http-authentication-factory=servlet-security-quickstart-http-auth)
# Run the batch commands
run-batch
# Reload the server configuration
reload
This configuration works fine, but I haven’t been able to migrate from H2 to MySQL8. The connection created by the included script is below.
<datasource jndi-name="java:jboss/datasources/ServletSecurityDS"
pool-name="ServletSecurityDS">
<connection-url>jdbc:h2:mem:servlet-security;DB_CLOSE_ON_EXIT=FALSE</connection-url>
   <driver>h2</driver>
      <security>
         <user-name>sa</user-name>
         <password>sa</password>
      </security>
</datasource>
  I changed the standalone.xml configuration to:
<datasource jndi-name="java:jboss/datasources/ServletSecurityDS"
  pool-name="ServletSecurityDS">
  <driver-class>com.mysql.cj.jdbc.Driver</driver-class>
  <datasource-class>com.mysql.cj.jdbc.MysqlDataSource</datasource-class>
  <driver>mysql</driver>
  <connection-url>
jdbc:mysql://hobo2020:3306/ServletSecurityDB?useSSL=false&
  </connection-url> 
  <security>
    <user-name>sa</user-name>
    <password>sa</password>
  </security>
</datasource>
I also edited the drivers configuration by adding the MySQL8 driver, as: 
<drivers>
  <driver name="mysql" module="com.mysql">
   <driver-class>com.mysql.cj.jdbc.Driver</driver-class>
<datasource-class>com.mysql.cj.jdbc.MysqlDataSource</datasource-class>
<xa-datasource-class>
com.mysql.cj.jdbc.MysqlXADataSource
</xa-datasource-class>                        
  </driver>
  <driver name="h2" module="com.h2database.h2">
  <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
  </driver>
</drivers>
When I try to run the quickstart with this configuration I get the modal dialog okay, but it returns an Internal server error and I get java.sql.SQLException: No database selected in the Wildfly console. I've tried setting up the database manually, and removing drop and create from persistence.xml, but I get the same result.
The Datasource shows up in the web-console, and I can also connect directly from a java application with no problem. If there is anything relevant that I haven’t included, please advise. Otherwise, thanks in advance for your response.

Why I am always getting "inexistent-host" error?

I installed ejabberd 20.07 on Ubuntu and set domain name as faiqkhan-VirtualBox and set user-admin name as admin and password to 123456. I also check install.log file it shows
User admin#faiqkhan-VirtualBox successfully registered. I also checked using command ./ejabberctl registered_users faiqkhan-VirtualBox it returns my user name admin. I don't know why it always giving error Access of <<"admin#faiqkhan-VirtualBox">> from <<"::ffff:127.0.0.1">> failed with error: <<"inexistent-host">> while logging in.
After changing the given URL http://localhost:5280/admin/ to my host http://faiqkhan-VirtualBox:5280/admin/ I successfully logged in.
As the error message states the host (#domain) is non-existent.
You will need to add it to your ejabberd.yml under hosts e.g. for localhost:
hosts:
- "faiqkhan-VirtualBox"
- "localhost"
Or for admin#faiqkhan.com (username admin and hostname faiqkhan.com)
hosts:
- "faiqkhan-VirtualBox"
- "faiqkhan.com"
Cheers

Symfony2 and GoDaddy error message with incorrect information

I recently uploaded a Symfony2 project to GoDaddy and I'm having trouble accesing it because I get the message:
An exception occured in driver: SQLSTATE[HY000] [1045] Access denied for user 'root'#'127.0.0.1' (using password: NO)
Obviously the message is clear, so I checked and rechecked my parameters.yml, and the message don't even match what I have there, which I have changed several times to try to fix. This is my parameters.yml:
parameters:
database_driver: pdo_mysql
database_host: localhost
database_port: null
database_name: database1
database_user: database1user
database_password: mytestpassword
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
locale: en
secret: RandomTokenThatWillBeChanged
debug_toolbar: true
debug_redirects: false
use_assetic_controller: true
So, the error message doesn't tell me what is my real problem, or it is loading the parameters from some cached version that I haven't found yet. Any ideas of what else could cause or where could a cached version of this data be?
One of the best practice when developing a Symfony application is to
make it configurable via a parameters.yml file. It contains
information such as the database name, the mailer hostname, and custom
configuration parameters.
As those parameters can be different on your local machine, your
testing environment, your production servers, and even between
developers working on the same project, it is not recommended to store
it in the project repository. Instead, the repository should contain a
paramaters.yml.dist file with sensible defaults that can be used as a
good starting point for everyone.
Then, whenever a developer starts working on the project, the
parameters`.yml file must be created by using the parameters.yml.dist
as a template. That works quite well, but whenever a new value is
added to the template, you must remember to update the main parameter
file accordingly.
As of Symfony 2.3, the Standard Edition comes with a new bundle that
automates the tedious work. Whenever you run composer install, a
script creates the parameters.yml file if it does not exist and allows
you to customize all the values interactively. Moreover, if you use
the --no-interaction flag, it will silently fallback to the default
values.
http://symfony.com/blog/new-in-symfony-2-3-interactive-management-of-the-parameters-yml-file
So, is it not possible that your paramaters.yml is overwritten by paramaters.yml.dist?
You can also try to completely clear the cache
In Dev:
php app/console cache:clear
In Production:
php app/console cache:clear --env=prod --no-debug

Password Reset policy in OpenSSO

I had to implement Password Reset policy....For which I had OpenSSO deployed on Glassfish server and OpenDS as the Data Store...I followed Indira's blog...
Password Reset With OpenDS
And executed all commands....Since I did not configure SMTP, when I try to Reset the Password of a particular User (Note: I hav specified a Gmail ID as the email Address of that user) after answering the Question, I get confirmation saying
"Your password has been reset but we are unable to send it to you. Contact your administrator."
How do I configure SMTP in OpenSSO and OpenDS?
OpenDS (and OpenDJ, the continuing open source project) has some global properties to point to the SMTP server.
Note that it doesn't support authentication at this point.
$ dsconfig set-global-configuration-prop --port 4444 --hostname hostname --bindDN "cn=Directory Manager" --bindPassword password --set smtp-server:smtp.example.com --trustAll --no-prompt
Kind regards,
Ludovic
I just had this problem, so for the record I think it's probably because you need to replace <Password-Administrator> in the WEB-INF/classes/amPasswordResetModuleMsgs*.properties files with a real email address.
I found that my Authentication debug log file had this error in it:
ERROR: Could not send email to user [Ljava.lang.String;#30720e48
com.sun.mail.smtp.SMTPSendFailedException: 553 5.5.4 <Password-Administrator>... Domain name required for sender address Password-Administrator
;
nested exception is:
com.sun.mail.smtp.SMTPSenderFailedException: 553 5.5.4 <Password-Administrator>... Domain name required for sender address Password-Administrator
at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2057)
I found the solution on the OpenAM mailing list originally: http://lists.forgerock.org/pipermail/openam/2012-April/005912.html
I used this sed command to do update all the files at once:
sed -i -e 's/\<Password-Administrator\>/user#address\.com\.au/g' amPasswordResetModuleMsgs*.properties

How to set up a password for openrdf workbench?

I have successfully installed Openrdf Repository (sesame 2.3.2) and Openrdf workbench however I do not know how to set up a user and a password to protect Openrdf workbench. I suppose that there is --somewhere -- a configuration file.
Can somebody give me a hint how to create a user and set up a password for openrdf workbench?
I believe you need to password protect at the servlet container level. Are you using Tomcat? Here's what I used to set up basic authentication with Tomcat 6:
web.xml
<security-constraint>
<web-resource-collection>
<web-resource-name>Sesame Workbench</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>sesame-user</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>Sesame Workbench</realm-name>
</login-config>
<security-role>
<description>The role required for Sesame workbench</description>
<role-name>sesame-user</role-name>
</security-role>
tomcat-users.xml
<role rolename="sesame-user"/>
<user username="workbench" password="workbench" roles="sesame-user"/>