msgbartop
Just share my knowledge..It may be a small thing..Read at your own risk.. :-)
msgbarbottom

Adding Remote JMX for Red5

How to Add JMX for Red5 Server

Here we are going to know, How to managing red5 server remotely using JMX.

what is red5 server ..?

Red5 is an Open Source Flash Server written in Java that supports:

  • Streaming Video (FLV, F4V, MP4)
  • Streaming Audio (MP3, F4A, M4A)
  • Recording Client Streams (FLV only)
  • Shared Objects
  • Live Stream Publishing
  • Remoting

This is developed by Reverse Engineering of Adobe Flash Media server.  Red5 under the GNU Lesser General Public License. You can Modify and redistribute this software.


What is JMX …?

JMX stands for Java Management eXtension . JMX is written in java technology used to monitor and manage a java application or objects.

The configuration of jmx agent in red5.properties file. the properties are

red5.properties

# JMX
jmx.rmi.port.registry=9999
jmx.rmi.port.remoteobjects=
jmx.rmi.host=0.0.0.0
jmx.rmi.ssl=false

jmx.rmi.port.registry – the RMI registry port

jmx.rmi.host – the host value by default 0.0.0.0 . if the host is 127.0.0.1 you can’t access in remote. Normally this is your machine ip address.

you must open the firwall for the port 9999. then only you access from remote. For more information  http://bit.ly/1ACRRY

you can visualize the jvm by using this software https://visualvm.dev.java.net/

After install this Add the remote Host and Add remote JMX connection by adding

service:jmx:rmi://192.168.2.6:9999/jndi/rmi://192.168.2.6:9999/red5

192.168.2.6 – ip address of red5

the default user name for jmx is “red5user” and password is “changeme” .  you can change this bu changing the access.properties and password.properties in red5 conf folder.

Tags: , , ,

Secure login using java servlet

The user authentication is the common task when we create a web application. The servlet have j_security_check  authentication method. This is commonly called as form based authentication. Here the steps for this authentication.

This is in your index.jsp or login page

<form action="j_security_check" method="post"> Username
<input name="j_username" type="text" />
Password
<input name="j_password" type="password" />
<input type="submit" value="Login" />
</form>

Add below code in your web.xml

<login-config>
        <auth-method>FORM</auth-method>
        <realm-name>Real Name</realm-name>
        <form-login-config>
            <form-login-page>LoginPage.jsp</form-login-page>
            <form-error-page>LoginPageError.jsp</form-error-page>
            </form-login-config>
</login-config>

 <security-role>
 <description>view all permissions</description>
 <role-name>admin</role-name>
 </security-role>

 <security-role>
 <description>limited permissions</description>
 <role-name>user</role-name>
 </security-role>

 <resource-ref>
 <description>jdbc:mysql://localhost:3306/databasename</description>
 <res-ref-name>mysql/pooldb</res-ref-name>
 <res-type>javax.sql.DataSource</res-type>
 <res-auth>Container</res-auth>
 <res-sharing-scope>Shareable</res-sharing-scope>
 </resource-ref>

Add below code in your Tomcat’s \conf\server.xml

<Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"
	driverName="com.mysql.jdbc.Driver"
	connectionURL="jdbc:mysql://localhost/DBNAME?user=DBUSER&amp;password=DBPASS"
	userTable="USERTABLE" userNameCol="NAMECOLUMN" userCredCol="PASSCOLUMN"
	userRoleTable="ROLETABLE" roleNameCol="ROLECOLUMN"/>

For this you need two tables in your database. One is username table that contains username and password column. And another one is userrole table that contains username and role column.

  • debug —Here, we set the debug level. A higher number generates more detailed output.
  • driverName —The name of our MySQL driver. You need to be sure that the driver’s JAR file is located in Tomcat’s CLASSPATH.
  • connectionURL —The database URL that is used to establish a JDBC connection. In this field, weblogin is the name of our database; user and password are login data with which you are connecting to the database. In MySQL, such a user is created by default, so you can use it. In case you don’t have such a user, you need to create your own user and make it capable of working with your weblogin database.
  • userTable —A table with at least two fields, defined in userNameCol and userCredCol.
  • userNameCol and userCredCol—The fields with the name of login field from the users table and pass.

For more info Realm How to

Tags: