<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-9057780077077039372</atom:id><lastBuildDate>Sun, 13 Dec 2020 11:30:13 +0000</lastBuildDate><category>Java</category><category>IBM Tivoli Access Manager</category><category>Linux</category><category>ITAM-eb</category><category>IBM Tivoli Directory Server</category><category>Android</category><category>Commands</category><category>IBM TDS</category><category>LDAP</category><category>TAM Java API</category><category>C++</category><category>JNDI</category><category>Java Naming and Directory Interface</category><category>com.tivoli.pd.jadmin</category><category>com.tivoli.pd.jutil</category><category>Factorial</category><category>IBM</category><category>IBM TAM</category><category>Send Email</category><category>Ubuntu</category><category>XML</category><category>com.tivoli.pd.jcfg.SvrSslCfg</category><category>AWK Script</category><category>AWT</category><category>Add TAM User</category><category>Add TAM group</category><category>Add TDS/LDAP User Attribute</category><category>Add User</category><category>Alert</category><category>Apache API</category><category>Assignment</category><category>Authentication</category><category>Banker Algorithm</category><category>Bash Script Array</category><category>Bash Shell Scripting</category><category>BeSafe</category><category>C#</category><category>Connection with LDAP</category><category>Connection with TAM</category><category>Connection with TDS</category><category>Create XML</category><category>Currency</category><category>Decode</category><category>Delete TAM User</category><category>Delete TAM group</category><category>Delete TDS/LDAP User Attribute</category><category>Dialog</category><category>Dollar</category><category>Edit XML</category><category>Emergency Help Button</category><category>Encode</category><category>Family Help</category><category>Fibonacci sequence</category><category>Find Location</category><category>GPS</category><category>Get All TAM groups List</category><category>Get All TAM users List</category><category>Get ITAM-eb User Account</category><category>Gmail SMTP Client</category><category>Google Weather API</category><category>HPDJA0109W</category><category>ITDS</category><category>Input Dialog</category><category>InstantSafe</category><category>Internet Connection</category><category>JSON</category><category>JSON array</category><category>JSON object</category><category>Java Mail API</category><category>Lightweight Directory Access Protocol</category><category>Log</category><category>Log4j</category><category>Log4j.jar</category><category>Modify User Attributes</category><category>Music</category><category>Network</category><category>OS</category><category>Open Ports</category><category>Operating System</category><category>PD.jar</category><category>Parse JSON</category><category>Parse XML</category><category>Parse XML response of Google Weather API</category><category>Parse XML response of Weather Underground API</category><category>Password Generator</category><category>Penny</category><category>Play Background</category><category>Ports</category><category>Power Button 4 Clicks</category><category>Prime facctors</category><category>Process Management</category><category>Random</category><category>Range</category><category>Read JSON</category><category>Read XML</category><category>Replace TDS/LDAP User Attribute</category><category>SSL</category><category>SWT</category><category>Samba Client</category><category>Samba Configuration</category><category>Samba Server</category><category>Search User</category><category>Search in LDAP</category><category>Set ITAM-eb User Account</category><category>Set User Password</category><category>Sound</category><category>Sum of digits</category><category>SvrSslCfg</category><category>Swing</category><category>TAM Password Validation</category><category>TAM Password policy</category><category>TDS Password</category><category>TDS URL</category><category>TDS Username</category><category>Track Mobile</category><category>Urdu String</category><category>Urdu Text</category><category>WAS</category><category>WAS Password</category><category>WAS URL</category><category>WAS Username</category><category>Weather Underground API</category><category>WebSeal</category><category>WebSphere Application Server</category><category>Windows</category><category>Write XML</category><category>Yahoo Mail Client</category><category>cat</category><category>com.google.gson</category><category>com.ibm.security.util.DerValue</category><category>commons-codec-1.6.jar</category><category>find</category><category>grep/egrep</category><category>groups</category><category>hard and soft links</category><category>head</category><category>jl1.0.jar</category><category>managing file permissions and ownership</category><category>mkdir</category><category>rm</category><category>rmdir</category><category>set up ACLs</category><category>tail</category><category>touch</category><category>type</category><category>user and group management</category><category>which</category><title>IT Knowledge</title><description>To share knowledge and help the people</description><link>http://usmanali112.blogspot.com/</link><managingEditor>noreply@blogger.com (Unknown)</managingEditor><generator>Blogger</generator><openSearch:totalResults>44</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9057780077077039372.post-8858219058490990032</guid><pubDate>Sat, 09 May 2015 10:15:00 +0000</pubDate><atom:updated>2015-05-09T15:20:33.508+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Android</category><category domain="http://www.blogger.com/atom/ns#">BeSafe</category><category domain="http://www.blogger.com/atom/ns#">Emergency Help Button</category><category domain="http://www.blogger.com/atom/ns#">Family Help</category><category domain="http://www.blogger.com/atom/ns#">Find Location</category><category domain="http://www.blogger.com/atom/ns#">InstantSafe</category><category domain="http://www.blogger.com/atom/ns#">Power Button 4 Clicks</category><category domain="http://www.blogger.com/atom/ns#">Track Mobile</category><title>Android: InstantSafe App</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Roboto, UILanguageFont, Arial, sans-serif; font-size: 14px; line-height: 24px;&quot;&gt;&lt;a href=&quot;https://play.google.com/store/apps/details?id=com.uab.instantsafe&quot; target=&quot;_blank&quot;&gt;InstantSafe&lt;/a&gt;&amp;nbsp;app is to save people in case of emergency and provide them instant help from their family/friends and local emergency help services. You can also instantly track your mobile phone or your family/friends can find your location to provide immediate help.&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Roboto, UILanguageFont, Arial, sans-serif; font-size: 14px; line-height: 24px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://3.bp.blogspot.com/-piTg4oU54z0/VU3cw4lAB_I/AAAAAAAABN8/W3tJnkjtUWU/s1600/InstantSafe.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;http://3.bp.blogspot.com/-piTg4oU54z0/VU3cw4lAB_I/AAAAAAAABN8/W3tJnkjtUWU/s320/InstantSafe.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Roboto, UILanguageFont, Arial, sans-serif; font-size: 14px; line-height: 24px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: Roboto, UILanguageFont, Arial, sans-serif; font-size: 14px; line-height: 24px; margin-bottom: 5px; padding: 0px;&quot;&gt;If you or your loved one ever walk through a dark alley, travelling abroad and have or witness serious life-threatening situation like fire or medical emergency or you just need to alert someone of your whereabouts just quickly click your mobile phone power button 4 times or click app SAFE button to instantly inform your family/friends/guardians that you need help.&lt;/div&gt;&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: Roboto, UILanguageFont, Arial, sans-serif; font-size: 14px; line-height: 24px; margin-bottom: 5px; padding: 0px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;background-color: white; border: 0px; color: #333333; font-family: Roboto, UILanguageFont, Arial, sans-serif; line-height: 24px; margin-bottom: 5px; padding: 0px; text-align: left;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;How it works:&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: Roboto, UILanguageFont, Arial, sans-serif; font-size: 14px; line-height: 24px; margin-bottom: 5px; padding: 0px;&quot;&gt;You just have to quickly click mobile phone power button 4 times or click app SAFE button in case of emergency to inform your emergency contacts. It will instantly initiate a call to your emergency call contact and send personalized help SMS including your location (a Google maps link) to your emergency SMS contacts even if your mobile phone screen is locked (No need even to get mobile phone out of your pocket). In personal emergency contacts you can add your family/friend/guardian contacts for emergency call or SMS. In local emergency contacts you can add local emergency help service contacts like police, hospital, fire brigade etc. You can save a personalized help SMS to be sent in case of emergency. You can save a location request code. When your mobile phone receives an SMS having exact specified location request code it will automatically send its location in reply.&lt;/div&gt;&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: Roboto, UILanguageFont, Arial, sans-serif; font-size: 14px; line-height: 24px; margin-bottom: 5px; padding: 0px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;background-color: white; border: 0px; color: #333333; font-family: Roboto, UILanguageFont, Arial, sans-serif; line-height: 24px; margin-bottom: 5px; padding: 0px; text-align: left;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;What is different?&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: Roboto, UILanguageFont, Arial, sans-serif; font-size: 14px; line-height: 24px; margin-bottom: 5px; padding: 0px;&quot;&gt;- Quick 4 times mobile phone power button click will inform emergency contacts instantly&lt;br /&gt;In case of panic you don&#39;t have to launch complete application or even unlock mobile phone screen lock to inform your emergency contacts. Mostly emergency help applications provide just an emergency button.&lt;/div&gt;&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: Roboto, UILanguageFont, Arial, sans-serif; font-size: 14px; line-height: 24px; margin-bottom: 5px; padding: 0px;&quot;&gt;- Mobile phone location in response to location request code SMS&lt;br /&gt;It can help you to track your mobile phone or your family/friends can find your location to provide you immediate help. It can be used in case your mobile is lost; family/friends are worried about you.&lt;/div&gt;&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: Roboto, UILanguageFont, Arial, sans-serif; font-size: 14px; line-height: 24px; margin-bottom: 5px; padding: 0px;&quot;&gt;- No internet required&lt;br /&gt;Although Internet is easily available everywhere but still to facilitate more people from basic to advanced smartphone users and to avoid internet connectivity issues in case of emergency, this app works fine without internet. Mostly emergency help applications require internet.&lt;/div&gt;&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: Roboto, UILanguageFont, Arial, sans-serif; font-size: 14px; line-height: 24px; margin-bottom: 5px; padding: 0px;&quot;&gt;- Intuitive User interface&lt;br /&gt;It has simple, tidy, easy to use interface.&lt;/div&gt;&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: Roboto, UILanguageFont, Arial, sans-serif; font-size: 14px; line-height: 24px; margin-bottom: 5px; padding: 0px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: Roboto, UILanguageFont, Arial, sans-serif; line-height: 24px; margin-bottom: 5px; padding: 0px;&quot;&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Features:&lt;/span&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/h3&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;- SAFE button to inform emergency contacts&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;- Quick mobile phone power button 4 clicks to inform emergency contacts&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;- No need to launch app, unlock mobile phone screen lock or even get mobile phone out of your pocket&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;- Immediately initiate call to emergency call contact&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;- Help SMS with your current coordinates to multiple emergency SMS contacts&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;- Add mobile phone contacts directly&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;- Personalized help SMS&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;- Custom location request code&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;- Self-activated reply with current location for location request code&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;- Notifications for emergency call/SMS contact and help SMS&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;- Power button, location request code, notification and sound settings&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;- Power saving approach for minimum battery consumption&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;- Application works fine without Internet connection&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-size: 14px;&quot;&gt;- Application is free of ads&lt;/span&gt;&lt;br /&gt;&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: Roboto, UILanguageFont, Arial, sans-serif; font-size: 14px; line-height: 24px; margin-bottom: 5px; padding: 0px;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;background-color: white; border: 0px; color: #333333; font-family: Roboto, UILanguageFont, Arial, sans-serif; line-height: 24px; margin-bottom: 5px; padding: 0px; text-align: left;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Note:&amp;nbsp;&lt;/span&gt;&lt;/h3&gt;&lt;div style=&quot;background-color: white; border: 0px; color: #333333; font-family: Roboto, UILanguageFont, Arial, sans-serif; font-size: 14px; line-height: 24px; margin-bottom: 5px; padding: 0px;&quot;&gt;Make sure in mobile phone settings, location services are &#39;ON&#39; and high accuracy mode using GPS, Wi-Fi and cellular networks to determine location is enabled.&lt;/div&gt;&lt;/div&gt;</description><link>http://usmanali112.blogspot.com/2015/05/android-instantsafe-app.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-piTg4oU54z0/VU3cw4lAB_I/AAAAAAAABN8/W3tJnkjtUWU/s72-c/InstantSafe.png" height="72" width="72"/><thr:total>4</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9057780077077039372.post-1270633857815758932</guid><pubDate>Sat, 18 Oct 2014 07:20:00 +0000</pubDate><atom:updated>2014-10-18T12:20:39.354+05:00</atom:updated><title>Java: Connection with MySQL using JDBC</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;This will help you create connection with MySQL database using Java (JDBC). You have to update database URL, username and password in the code, then run it you will get connection established as output. &amp;nbsp;Please include&amp;nbsp;mysql-connector-java-5.1.23-bin.jar in your project build path. You can download it from here:&amp;nbsp;&lt;a href=&quot;http://www.java2s.com/Code/JarDownload/mysql/mysql-connector-java-5.1.23-bin.jar.zip&quot; target=&quot;_blank&quot;&gt;http://www.java2s.com/Code/JarDownload/mysql/mysql-connector-java-5.1.23-bin.jar.zip&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;import java.sql.Connection;&lt;br /&gt;import java.sql.DriverManager;&lt;br /&gt;import java.sql.SQLException;&lt;br /&gt;&lt;br /&gt;public class DBConnection {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static void main(String[] args){&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;getConnection();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; public static Connection getConnection(){&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Connection conn = null;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Class.forName(&quot;com.mysql.jdbc.Driver&quot;);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; String url = &quot;jdbc:mysql://localhost/database_name&quot;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; String user = &quot;root&quot;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; String password = &quot;&quot;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; conn = &amp;nbsp;DriverManager.getConnection(url, user, password);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; System.out.println(&quot;Connection established&quot;);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; catch(ClassNotFoundException e)&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; System.out.println(e.getMessage());&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; System.exit(0);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; catch(SQLException e)&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; System.out.println(e.getMessage());&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; System.exit(0);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return conn;&lt;br /&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;}&lt;/div&gt;</description><link>http://usmanali112.blogspot.com/2014/10/java-connection-with-mysql-using-jdbc.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9057780077077039372.post-3060255045306648945</guid><pubDate>Thu, 25 Sep 2014 15:58:00 +0000</pubDate><atom:updated>2014-09-25T21:04:10.015+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Android</category><category domain="http://www.blogger.com/atom/ns#">Input Dialog</category><title>Android: Show Input Dialog</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This code simply shows how to use an input dialog box and get input value from it.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public void showInputDialog(Context context){&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;AlertDialog.Builder alert = new AlertDialog.Builder(context);&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;alert.setTitle(&quot;Input&quot;);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;alert.setMessage(&quot;Enter Text&quot;);&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;// Set an EditText view to get user input&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;final EditText input = new EditText(context);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;input.setInputType(InputType.TYPE_CLASS_TEXT);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;alert.setView(input);&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;alert.setPositiveButton(&quot;Ok&quot;,&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;new DialogInterface.OnClickListener() {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;public void onClick(DialogInterface dialog,&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;int whichButton) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt;String value = input.getText().toString().trim();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt;System.out.println(value);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;});&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;alert.setNegativeButton(&quot;Cancel&quot;,&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;new DialogInterface.OnClickListener() {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;public void onClick(DialogInterface dialog,&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;int whichButton) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt;// Canceled.&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;});&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;alert.show();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/div&gt;</description><link>http://usmanali112.blogspot.com/2014/09/android-show-input-dialog.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9057780077077039372.post-7249027471123785986</guid><pubDate>Thu, 25 Sep 2014 15:01:00 +0000</pubDate><atom:updated>2014-09-25T21:03:18.170+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Android</category><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">Open Ports</category><category domain="http://www.blogger.com/atom/ns#">Ports</category><category domain="http://www.blogger.com/atom/ns#">Range</category><title>Java: Find Open Ports in a Range</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This code will help you to find system available open ports in a range. You can use it in Java or Android applications according to the scenario.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;import java.io.IOException;&lt;br /&gt;import java.net.ServerSocket;&lt;br /&gt;import java.util.ArrayList;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public class SystemPorts {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static void main(String[] args){&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;getFreePorts();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static void getFreePorts() {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;final int MAXIMUM_PORT_RANGE = 6000;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;final int MINIMUM_PORT_RANGE = 5000;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;int[] ports = new int[1001];&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ArrayList&amp;lt;Integer&amp;gt; avialablePorts = new ArrayList&amp;lt;Integer&amp;gt;();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for (int j = 0, i = MINIMUM_PORT_RANGE; i &amp;lt;= MAXIMUM_PORT_RANGE ; i++, j++) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ports[j] = i;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for (int i=0; i&amp;lt;ports.length; i++) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;try {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;ServerSocket socket = new ServerSocket(ports[i]);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;socket.close();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;if(socket.isClosed()){&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;avialablePorts.add(ports[i]);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;System.out.println(&quot;Port Number: &quot; + ports[i]);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;} catch (IOException ex) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;continue; // try next port&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://usmanali112.blogspot.com/2014/09/java-find-open-ports-in-range.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9057780077077039372.post-6254503113493833718</guid><pubDate>Mon, 19 Aug 2013 07:13:00 +0000</pubDate><atom:updated>2013-08-19T12:13:42.606+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Android</category><category domain="http://www.blogger.com/atom/ns#">Internet Connection</category><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">Network</category><title>Android: Verify Device Internet Connection</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;This code verifies either device is connected to network or not.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// Verify Network Connection&lt;br /&gt;protected boolean isNetworkConnected(Activity context) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;boolean connectedWifi = false; // connected to WiFi&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp;boolean connectedMobile = false; // connected to Mobile&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp;ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp;NetworkInfo[] netInfo = connectivityManager.getAllNetworkInfo();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp;for (NetworkInfo ni : netInfo) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (ni.getTypeName().equalsIgnoreCase(&quot;WIFI&quot;))&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (ni.isConnected())&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;connectedWifi = true;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (ni.getTypeName().equalsIgnoreCase(&quot;MOBILE&quot;))&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (ni.isConnected())&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;connectedMobile = true;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp;return connectedWifi || connectedMobile;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;</description><link>http://usmanali112.blogspot.com/2013/08/android-verify-device-internet.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9057780077077039372.post-7888501415171150809</guid><pubDate>Mon, 19 Aug 2013 06:57:00 +0000</pubDate><atom:updated>2013-08-19T11:57:51.128+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Alert</category><category domain="http://www.blogger.com/atom/ns#">Android</category><category domain="http://www.blogger.com/atom/ns#">Dialog</category><category domain="http://www.blogger.com/atom/ns#">GPS</category><category domain="http://www.blogger.com/atom/ns#">Java</category><title>Android: Show Alert Dialog to enable GPS</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;br /&gt;This code will show alert dialog to enable GPS on the device.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// Show Alert Dialog to enable GPS&lt;br /&gt;protected void showGPSAlert(final Context context) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;context);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;alertDialogBuilder&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;.setMessage(&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;&quot;GPS is disabled on your device. Would you like to enable it?&quot;)&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;.setCancelable(false)&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;.setPositiveButton(&quot;Open Settings&quot;,&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;new DialogInterface.OnClickListener() {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;        &lt;/span&gt;public void onClick(DialogInterface dialog, int id) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;        &lt;/span&gt;// set intent to open settings&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;         &lt;/span&gt;Intent callGPSSettingIntent = new Intent(&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;           &lt;/span&gt;android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;         &lt;/span&gt;context.startActivity(callGPSSettingIntent);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;        &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;});&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;alertDialogBuilder.setNegativeButton(&quot;Cancel&quot;,&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;new DialogInterface.OnClickListener() {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt;public void onClick(DialogInterface dialog, int id) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;dialog.cancel();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;});&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;AlertDialog alert = alertDialogBuilder.create();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;alert.show();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;/div&gt;</description><link>http://usmanali112.blogspot.com/2013/08/android-show-alert-dialog-to-enable-gps.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9057780077077039372.post-5794900384217280001</guid><pubDate>Mon, 11 Mar 2013 19:09:00 +0000</pubDate><atom:updated>2013-03-13T21:19:58.381+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">AWT</category><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">Swing</category><category domain="http://www.blogger.com/atom/ns#">SWT</category><category domain="http://www.blogger.com/atom/ns#">Urdu String</category><category domain="http://www.blogger.com/atom/ns#">Urdu Text</category><title>Java: Show Urdu Text on Swing/AWT/SWT Components</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-vKXsnx-Gm70/UFNBCThql8I/AAAAAAAAAKk/i5sYAfNZ1EE/s1600/Java.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://2.bp.blogspot.com/-vKXsnx-Gm70/UFNBCThql8I/AAAAAAAAAKk/i5sYAfNZ1EE/s1600/Java.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;This code will&amp;nbsp;Show Urdu Text on Swing/AWT/SWT Components. You will have to use unicode values for Urdu characters.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;import java.awt.BorderLayout;&lt;br /&gt;import java.awt.Dimension;&lt;br /&gt;import java.awt.Font;&lt;br /&gt;import java.awt.GridLayout;&lt;br /&gt;import java.awt.event.ActionEvent;&lt;br /&gt;import java.awt.event.ActionListener;&lt;br /&gt;&lt;br /&gt;import javax.swing.JButton;&lt;br /&gt;import javax.swing.JFrame;&lt;br /&gt;import javax.swing.JLabel;&lt;br /&gt;import javax.swing.JPanel;&lt;br /&gt;import javax.swing.JTextField;&lt;br /&gt;&lt;br /&gt;public class Factory extends JFrame implements ActionListener{&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private static final long serialVersionUID = 1L;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;JPanel bottomPanel = new JPanel();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;JPanel centerPanel = new JPanel();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;JLabel lblDate = new JLabel();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;JLabel lblSale = new JLabel(&quot;\u06A9\u0644 \u0641\u0631\u0648\u062E\u062A : &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;JLabel lblSpent = new JLabel(&quot;\u06A9\u0644 \u0631\u0642\u0645 \u062E\u0631\u06CC\u062F \u067E\u0631 \u062E\u0631 \u0686 : &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;JLabel lblDailywages = new JLabel(&quot;\u062F\u06CC\u06C1\u0627 \u0691 \u06CC \u062F\u0627\u0631 \u06A9\u06CC \u062F\u06CC\u06C1\u0627 \u0691 \u06CC : &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;JLabel lblOtherExpenses = new JLabel(&quot;\u062F\u0648\u0633\u0631\u06D2 \u0627\u062E\u0631\u0627\u062C\u0627\u062A : &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;JLabel lblBankDeposit = new JLabel(&quot;\u0628\u06CC\u0646\u06A9 \u0645\u06CC\u06BA \u062C\u0645\u0639 : &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&quot;);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;JTextField txtSale = new JTextField();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;JTextField txtSpent = new JTextField();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;JTextField txtDailywages = new JTextField();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;JTextField txtOtherExpenses = new JTextField();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;JTextField txtBankDeposit = new JTextField();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;JButton btnSave = new JButton(&quot;\u0645\u062D\u0641\u0648\u0638 \u06A9\u0631 \u0648 &quot;);&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public Factory() {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;lblSale.setFont(new Font(&quot;Segoe UI&quot;,1,16));&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;lblSpent.setFont(new Font(&quot;Segoe UI&quot;,1,16));&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;lblOtherExpenses.setFont(new Font(&quot;Segoe UI&quot;,1,16));&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;lblDailywages.setFont(new Font(&quot;Segoe UI&quot;,1,16));&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;lblBankDeposit.setFont(new Font(&quot;Segoe UI&quot;,1,16));&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;lblDate.setFont(new Font(&quot;Segoe UI&quot;,1,16));&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;txtSale.setPreferredSize(new Dimension(200, 30));&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;txtSpent.setPreferredSize(new Dimension(200, 30));&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;txtOtherExpenses.setPreferredSize(new Dimension(200, 30));&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;txtDailywages.setPreferredSize(new Dimension(200, 30));&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;txtBankDeposit.setPreferredSize(new Dimension(200, 30));&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;GridLayout layout = new GridLayout(5,1);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; layout.setVgap(8);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; centerPanel.setLayout(layout);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JPanel saleGridPanel = new JPanel(new GridLayout(1,2));&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JPanel salePanel = new JPanel();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;saleGridPanel.add(txtSale);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;saleGridPanel.add(lblSale);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;salePanel.add(saleGridPanel);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;centerPanel.add(salePanel);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JPanel spentGridPanel = new JPanel(new GridLayout(1,2));&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JPanel spentPanel = new JPanel();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;spentGridPanel.add(txtSpent);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;spentGridPanel.add(lblSpent);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;spentPanel.add(spentGridPanel);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;centerPanel.add(spentPanel);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JPanel wagesGridPanel = new JPanel(new GridLayout(1,2));&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JPanel wagesPanel = new JPanel();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;wagesGridPanel.add(txtDailywages);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;wagesGridPanel.add(lblDailywages);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;wagesPanel.add(wagesGridPanel);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;centerPanel.add(wagesPanel);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JPanel expensesGridPanel = new JPanel(new GridLayout(1,2));&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JPanel expensesPanel = new JPanel();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;expensesGridPanel.add(txtOtherExpenses);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;expensesGridPanel.add(lblOtherExpenses);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;expensesPanel.add(expensesGridPanel);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;centerPanel.add(expensesPanel);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JPanel bankGridPanel = new JPanel(new GridLayout(1,2));&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;JPanel bankPanel = new JPanel();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;bankGridPanel.add(txtBankDeposit);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;bankGridPanel.add(lblBankDeposit);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;bankPanel.add(bankGridPanel);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;centerPanel.add(bankPanel);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;bottomPanel.add(btnSave);&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;btnSave.addActionListener(this);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;setTitle(&quot;\u0641\u06CC\u06A9\u0679\u0631\u06CC &quot;);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; setPreferredSize(new Dimension(500,600));&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; setLayout(new BorderLayout());&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;getContentPane().add(centerPanel, BorderLayout.CENTER);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;getContentPane().add(bottomPanel, BorderLayout.SOUTH);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pack();&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; setDefaultCloseOperation(EXIT_ON_CLOSE);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; setVisible(true);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; setLocationRelativeTo(null);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static void main(String[] args){&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;new Factory();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;@Override&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void actionPerformed(ActionEvent e) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if(e.getSource() == btnSave){&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;javax.swing.JOptionPane.showMessageDialog(null,&quot;Saved&quot;, &quot;Saved&quot;, javax.swing.JOptionPane.INFORMATION_MESSAGE);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;div&gt;&lt;br /&gt;References:&lt;br /&gt;For Urdu text use Google Translator&amp;nbsp;&lt;a href=&quot;http://translate.google.com/&quot; target=&quot;_blank&quot;&gt;http://translate.google.com/&lt;/a&gt;&lt;br /&gt;For Unicode Conversion&amp;nbsp;&lt;a href=&quot;http://rishida.net/tools/conversion/&quot; target=&quot;_blank&quot;&gt;http://rishida.net/tools/conversion/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://usmanali112.blogspot.com/2013/03/java-show-urdu-text-on-swingawtswt.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-vKXsnx-Gm70/UFNBCThql8I/AAAAAAAAAKk/i5sYAfNZ1EE/s72-c/Java.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9057780077077039372.post-3113986569187789604</guid><pubDate>Mon, 11 Mar 2013 18:43:00 +0000</pubDate><atom:updated>2013-03-11T23:43:27.956+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">jl1.0.jar</category><category domain="http://www.blogger.com/atom/ns#">Music</category><category domain="http://www.blogger.com/atom/ns#">Play Background</category><category domain="http://www.blogger.com/atom/ns#">Sound</category><title>Java: Play Background Music</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-vKXsnx-Gm70/UFNBCThql8I/AAAAAAAAAKk/i5sYAfNZ1EE/s1600/Java.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://2.bp.blogspot.com/-vKXsnx-Gm70/UFNBCThql8I/AAAAAAAAAKk/i5sYAfNZ1EE/s1600/Java.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;You can use following code to play background music in your Java application. You will need to add &#39;jl1.0.jar&#39; in your Java project. You can download it from&lt;br /&gt;&lt;a href=&quot;http://www.javazoom.net/javalayer/sources.html&quot; target=&quot;_blank&quot;&gt;http://www.javazoom.net/javalayer/sources.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;BackgroundMusic.java:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;import java.io.BufferedInputStream;&lt;br /&gt;import java.io.FileInputStream;&lt;br /&gt;import javazoom.jl.player.Player;&lt;br /&gt;&lt;br /&gt;public class BackgroundMusic {&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; private String filename;&lt;br /&gt;&amp;nbsp; &amp;nbsp; private static Player player;&lt;br /&gt;&amp;nbsp; &amp;nbsp; Thread playMusic;&lt;br /&gt;&amp;nbsp; &amp;nbsp; // constructor that takes the name of an MP3 file&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; public BackgroundMusic(String filename) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.filename = filename;&lt;br /&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; // play the MP3 file to the sound card&lt;br /&gt;&amp;nbsp; &amp;nbsp; public void play() {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FileInputStream fis = new FileInputStream(filename);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; BufferedInputStream bis = new BufferedInputStream(fis);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; player = new Player(bis);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } catch (Exception e) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; System.out.println(&quot;Problem playing file &quot; + filename);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; System.out.println(e);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; public void start() {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; play();&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; playMusic = new Thread(new PlayMusic());&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; playMusic.start();&lt;br /&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; public void stop() {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; close();&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; playMusic = null;&lt;br /&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; public void close() {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (player != null) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; player.close();&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; class PlayMusic implements Runnable {&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public void run() {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; player.play();&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; catch (Exception e) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; System.out.println(e);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;&amp;nbsp; &amp;nbsp; }&lt;br /&gt;}&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;TestBackgroundMusic.java:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;import java.util.logging.Level;&lt;/div&gt;&lt;div&gt;import java.util.logging.Logger;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;public class TestBackgroundMusic {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; public static void main(String[] args){&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; BackgroundMusic bm = new BackgroundMusic(&quot;FileName.mp3&quot;);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; bm.start();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Thread.sleep(10000);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; bm.stop();&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } catch (InterruptedException ex) {&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; System.out.println(ex);&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; }&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://usmanali112.blogspot.com/2013/03/java-play-background-music.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-vKXsnx-Gm70/UFNBCThql8I/AAAAAAAAAKk/i5sYAfNZ1EE/s72-c/Java.jpg" height="72" width="72"/><thr:total>3</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9057780077077039372.post-4918156540622043897</guid><pubDate>Mon, 11 Mar 2013 18:15:00 +0000</pubDate><atom:updated>2013-03-14T20:58:12.604+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">com.ibm.security.util.DerValue</category><category domain="http://www.blogger.com/atom/ns#">com.tivoli.pd.jcfg.SvrSslCfg</category><category domain="http://www.blogger.com/atom/ns#">HPDJA0109W</category><category domain="http://www.blogger.com/atom/ns#">IBM</category><category domain="http://www.blogger.com/atom/ns#">IBM TAM</category><category domain="http://www.blogger.com/atom/ns#">IBM Tivoli Access Manager</category><category domain="http://www.blogger.com/atom/ns#">ITAM-eb</category><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">SvrSslCfg</category><category domain="http://www.blogger.com/atom/ns#">TAM Java API</category><title>IBM: Java com.tivoli.pd.jcfg.SvrSslCfg Utility</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-fYMIbQfEv9k/UFNBrvCYtwI/AAAAAAAAAKs/zruovt_MOWg/s1600/IBM.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://2.bp.blogspot.com/-fYMIbQfEv9k/UFNBrvCYtwI/AAAAAAAAAKs/zruovt_MOWg/s1600/IBM.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;This (com.tivoli.pd.jcfg.SvrSslCfg) utility configures your application in secure domain which is required for communication between TAM-eb and your application. I will configure and run a demo application. These are&amp;nbsp;prerequisites for running the utility:&lt;br /&gt;&lt;br /&gt;&lt;b&gt;* WAS, LDAP (TDS) and WebSEAL are configured (Tested by running)&lt;/b&gt;&lt;br /&gt;&lt;b&gt;* Java installed&lt;/b&gt;&lt;br /&gt;Note: Run these commands on the terminal&lt;br /&gt;&lt;br /&gt;$java -version (Java Runtime version)&lt;br /&gt;$javac -version (Java compiler version)&lt;br /&gt;&lt;br /&gt;Both should be same like&lt;br /&gt;Runtime: java version &quot;1.6.0_32-ea&quot;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Java(TM) SE Runtime Environment (build 1.6.0_32-ea-b01)&lt;br /&gt;&lt;br /&gt;Compile: javac 1.6.0_32-ea&lt;br /&gt;&lt;br /&gt;&lt;b&gt;* Set System Environmental Variables&lt;/b&gt;&amp;nbsp;in $HOME/.bashrc or /root/.bashrc like&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; PATH=/usr/java/jdk1.6.0/bin:$PATH&lt;br /&gt;&amp;nbsp; export JAVA_HOME=/usr/java/jdk1.6.0&lt;br /&gt;&amp;nbsp; export CLASSPATH=/usr/java/jdk1.6.0/lib/tools.jar:./&lt;br /&gt;&lt;br /&gt;If you get following exception while running com.tivoli.pd.jcfg.SvrSslCfg&amp;nbsp;utility&lt;br /&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;b&gt;Exception:&amp;nbsp;noclassdeffounderror com.ibm.security.x509.x509certimpl&lt;br /&gt;OR&lt;br /&gt;&amp;nbsp;PD.properties can&#39;t be loaded&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;b&gt;Solution:&amp;nbsp;&lt;/b&gt;&lt;/div&gt;&lt;br /&gt;* Run this command on terminal&lt;br /&gt;$export PATH=/opt/IBM/TDI/V6.1.1/jvm/jre/bin:$PATH&lt;br /&gt;&lt;br /&gt;* Run this command on terminal&lt;br /&gt;$which java&lt;br /&gt;&lt;br /&gt;Output should be:&amp;nbsp;/opt/IBM/TDI/V6.1.1/jvm/jre/bin&lt;br /&gt;&lt;br /&gt;* Run this command on terminal&lt;br /&gt;$/opt/PolicyDirector/sbin/pdjrtecfg -action config -host tameb -port 7135 -java_home /usr/j2se/jre -domain Default -config_type full&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Output should be: Configuration of Access Manager Runtime for Java is in progress.&lt;br /&gt;This might take several minutes.&lt;br /&gt;Configuration of Access Manager Runtime for Java completed successfully.&lt;br /&gt;&lt;br /&gt;* In $HOME/.bashrc or /root/.bashrc, add following line:&lt;br /&gt;&lt;br /&gt;export CLASSPATH=/usr/java/jre1.6.0_30/lib/ext/PD.jar:$CLASSPATH&lt;br /&gt;&lt;br /&gt;* Run this command on terminal&lt;br /&gt;$echo $CLASSPATH&lt;br /&gt;&lt;br /&gt;Output should be:&amp;nbsp;/usr/java/jre1.6.0_30/lib/ext/PD.jar:/usr/java/jdk1.6.0_32/lib/tools.jar:./&lt;br /&gt;&lt;br /&gt;* Run this command on the terminal&lt;br /&gt;$cat /opt/PolicyDirector/etc/pdjrte_paths&lt;br /&gt;&lt;br /&gt;Output should be: /opt/IBM/WebSphere/AppServer/java/jre&lt;br /&gt;/usr/java/jre1.6.0_30&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Run&amp;nbsp;com.tivoli.pd.jcfg.SvrSslCfg Utility&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;Configure Your Application:&lt;br /&gt;$java -Dpd.cfg.home=/opt/IBM/WebSphere/AppServer/java/jre com.tivoli.pd.jcfg.SvrSslCfg -action config -admin_id sec_master -admin_pwd object00 -appsvr_id tameb -port 8880 -mode local -policysvr tameb:7135:1 -authzsvr tameb:7136:1&lt;br /&gt;-cfg_file /opt/PolicyDirector/example/pdadminapi_demo/java/configuration/app.properties&lt;br /&gt;-key_file /opt/PolicyDirector/example/pdadminapi_demo/java/keyfile/app.ks -cfg_action create&lt;br /&gt;&lt;br /&gt;Note:&lt;br /&gt;* If app.ks file already exists then value for -cfg_action will be &#39;replace&#39;&lt;br /&gt;* If you have already configured an application, then before configuring another you have to unconfig previous one using this command&lt;br /&gt;&lt;br /&gt;Unconfig Your Application:&lt;br /&gt;$java -Dpd.cfg.home=/opt/IBM/WebSphere/AppServer/java/jre com.tivoli.pd.jcfg.SvrSslCfg -action unconfig -admin_id sec_master -admin_pwd object00 -appsvr_id tameb -policysvr tameb:7135:1 -cfg_file /opt/PolicyDirector/example/pdadminapi_demo/java/configuration/app.properties&lt;br /&gt;&lt;br /&gt;Now Run your demo application using this command&lt;br /&gt;$java PDAdminDemo sec_master file:///opt/PolicyDirector/example/pdadminapi_demo/java/configuration/app.properties c=us&lt;br /&gt;&lt;br /&gt;Note:&lt;br /&gt;* Your configuration string should start like this, &#39;file:///&#39; (config_str = file:///) or you will get something like specified protocol error.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Exceptions:&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;b&gt;java.lang.ClassNotFoundException: com.ibm.crypto.fips.provider.IBMJCEFIPS&lt;/b&gt;&lt;br /&gt;&lt;b&gt;java.lang.ClassNotFoundException: com.ibm.crypto.provider.IBMJCE&lt;/b&gt;&lt;br /&gt;&lt;b&gt;java.lang.ClassNotFoundException: com.ibm.security.util.DerValue&lt;/b&gt;&lt;br /&gt;&lt;b&gt;java.lang.ClassNotFoundException: com.ibm.jsse2.IBMJSSEProvider2&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Solution:&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Run these commands on terminal or add these lines in $HOME/.bashrc or /root/.bashrc&lt;br /&gt;&lt;br /&gt;export CLASSPATH=/usr/java/jre1.6.0_30/lib/ext/ibmjcefips.jar:$CLASSPATH&lt;br /&gt;export CLASSPATH=/usr/java/jre1.6.0_30/lib/ext/ibmjceprovider.jar:$CLASSPATH&lt;br /&gt;export CLASSPATH=/usr/java/jre1.6.0_30/lib/ext/ibmpkcs.jar:$CLASSPATH&lt;br /&gt;export CLASSPATH=/usr/java/jre1.6.0_30/lib/ext/ibmjsseprovider2.jar:$CLASSPATH&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Exception:&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;b&gt;&quot;HPDJA0109W A nonnull value is being passed to an unsupported argument&quot; is thrown while creating a user using PDUser.createUser&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;b&gt;OR&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;java.util.MissingResourceException: can&#39;t find bundle for base name locale english US:&lt;/b&gt;&lt;br /&gt;&lt;b&gt;PDUser.CreateUser()&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;b&gt;Solution:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;While creating a PD user, value for the description should be null.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Helping Commands:&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;* Check Servers Status&lt;br /&gt;$pd_start status&lt;br /&gt;&lt;br /&gt;* To view process ports&lt;br /&gt;$$lsof -i&lt;br /&gt;&lt;br /&gt;&lt;b&gt;References:&amp;nbsp;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;a href=&quot;http://www-01.ibm.com/support/docview.wss?uid=swg21284688&quot; target=&quot;_blank&quot;&gt;http://www-01.ibm.com/support/docview.wss?uid=swg21284688&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;</description><link>http://usmanali112.blogspot.com/2013/03/ibm-java-comtivolipdjcfgsvrsslcfg.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-fYMIbQfEv9k/UFNBrvCYtwI/AAAAAAAAAKs/zruovt_MOWg/s72-c/IBM.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9057780077077039372.post-2982393120282396110</guid><pubDate>Thu, 26 Jul 2012 18:49:00 +0000</pubDate><atom:updated>2012-09-14T19:40:56.499+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">IBM</category><category domain="http://www.blogger.com/atom/ns#">IBM TAM</category><category domain="http://www.blogger.com/atom/ns#">IBM TDS</category><category domain="http://www.blogger.com/atom/ns#">IBM Tivoli Access Manager</category><category domain="http://www.blogger.com/atom/ns#">IBM Tivoli Directory Server</category><category domain="http://www.blogger.com/atom/ns#">LDAP</category><category domain="http://www.blogger.com/atom/ns#">TDS Password</category><category domain="http://www.blogger.com/atom/ns#">TDS URL</category><category domain="http://www.blogger.com/atom/ns#">TDS Username</category><category domain="http://www.blogger.com/atom/ns#">WAS</category><category domain="http://www.blogger.com/atom/ns#">WAS Password</category><category domain="http://www.blogger.com/atom/ns#">WAS URL</category><category domain="http://www.blogger.com/atom/ns#">WAS Username</category><category domain="http://www.blogger.com/atom/ns#">WebSeal</category><category domain="http://www.blogger.com/atom/ns#">WebSphere Application Server</category><title>IBM: LDAP, WAS, WebSEAL Start Commands and Default Values</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-fYMIbQfEv9k/UFNBrvCYtwI/AAAAAAAAAKs/zruovt_MOWg/s1600/IBM.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://2.bp.blogspot.com/-fYMIbQfEv9k/UFNBrvCYtwI/AAAAAAAAAKs/zruovt_MOWg/s1600/IBM.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;It will help you to start and verify LDAP, WAS, WebSEAL status. Here, I used default values for everything.&lt;br /&gt;&lt;br /&gt;1-Verify Webseal Status:&lt;br /&gt;&amp;nbsp; $pdweb status&lt;br /&gt;&lt;br /&gt;Verify LDAP, WAS, Webseal Status:&lt;br /&gt;&amp;nbsp; $pd_start status&lt;br /&gt;&lt;br /&gt;2-Start WebSphere Application Server (WAS):&lt;br /&gt;&amp;nbsp; $cd /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin&lt;br /&gt;&amp;nbsp; $./startServer.sh server1 &amp;nbsp; &amp;nbsp;//server1 is the WAS instance name&lt;br /&gt;&lt;br /&gt;3-Start LDAP:&lt;br /&gt;&amp;nbsp; $cd /opt/ibm/ldap/V6.1/sbin/&lt;br /&gt;&amp;nbsp; $ibmslapd&lt;br /&gt;&lt;br /&gt;4-Start Webseal:&lt;br /&gt;&amp;nbsp; $cd /opt/pdweb/bin&lt;br /&gt;&amp;nbsp; $pdweb start&lt;br /&gt;&lt;br /&gt;5-Verify Webseal Status (again):&lt;br /&gt;&amp;nbsp; $pdweb status&lt;br /&gt;&lt;br /&gt;Verify LDAP, WAS, Webseal Status (again):&lt;br /&gt;&amp;nbsp; $pd_start status&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;6-TDS URL(LDAP):&lt;br /&gt;&amp;nbsp; http://tameb:9080/IDSWebApp/IDSjsp/Login.jsp&lt;br /&gt;&lt;br /&gt;Note: Here &#39;tameb&#39; is the hostname. It should be written in /etc/hosts to resolve like&lt;br /&gt;tameb 192.168.179.131&lt;br /&gt;&lt;br /&gt;&lt;table border=&quot;1&quot;&gt;&lt;tbody&gt;&lt;tr&gt; &lt;th&gt;Username&lt;/th&gt; &lt;th&gt;Password&lt;/th&gt; &lt;/tr&gt;&lt;tr&gt; &lt;td&gt;superadmin&lt;/td&gt; &lt;td&gt;secret&lt;/td&gt; &lt;/tr&gt;&lt;tr&gt; &lt;td&gt;cn=root&lt;/td&gt; &lt;td&gt;object00&lt;/td&gt; &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;7-WAS Console:&lt;br /&gt;&amp;nbsp; http://tameb:9060/ibm/console/&lt;br /&gt;&lt;br /&gt;&lt;table border=&quot;1&quot;&gt;&lt;tbody&gt;&lt;tr&gt; &lt;th&gt;Admin&lt;/th&gt; &lt;th&gt;Username&lt;/th&gt;  &lt;th&gt;Password&lt;/th&gt; &lt;/tr&gt;&lt;tr&gt; &lt;td&gt;admin&lt;/td&gt; &lt;td&gt;sec_master&lt;/td&gt; &lt;td&gt;object00&lt;/td&gt; &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;LDAP/TDS Default Information:&lt;br /&gt;&lt;br /&gt;&lt;table border=&quot;1&quot;&gt;&lt;tbody&gt;&lt;tr&gt; &lt;th&gt;Attribute&lt;/th&gt; &lt;th&gt;Values&lt;/th&gt; &lt;/tr&gt;&lt;tr&gt; &lt;td&gt;LDAP Hostname&lt;/td&gt; &lt;td&gt;tameb:389 or your_IP:389&lt;/td&gt; &lt;/tr&gt;&lt;tr&gt; &lt;td&gt;User DN&lt;/td&gt; &lt;td&gt;cn=root&lt;/td&gt; &lt;/tr&gt;&lt;tr&gt; &lt;td&gt;Password&lt;/td&gt; &lt;td&gt;object00&lt;/td&gt; &lt;/tr&gt;&lt;tr&gt; &lt;td&gt;Non-SSL Port&lt;/td&gt; &lt;td&gt;389&lt;/td&gt; &lt;/tr&gt;&lt;tr&gt; &lt;td&gt;SSL Port&lt;/td&gt; &lt;td&gt;636&lt;/td&gt; &lt;/tr&gt;&lt;tr&gt; &lt;td&gt;SSL key file&lt;/td&gt; &lt;td&gt;/opt/ibm/ldap/V6.1/lib/am_key.kdb&lt;/td&gt; &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;</description><link>http://usmanali112.blogspot.com/2012/07/ibm-ldap-was-webseal-start-commands-and.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-fYMIbQfEv9k/UFNBrvCYtwI/AAAAAAAAAKs/zruovt_MOWg/s72-c/IBM.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9057780077077039372.post-1319144892993257273</guid><pubDate>Thu, 26 Jul 2012 10:31:00 +0000</pubDate><atom:updated>2012-09-15T00:15:13.891+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">IBM Tivoli Access Manager</category><category domain="http://www.blogger.com/atom/ns#">IBM Tivoli Directory Server</category><category domain="http://www.blogger.com/atom/ns#">ITAM-eb</category><category domain="http://www.blogger.com/atom/ns#">ITDS</category><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">TAM Password policy</category><category domain="http://www.blogger.com/atom/ns#">TAM Password Validation</category><title>Java: IBM Tivoli Access Manager (ITAM-eb) Default Password Validation</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-agSiGMzGPu0/UFOBuECvXYI/AAAAAAAAALE/CCkWtdrEnzU/s1600/ITAM.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://1.bp.blogspot.com/-agSiGMzGPu0/UFOBuECvXYI/AAAAAAAAALE/CCkWtdrEnzU/s1600/ITAM.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;These are the following IBM Tivoli Access Manager (ITAM-eb) &amp;nbsp;password policy parameters and the default values:&lt;br /&gt;&lt;br /&gt;Parameter &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Default Value&lt;br /&gt;min-password-length&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 8&lt;br /&gt;&lt;br /&gt;min-password-alphas&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4&lt;br /&gt;&lt;br /&gt;min-password-non-alphas&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;br /&gt;&lt;br /&gt;max-password-repeated-chars&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;br /&gt;&lt;br /&gt;password-spaces&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;not set&lt;br /&gt;&lt;br /&gt;If you are using IBM Tivoli Directory Server (ITDS) integrated with ITAM-eb, then you can see its password guidelines here:&lt;br /&gt;&lt;a href=&quot;http://pic.dhe.ibm.com/infocenter/tivihelp/v2r1/index.jsp?topic=%2Fcom.ibm.IBMDS.doc%2Fadmin_gd198.htm&quot; target=&quot;_blank&quot;&gt;http://pic.dhe.ibm.com/infocenter/tivihelp/v2r1/index.jsp?topic=%2Fcom.ibm.IBMDS.doc%2Fadmin_gd198.htm&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;This class will help you for IBM Tivoli Access Manager (ITAM-eb) &amp;nbsp;password validation and user email validation.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;background-color: white;&quot;&gt;&lt;/span&gt;&lt;br /&gt;import java.util.regex.Matcher;&lt;br /&gt;import java.util.regex.Pattern;&lt;br /&gt;&lt;br /&gt;// for validations of password&lt;br /&gt;public class Validation {&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// email regular expression&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private static final String EMAIL_PATTERN = &quot;^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$&quot;;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// validate password length&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static boolean passwordLength(String pwd) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;boolean length = false;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;if (pwd.length() &amp;gt;= 8) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;length = true;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return length;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// validate password&#39;s count of alpha characters&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static boolean passwordAlphaCount(String pwd) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;boolean alpha = false;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;int count = 0;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;try {&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;for (int i = 0; i &amp;lt; pwd.length(); i++) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;if (Character.isLetter(pwd.charAt(i)))&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;++count;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;if (count &amp;gt;= 4)&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;alpha = true;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;} catch (Exception ex) {&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return alpha;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// validate password&#39;s count of non alpha characters&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static boolean passwordNonAlphaCount(String pwd) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;boolean nonalpha = false;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;int count = 0;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;try {&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;for (int i = 0; i &amp;lt; pwd.length(); i++) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;if (Character.isDigit(pwd.charAt(i)))&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;++count;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;if (count &amp;gt;= 1)&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;nonalpha = true;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;} catch (Exception ex) {&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return nonalpha;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// validate password&#39;s repetition of characters&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static boolean passwordCharRepeat(String pwd) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;boolean repeat = true;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;for (int i = 2; i &amp;lt; pwd.length(); i++) {&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;if (String.valueOf(pwd.charAt(i - 2)).equals(String.valueOf(pwd.charAt(i - 1)))&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;&amp;amp;&amp;amp; String.valueOf(pwd.charAt(i - 1)).equals(String.valueOf(pwd.charAt(i ))))&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;repeat = false;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return repeat;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// validate IBM Tivoli Access Manager user email&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static boolean emailValidate(final String email) {&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Pattern pattern = Pattern.compile(EMAIL_PATTERN);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Matcher matcher = pattern.matcher(email);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return matcher.matches();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;</description><link>http://usmanali112.blogspot.com/2012/07/java-ibm-tivoli-access-manager-itam-eb.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-agSiGMzGPu0/UFOBuECvXYI/AAAAAAAAALE/CCkWtdrEnzU/s72-c/ITAM.jpg" height="72" width="72"/><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9057780077077039372.post-2963619199829979467</guid><pubDate>Thu, 26 Jul 2012 09:44:00 +0000</pubDate><atom:updated>2012-09-15T00:23:59.920+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">com.tivoli.pd.jadmin</category><category domain="http://www.blogger.com/atom/ns#">com.tivoli.pd.jutil</category><category domain="http://www.blogger.com/atom/ns#">Get ITAM-eb User Account</category><category domain="http://www.blogger.com/atom/ns#">IBM Tivoli Access Manager</category><category domain="http://www.blogger.com/atom/ns#">ITAM-eb</category><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">Set ITAM-eb User Account</category><category domain="http://www.blogger.com/atom/ns#">TAM Java API</category><title>Java: Get/Set Valid User Account of IBM Tivoli Access Manager (ITAM-eb)</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-agSiGMzGPu0/UFOBuECvXYI/AAAAAAAAALE/CCkWtdrEnzU/s1600/ITAM.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://1.bp.blogspot.com/-agSiGMzGPu0/UFOBuECvXYI/AAAAAAAAALE/CCkWtdrEnzU/s1600/ITAM.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;This will help you to get/set valid user account of IBM Tivoli Access Manager (ITAM-eb) using TAM Java API. Please configure your environment before running this. Your PATH, CLASSPATH, JAVAHOME environmental variables should be set before running this and you have to include PD.jar in your project and classpath. Configuration for TAM-eb should be correct otherwise there will be some problems with it. For conection with IBM Tivoli Access Manager (ITAM-eb) visit: &amp;nbsp;&amp;nbsp;&lt;a href=&quot;http://usmanali112.blogspot.com/2012/07/java-connection-with-ibm-tivoli-access.html&quot; target=&quot;_blank&quot;&gt;http://usmanali112.blogspot.com/2012/07/java-connection-with-ibm-tivoli-access.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;import com.tivoli.pd.jadmin.PDUser;&lt;br /&gt;import com.tivoli.pd.jutil.PDContext;&lt;br /&gt;import com.tivoli.pd.jutil.PDMessages;&lt;br /&gt;&lt;br /&gt;// service for TAM user&lt;br /&gt;public class UserService {&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private PDMessages msgs = new PDMessages();&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// to get user account is valid or invalid&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public boolean getValidAccount(String name) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;boolean valid = false;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;try {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; &amp;nbsp;// Initialize administration API Context&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt; &amp;nbsp; &amp;nbsp;ctxt = TAMConnection.InitializeContext();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;PDUser pdUser = new PDUser(ctxt, name, msgs);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;valid = pdUser.isAccountValid();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;// Close administration API Context&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;TAMConnection.CloseContext(msgs);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}catch (Exception ex) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ex.getMessage();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return valid;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// to set user account to valid or invalid&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void setValidAccount(String name, boolean valid) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;PDContext ctxt = null;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;try {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;// Initialize administration API Context&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ctxt = TAMConnection.InitializeContext();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;PDUser pdUser = new PDUser(ctxt, name, msgs);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;pdUser.setAccountValid(ctxt, valid, msgs);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;System.out.println(pdUser.isAccountValid());&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;// Close administration API Context&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;TAMConnection.CloseContext(msgs);&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;} catch (Exception ex) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ex.getMessage();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://usmanali112.blogspot.com/2012/07/java-getset-valid-user-account-of-ibm.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-agSiGMzGPu0/UFOBuECvXYI/AAAAAAAAALE/CCkWtdrEnzU/s72-c/ITAM.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9057780077077039372.post-4818284247520960574</guid><pubDate>Thu, 26 Jul 2012 09:33:00 +0000</pubDate><atom:updated>2012-09-15T01:11:53.278+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">com.tivoli.pd.jadmin</category><category domain="http://www.blogger.com/atom/ns#">com.tivoli.pd.jutil</category><category domain="http://www.blogger.com/atom/ns#">Get All TAM users List</category><category domain="http://www.blogger.com/atom/ns#">IBM Tivoli Access Manager</category><category domain="http://www.blogger.com/atom/ns#">ITAM-eb</category><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">Set User Password</category><category domain="http://www.blogger.com/atom/ns#">TAM Java API</category><title>Java: Set User Password and Show Users list of IBM Tivoli Access Manager (ITAM-eb)</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-agSiGMzGPu0/UFOBuECvXYI/AAAAAAAAALE/CCkWtdrEnzU/s1600/ITAM.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://1.bp.blogspot.com/-agSiGMzGPu0/UFOBuECvXYI/AAAAAAAAALE/CCkWtdrEnzU/s1600/ITAM.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;This will help you to set user password and show all users list of IBM Tivoli Access Manager (ITAM-eb) using TAM Java API. Please configure your environment before running this. Your PATH, CLASSPATH, JAVAHOME environmental variables should be set before running this and you have to include PD.jar in your project and classpath. Configuration for TAM-eb should be correct otherwise there will be some problems with it. For conection with IBM Tivoli Access Manager (ITAM-eb) visit: &amp;nbsp;&amp;nbsp;&lt;a href=&quot;http://usmanali112.blogspot.com/2012/07/java-connection-with-ibm-tivoli-access.html&quot; target=&quot;_blank&quot;&gt;http://usmanali112.blogspot.com/2012/07/java-connection-with-ibm-tivoli-access.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;import java.util.ArrayList;&lt;br /&gt;import com.tivoli.pd.jadmin.PDUser;&lt;br /&gt;import com.tivoli.pd.jutil.PDContext;&lt;br /&gt;import com.tivoli.pd.jutil.PDMessages;&lt;br /&gt;&lt;br /&gt;// service for TAM user&lt;br /&gt;public class UserService {&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private PDMessages msgs = new PDMessages();&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// to get list of all users&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public ArrayList&amp;lt;String&amp;gt; listUser() {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;PDContext ctxt = null;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ArrayList&amp;lt;String&amp;gt; list = null;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;try {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;// Initialize administration API Context&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ctxt = TAMConnection.InitializeContext();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;list = PDUser.listUsers(ctxt,&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;PDUser.PDUSER_ALLPATTERN, PDUser.PDUSER_MAXRETURN, false,&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;msgs); // (context, pattern, maximum return, list by&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;// registry name, messages)&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;// Close administration API Context&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;TAMConnection.CloseContext(msgs);&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;} catch (Exception ex) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ex.getMessage();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return list;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// to set TAM user password&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void setPassword(String name, String password) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;PDContext ctxt = null;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;try {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;// Initialize administration API Context&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ctxt = TAMConnection.InitializeContext();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;PDUser pdUser = new PDUser(ctxt, name, msgs);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;pdUser.setPassword(ctxt, password.toCharArray(), msgs);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;// Close administration API Context&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;TAMConnection.CloseContext(msgs);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;} catch (Exception ex) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ex.getMessage();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://usmanali112.blogspot.com/2012/07/java-set-user-password-and-show-users.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-agSiGMzGPu0/UFOBuECvXYI/AAAAAAAAALE/CCkWtdrEnzU/s72-c/ITAM.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9057780077077039372.post-194531889112687760</guid><pubDate>Thu, 26 Jul 2012 09:24:00 +0000</pubDate><atom:updated>2012-09-15T01:13:52.792+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Add TAM User</category><category domain="http://www.blogger.com/atom/ns#">com.tivoli.pd.jadmin</category><category domain="http://www.blogger.com/atom/ns#">com.tivoli.pd.jutil</category><category domain="http://www.blogger.com/atom/ns#">Delete TAM User</category><category domain="http://www.blogger.com/atom/ns#">IBM Tivoli Access Manager</category><category domain="http://www.blogger.com/atom/ns#">ITAM-eb</category><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">TAM Java API</category><title>Java: Add/Delete User of IBM Tivoli Access Manager (ITAM-eb)</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-agSiGMzGPu0/UFOBuECvXYI/AAAAAAAAALE/CCkWtdrEnzU/s1600/ITAM.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://1.bp.blogspot.com/-agSiGMzGPu0/UFOBuECvXYI/AAAAAAAAALE/CCkWtdrEnzU/s1600/ITAM.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;This will help you to add/delete user of IBM Tivoli Access Manager (ITAM-eb) using TAM Java API. Please configure your environment before running this. Your PATH, CLASSPATH, JAVAHOME environmental variables should be set before running this and you have to include PD.jar in your project and classpath. Configuration for TAM-eb should be correct otherwise there will be some problems with it. I used default values here which you have to change according to your requirements. For conection with IBM Tivoli Access Manager (ITAM-eb) visit: &amp;nbsp;&lt;a href=&quot;http://usmanali112.blogspot.com/2012/07/java-connection-with-ibm-tivoli-access.html&quot; target=&quot;_blank&quot;&gt; http://usmanali112.blogspot.com/2012/07/java-connection-with-ibm-tivoli-access.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;import com.tivoli.pd.jadmin.PDUser;&lt;br /&gt;import com.tivoli.pd.jutil.PDContext;&lt;br /&gt;import com.tivoli.pd.jutil.PDMessages;&lt;br /&gt;import com.tivoli.pd.jutil.PDRgyUserName;&lt;br /&gt;&lt;br /&gt;// service for TAM user&lt;br /&gt;public class UserService {&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// to set default values for User services&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private String rgySuffix = &quot;c=us&quot;;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private PDMessages msgs = new PDMessages();&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// create user in TAM&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void createUser(String firstName, String lastName,&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;String password, String group) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;PDContext ctxt = null;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;PDRgyUserName pdRgyUserName = null;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;ArrayList&amp;lt;String&amp;gt; groupList = new ArrayList&amp;lt;String&amp;gt;();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;// Set default values to create user&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String name = firstName + &quot; &quot; + lastName;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;boolean ssoUser = true;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;boolean pwdPolicy = true;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;try {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;// Initialize administration API Context&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;ctxt = TAMConnection.InitializeContext();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;String rgyName = &quot;cn=&quot; + name + &quot;,&quot; + rgySuffix;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;pdRgyUserName = new PDRgyUserName(rgyName, firstName, lastName);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;groupList.add(group);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;PDUser.createUser(ctxt, name, pdRgyUserName, null,&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt;password.toCharArray(), groupList, ssoUser, pwdPolicy,&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt;msgs);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;PDUser pdUser = new PDUser(ctxt, name, msgs);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;pdUser.setAccountValid(ctxt, true, msgs);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;// Close administration API Context&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;TAMConnection.CloseContext(msgs);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}catch (Exception ex) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ex.getMessage();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return result;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// to delete TAM user&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void deleteUser(String name) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;PDContext ctxt = null;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;try {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;// Initialize administration API Context&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ctxt = TAMConnection.InitializeContext();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;PDUser.deleteUser(ctxt, name, true, msgs);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;// Close administration API Context&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;TAMConnection.CloseContext(msgs);&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;} catch (Exception ex) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ex.getMessage();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;</description><link>http://usmanali112.blogspot.com/2012/07/java-adddelete-user-of-ibm-tivoli.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-agSiGMzGPu0/UFOBuECvXYI/AAAAAAAAALE/CCkWtdrEnzU/s72-c/ITAM.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9057780077077039372.post-8586873053364274323</guid><pubDate>Wed, 25 Jul 2012 19:22:00 +0000</pubDate><atom:updated>2012-09-15T01:14:57.629+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Add TAM group</category><category domain="http://www.blogger.com/atom/ns#">com.tivoli.pd.jadmin</category><category domain="http://www.blogger.com/atom/ns#">com.tivoli.pd.jutil</category><category domain="http://www.blogger.com/atom/ns#">Delete TAM group</category><category domain="http://www.blogger.com/atom/ns#">Get All TAM groups List</category><category domain="http://www.blogger.com/atom/ns#">IBM Tivoli Access Manager</category><category domain="http://www.blogger.com/atom/ns#">ITAM-eb</category><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">TAM Java API</category><title>Java: Add/Delete Group and Show Groups list of IBM Tivoli Access Manager (ITAM-eb)</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-agSiGMzGPu0/UFOBuECvXYI/AAAAAAAAALE/CCkWtdrEnzU/s1600/ITAM.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://1.bp.blogspot.com/-agSiGMzGPu0/UFOBuECvXYI/AAAAAAAAALE/CCkWtdrEnzU/s1600/ITAM.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;This will help you to add/delete group and get all groups list of IBM Tivoli Access Manager (ITAM-eb) using TAM Java API. Please configure your environment before running this. Your PATH, CLASSPATH, JAVAHOME environmental variables should be set before running this and you have to include PD.jar in your project and classpath. Configuration for TAM-eb should be correct otherwise there will be some problems with it. I used default values here which you have to change according to your requirements. For conection with IBM Tivoli Access Manager (ITAM-eb) visit: &amp;nbsp;&amp;nbsp;&lt;a href=&quot;http://usmanali112.blogspot.com/2012/07/java-connection-with-ibm-tivoli-access.html&quot; target=&quot;_blank&quot;&gt;http://usmanali112.blogspot.com/2012/07/java-connection-with-ibm-tivoli-access.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;import java.util.ArrayList;&lt;br /&gt;import com.tivoli.pd.jadmin.PDGroup;&lt;br /&gt;import com.tivoli.pd.jutil.PDContext;&lt;br /&gt;import com.tivoli.pd.jutil.PDMessages;&lt;br /&gt;import com.tivoli.pd.jutil.PDRgyGroupName;&lt;br /&gt;&lt;br /&gt;// service for the TAM groups&lt;br /&gt;public class GroupService {&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private String rgySuffix = &quot;c=us&quot;;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private PDMessages msgs = new PDMessages();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// create group in TAM&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void createGroup(String group) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;PDContext ctxt = null;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;try {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ctxt = TAMConnection.InitializeContext();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;this.rgySuffix = TAMConnection.registrysuffix;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;String rgyGroup = &quot;cn=&quot; + group + &quot;,&quot; + rgySuffix;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;PDRgyGroupName pdRgyGroupName = new PDRgyGroupName(rgyGroup);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;PDGroup.createGroup(ctxt, group, pdRgyGroupName, null, null, msgs); &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;                  &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;TAMConnection.CloseContext(msgs);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;} catch (Exception ex) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ex.getMessage();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// to delete group from TAM&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void deleteGroup(String group) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;PDContext ctxt = null;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;try {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ctxt = TAMConnection.InitializeContext();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;PDGroup.deleteGroup(ctxt, group, true, msgs);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;TAMConnection.CloseContext(msgs);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;} catch (Exception ex) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ex.getMessage();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// to get all groups from TAM&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public ArrayList&amp;lt;String&amp;gt; getGroup() {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;PDContext ctxt = null;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ArrayList&amp;lt;String&amp;gt; list = null;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;try {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ctxt = TAMConnection.InitializeContext();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;list = PDGroup.listGroups(ctxt,&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;PDGroup.PDGROUP_ALLPATTERN, PDGroup.PDGROUP_MAXRETURN,&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;true, msgs);&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;TAMConnection.CloseContext(msgs);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;} &amp;nbsp;catch (Exception ex) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ex.getMessage();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return list;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;}&lt;/div&gt;</description><link>http://usmanali112.blogspot.com/2012/07/java-adddelete-group-and-get-all-groups.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-agSiGMzGPu0/UFOBuECvXYI/AAAAAAAAALE/CCkWtdrEnzU/s72-c/ITAM.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9057780077077039372.post-2735606218118457391</guid><pubDate>Wed, 25 Jul 2012 13:52:00 +0000</pubDate><atom:updated>2012-07-26T13:25:42.765+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">com.tivoli.pd.jcfg.SvrSslCfg</category><category domain="http://www.blogger.com/atom/ns#">Connection with TAM</category><category domain="http://www.blogger.com/atom/ns#">IBM Tivoli Access Manager</category><category domain="http://www.blogger.com/atom/ns#">ITAM-eb</category><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">PD.jar</category><title>Java: Connection with IBM Tivoli Access Manager (ITAM-eb)</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;This will help you to create connection with&amp;nbsp;IBM Tivoli Access Manager (ITAM-eb) using TAM Java API. Please configure your environment before running this. Your PATH, CLASSPATH, JAVAHOME environmental variables should be set before running this and you have to include PD.jar in your project and classpath. Configuration for TAM-eb should be correct otherwise there will be some problems with it. I have used default values for the connection, so you can modify these according your environment settings. The most important part is the use of&amp;nbsp;com.tivoli.pd.jcfg.SvrSslCfg utility.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;import java.util.*;&lt;br /&gt;import java.net.URL;&lt;br /&gt;&lt;br /&gt;import com.tivoli.pd.jutil.PDContext;&lt;br /&gt;import com.tivoli.pd.jadmin.*;&lt;br /&gt;&lt;br /&gt;// to connect TAM&lt;br /&gt;public class TAMConnection {&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// Set up values for TAM Context Initialization&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private static PDContext ctxt = null;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private PDMessages msgs = new PDMessages();&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// Set up default values for TAM connection and change all values according to your environment&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;//app.properties will be generated with com.tivoli.pd.jcfg.SvrSslCfg utility&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private static String prog &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = &quot;TAMConnection&quot;;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private static String adminName &amp;nbsp; &amp;nbsp; &amp;nbsp;= &quot;sec_master&quot;;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private static String configURLStr &amp;nbsp; = &quot;file:///root/Desktop/app.properties&quot;;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private static String registrysuffix = &quot;c=us&quot;;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private static char[] adminPassword &amp;nbsp;= {&#39;o&#39;,&#39;b&#39;,&#39;j&#39;,&#39;e&#39;,&#39;c&#39;,&#39;t&#39;,&#39;0&#39;,&#39;0&#39;,&#39;\0&#39;};&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private Locale locale &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= new Locale(&quot;ENGLISH&quot;, &quot;US&quot;);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private URL configURL &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= null;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private TAMConnection() {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;try {&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;PDAdmin.initialize(prog, msgs);&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;configURL = new URL(configURLStr);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ctxt = new PDContext(locale, adminName, adminPassword, configURL);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;} catch (Exception ex) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ex.getMessage();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// to initialize the TAM context&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static PDContext InitializeContext() {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;new TAMConnection();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return ctxt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// to close the TAM context&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static void CloseContext(PDMessages msgs) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;try {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;if (ctxt != null) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;ctxt.close();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;PDAdmin.shutdown(msgs);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;} catch (Exception ex) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ex.getMessage();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;}&lt;/div&gt;</description><link>http://usmanali112.blogspot.com/2012/07/java-connection-with-ibm-tivoli-access.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9057780077077039372.post-2275238317041479395</guid><pubDate>Wed, 25 Jul 2012 13:28:00 +0000</pubDate><atom:updated>2012-07-26T14:56:16.498+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Add TDS/LDAP User Attribute</category><category domain="http://www.blogger.com/atom/ns#">Delete TDS/LDAP User Attribute</category><category domain="http://www.blogger.com/atom/ns#">IBM TDS</category><category domain="http://www.blogger.com/atom/ns#">IBM Tivoli Directory Server</category><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">Java Naming and Directory Interface</category><category domain="http://www.blogger.com/atom/ns#">JNDI</category><category domain="http://www.blogger.com/atom/ns#">LDAP</category><category domain="http://www.blogger.com/atom/ns#">Modify User Attributes</category><category domain="http://www.blogger.com/atom/ns#">Replace TDS/LDAP User Attribute</category><title>Java: Modify User Attributes in IBM Tivoli Directory Server (TDS) LDAP using JNDI</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;It will help you to modify user attribute (add, replace, delete) in IBM Tivoli Directory Server (TDS) using JNDI. I used default values, so you have to change it according your requirements. Also the user attributes will depend upon your directory server schema.For connection with IBM Tivoli Directory Server (TDS)/&amp;nbsp;&lt;a href=&quot;http://www.blogger.com/LDAP%20visit:%20http://usmanali112.blogspot.com/2012/07/java-authentication-and-connection-with.html&quot; target=&quot;_blank&quot;&gt;LDAP visit: http://usmanali112.blogspot.com/2012/07/java-authentication-and-connection-with.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;import javax.naming.ldap.InitialLdapContext;&lt;br /&gt;import javax.naming.directory.*;&lt;br /&gt;&lt;br /&gt;//this class perform all LDAP actions for the user&lt;br /&gt;public class LDAPService {&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private String base = &quot;c=us&quot;; // base for LDAP&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private String realm = &quot;cn=realm1&quot;; // LDAP realm for user&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// to set user password&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void setPassword(String surname, String password) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;try {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;// Set up default values for LDAP information&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;String distinguish_name = &quot;sn=&quot; + surname + &quot;,&quot; + realm + &quot;,&quot;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;+ base;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;// Initialize LDAP Context&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;InitialLdapContext context = LDAPConnection.InitializeContext();&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ModificationItem[] mods = new ModificationItem[1];&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;Attribute mod0 = new BasicAttribute(&quot;userpassword&quot;, password);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;mods[0] = new ModificationItem(DirContext.REPLACE_ATTRIBUTE, mod0);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//use DirContext.ADD_ATTRIBUTE to add an attribute&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;//use DirContext.DELETE_ATTRIBUTE to delete an attribute&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;// Perform modification of user&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;context.modifyAttributes(distinguish_name, mods);&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;// Close LDAP Context&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;LDAPConnection.CloseContext();&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;} catch (Exception ex) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ex.getMessage();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;}&lt;/div&gt;</description><link>http://usmanali112.blogspot.com/2012/07/java-modify-user-attributes-in-ibm.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9057780077077039372.post-2764053766858121842</guid><pubDate>Wed, 25 Jul 2012 13:02:00 +0000</pubDate><atom:updated>2012-07-26T13:23:42.364+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">IBM TDS</category><category domain="http://www.blogger.com/atom/ns#">IBM Tivoli Directory Server</category><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">Java Naming and Directory Interface</category><category domain="http://www.blogger.com/atom/ns#">JNDI</category><category domain="http://www.blogger.com/atom/ns#">LDAP</category><category domain="http://www.blogger.com/atom/ns#">Search in LDAP</category><category domain="http://www.blogger.com/atom/ns#">Search User</category><title>Java: Search User in IBM Tivoli Directory Server (TDS) LDAP using JNDI</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;It will help you to search user and other entries in IBM Tivoli Directory Server (TDS) using JNDI. I used default values, so you have to change it according your requirements. Also the user attributes will depend upon your directory server schema. For connection with IBM Tivoli Directory Server (TDS)/ LDAP visit:&amp;nbsp;&lt;a href=&quot;http://usmanali112.blogspot.com/2012/07/java-authentication-and-connection-with.html&quot; target=&quot;_blank&quot;&gt;http://usmanali112.blogspot.com/2012/07/java-authentication-and-connection-with.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;import javax.naming.NamingEnumeration;&lt;br /&gt;import javax.naming.ldap.InitialLdapContext;&lt;br /&gt;import javax.naming.directory.*;&lt;br /&gt;&lt;br /&gt;//this class perform all LDAP actions for the user&lt;br /&gt;public class LDAPService {&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private String base = &quot;c=us&quot;; // base for LDAP&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private String realm = &quot;cn=realm1&quot;; // LDAP realm for user&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public void getUserInfo(String name) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;String dn = &quot;sn=&quot; + name + &quot;,&quot; + realm + &quot;,&quot; + base;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;try {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;// Initialize LDAP Context&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;InitialLdapContext context = LDAPConnection.InitializeContext();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;String[] att = { &quot;givenName&quot;, &quot;mail&quot; };&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;// Set up Search Controls&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;SearchControls sc = new SearchControls();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;sc.setSearchScope(SearchControls.SUBTREE_SCOPE);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;sc.setReturningAttributes(att);&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;// perform search on directory&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;NamingEnumeration results = context.search(base,&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;&quot;(objectclass=inetorgperson)&quot;, sc);&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;while (results.hasMore()) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;SearchResult sr = (SearchResult) results.next();&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;// get the attributes and attribute list&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;Attributes atts = sr.getAttributes();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;NamingEnumeration attrList = atts.getAll();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;if (dn.equals(sr.getName() + &quot;,&quot; + base)) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;// while we have attributes&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;while (attrList.hasMore()) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt;Attribute attr = (Attribute) attrList.next();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt;NamingEnumeration values = attr.getAll();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt;String id, value = &quot;&quot;;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt;while (values.hasMore()) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;id = attr.getID();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;value = values.next().toString();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;       &lt;/span&gt;System.out.println(id + &quot; &quot; + value);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;      &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;     &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;// Close LDAP Context&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;LDAPConnection.CloseContext();&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;} catch (Exception ex) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ex.getMessage();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br class=&quot;Apple-interchange-newline&quot; /&gt;&lt;/div&gt;</description><link>http://usmanali112.blogspot.com/2012/07/java-search-user-in-ibm-tivoli.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>5</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9057780077077039372.post-4423061072531947733</guid><pubDate>Wed, 25 Jul 2012 12:18:00 +0000</pubDate><atom:updated>2012-07-26T12:25:01.115+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Add User</category><category domain="http://www.blogger.com/atom/ns#">IBM TDS</category><category domain="http://www.blogger.com/atom/ns#">IBM Tivoli Directory Server</category><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">Java Naming and Directory Interface</category><category domain="http://www.blogger.com/atom/ns#">JNDI</category><category domain="http://www.blogger.com/atom/ns#">LDAP</category><title>Java: Add User in IBM Tivoli Directory Server (TDS) LDAP using JNDI</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;It will help you to add user or other entries in&amp;nbsp;IBM Tivoli Directory Server (TDS) using JNDI. I used default values and my own user information, so you have to change it according your requirements. Also the user attributes will depend upon your directory server schema. For connection with&amp;nbsp;&amp;nbsp;IBM Tivoli Directory Server (TDS)/ LDAP visit:&amp;nbsp;&lt;a href=&quot;http://usmanali112.blogspot.com/2012/07/java-authentication-and-connection-with.html&quot;&gt;http://usmanali112.blogspot.com/2012/07/java-authentication-and-connection-with.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;import javax.naming.ldap.InitialLdapContext;&lt;br /&gt;import javax.naming.directory.*;&lt;br /&gt;&lt;br /&gt;//this class perform all LDAP actions for the user&lt;br /&gt;public class LDAPService {&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private String base = &quot;c=us&quot;; // base for LDAP&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private String realm = &quot;cn=realm1&quot;; // LDAP realm for user&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// User information&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private String surname = &quot;Ali&quot;; // user surname&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private String givenname = &quot;Usman&quot;; // user given name or first name&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private String userpassword = &quot;********&quot;; // user password&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private String email = &quot;usmanalibutt9393@gmail.com&quot;; // user email&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private String distinguish_name = &quot;sn=&quot; + surname + &quot;,&quot; + realm + &quot;,&quot; + base;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// to add user in LDAP (TDS)&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void addUser() {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;try {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;InitialLdapContext context = LDAPConnection.InitializeContext();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;Attributes attributes = new BasicAttributes();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;Attribute objectClass = new BasicAttribute(&quot;objectClass&quot;);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;objectClass.add(&quot;inetOrgPerson&quot;);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;attributes.put(objectClass);&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;// Define User attributes&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;attributes.put(&quot;sn&quot;, surname);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;attributes.put(&quot;givenName&quot;, givenname);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;attributes.put(&quot;userPassword&quot;, userpassword);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;attributes.put(&quot;mail&quot;, email);&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;// call API to add user&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;context.createSubcontext(distinguish_name, attributes);&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;// Close LDAP Context&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;    &lt;/span&gt;LDAPConnection.CloseContext();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;} catch (Exception ex) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ex.getMessage();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;}&lt;/div&gt;</description><link>http://usmanali112.blogspot.com/2012/07/java-add-user-in-ibm-tivoli-directory.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9057780077077039372.post-6403917675506716051</guid><pubDate>Wed, 25 Jul 2012 11:49:00 +0000</pubDate><atom:updated>2012-07-26T12:17:25.708+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Authentication</category><category domain="http://www.blogger.com/atom/ns#">Connection with LDAP</category><category domain="http://www.blogger.com/atom/ns#">Connection with TDS</category><category domain="http://www.blogger.com/atom/ns#">IBM TDS</category><category domain="http://www.blogger.com/atom/ns#">IBM Tivoli Directory Server</category><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">Java Naming and Directory Interface</category><category domain="http://www.blogger.com/atom/ns#">JNDI</category><category domain="http://www.blogger.com/atom/ns#">LDAP</category><category domain="http://www.blogger.com/atom/ns#">Lightweight Directory Access Protocol</category><category domain="http://www.blogger.com/atom/ns#">SSL</category><title>Java: Authentication and Connection with LDAP using JNDI</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;This will help you to connect with LDAP using JNDI (Java Naming and Directory Interface). I used this to connect with IBM Tivoli Directory Server (TDS). The connection with LDAP will be on SSL and you can modify it for non SSL too. You can also authenticate a user of IBM Tivoli Directory Server (TDS). If user exists then he will be authenticated otherwise the given authentication method will throw an exception. I have used all default values for the connection, you should change all values according your environment settings.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;import java.util.HashMap;&lt;br /&gt;import java.util.Hashtable;&lt;br /&gt;import javax.naming.ldap.InitialLdapContext;&lt;br /&gt;&lt;br /&gt;// this class is for LDAP Connection&lt;br /&gt;public class LDAPConnection {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// Set up values for LDAP Context Initialization&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private static InitialLdapContext ctx = null;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private static Hashtable&amp;lt;String, String&amp;gt; hashtable = null;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// Set up default parameters for LDAP connection&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private static String urlparam = &quot;java.naming.provider.url&quot;;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private static String usernameparam = &quot;java.naming.security.principal&quot;;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private static String passwordparam = &quot;java.naming.security.credentials&quot;;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private static String versionparam = &quot;java.naming.ldap.version&quot;;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private static String factory_initialparam = &quot;java.naming.factory.initial&quot;;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private static String authenticationparam = &quot;java.naming.security.authentication&quot;;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private static String protocolparam = &quot;java.naming.security.protocol&quot;;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private static String referralparam = &quot;java.naming.referral&quot;;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// Set up default values for LDAP connection&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private static String url = &quot;ldap://tameb:636&quot;; &amp;nbsp; // for non SSL use port &#39;389&#39;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private static String username = &quot;cn=root&quot;;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private static String password = &quot;object00&quot;;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private static String version = &quot;3&quot;;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private static String factory_initial = &quot;com.sun.jndi.ldap.LdapCtxFactory&quot;;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private static String authentication = &quot;simple&quot;;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private static String protocol = &quot;ssl&quot;;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private static String referral = &quot;follow&quot;;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static String base = &quot;c=us&quot;;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static String realm = &quot;cn=realm1&quot;;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// Provide java trust store parameters where LDAP certificates are imported (in case of &amp;nbsp;SSL)&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private static String truststoreparam = &quot;javax.net.ssl.trustStore&quot;;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private static String ts_passwordparam = &quot;javax.net.ssl.trustStorePassword&quot;;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// Provide java trust store values where LDAP certificates are imported (in case of &amp;nbsp;SSL)&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private static String truststore = &quot;/usr/java/jre1.6.0_30/lib/security/cacerts&quot;;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private static String ts_password = &quot;changeit&quot;;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// set connection to LDAP&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private static void setConnection() {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;try {&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;// Set up LDAP configuration settings&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;hashtable = new Hashtable&amp;lt;String, String&amp;gt;();&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;System.setProperty(truststoreparam, truststore);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;System.setProperty(ts_passwordparam, ts_password);&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;hashtable.put(versionparam, version);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;hashtable.put(factory_initialparam, factory_initial);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;hashtable.put(authenticationparam, authentication);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;hashtable.put(protocolparam, protocol);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;hashtable.put(usernameparam, username);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;hashtable.put(passwordparam, password);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;hashtable.put(referralparam, referral);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;hashtable.put(urlparam, url);&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;// Make LDAP connection&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ctx = new InitialLdapContext(hashtable, null);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;} catch (Exception ex) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ex.getMessage();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// initialize and give LDAP connection context&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static InitialLdapContext InitializeContext() {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;setConnection();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return ctx;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// close LDAP connection context&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static void CloseContext() {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;try {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;// Close the connection to LDAP&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ctx.close();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;} catch (Exception ex) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ex.getMessage();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// authenticate LDAP user&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static boolean authenticateUser(String name, String password) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;boolean authenticate = false;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;try {&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;// Set up LDAP configuration settings&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;hashtable = new Hashtable&amp;lt;String, String&amp;gt;();&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;System.setProperty(truststoreparam, truststore);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;System.setProperty(ts_passwordparam, ts_password);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;String username = &quot;sn=&quot; + name + &quot;,&quot; + realm + &quot;,&quot; + base;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;hashtable.put(versionparam, version);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;hashtable.put(factory_initialparam, factory_initial);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;hashtable.put(authenticationparam, authentication);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;hashtable.put(protocolparam, protocol);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;hashtable.put(usernameparam, username);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;hashtable.put(passwordparam, password);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;hashtable.put(referralparam, referral);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;hashtable.put(urlparam, url);&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;// Make LDAP connection&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ctx = new InitialLdapContext(hashtable, null);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;authenticate = true;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;} catch (Exception ex) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;ex.getMessage();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;return authenticate;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;}&lt;/div&gt;</description><link>http://usmanali112.blogspot.com/2012/07/java-authentication-and-connection-with.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9057780077077039372.post-3121948391318155984</guid><pubDate>Tue, 24 Jul 2012 09:33:00 +0000</pubDate><atom:updated>2012-07-26T12:11:58.166+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">Log</category><category domain="http://www.blogger.com/atom/ns#">Log4j</category><category domain="http://www.blogger.com/atom/ns#">Log4j.jar</category><title>Java: Apache Log4j</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;This will help you to make logs of your programs. Please include log4j.jar to run this code. you can download this from following link:&amp;nbsp;&lt;a href=&quot;http://logging.apache.org/log4j/1.2/download.html&quot; target=&quot;_blank&quot;&gt;http://logging.apache.org/log4j/1.2/download.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// The logger class&lt;br /&gt;import java.io.IOException;&lt;br /&gt;import org.apache.log4j.Logger;&lt;br /&gt;import org.apache.log4j.PatternLayout;&lt;br /&gt;import org.apache.log4j.FileAppender;&lt;br /&gt;&lt;br /&gt;public class ServiceLog {&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private static Logger logger = null;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private static String pattern = &quot;&quot;;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private static String logfile = &quot;ServiceLogInformation&quot;;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static void setLog(Logger loging) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;logger = loging;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;pattern += &quot;Milliseconds since program start: %r %n&quot;;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;pattern += &quot;Classname of caller: %C %n&quot;;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;pattern += &quot;Date in ISO8601 format: %d{ISO8601} %n&quot;;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;pattern += &quot;Location of log event: %l %n&quot;;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;pattern += &quot;Message: %m %n %n&quot;;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;PatternLayout layout = new PatternLayout(pattern);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;FileAppender appender = null;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;try {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;appender = new FileAppender(layout, logfile, true);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;} catch (IOException e) {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;e.printStackTrace();&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;logger.addAppender(appender);&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// This class will use above class for logging&lt;br /&gt;import org.apache.log4j.Logger;&lt;br /&gt;&lt;br /&gt;public class Service {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;private static Logger logger = Logger.getLogger(Service.class);&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public static void main(String[] args) {&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;try {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// do something&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; catch (Exception ex) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ServiceLog.setLog(logger);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;logger.setLevel((Level) Level.ERROR);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;logger.error(ex.getMessage());&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br /&gt;}&lt;/div&gt;</description><link>http://usmanali112.blogspot.com/2012/07/java-log4j-making-logs-of-your-program.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9057780077077039372.post-5943324605442480803</guid><pubDate>Mon, 23 Jul 2012 11:50:00 +0000</pubDate><atom:updated>2012-07-26T12:11:01.285+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Linux</category><category domain="http://www.blogger.com/atom/ns#">Samba Client</category><category domain="http://www.blogger.com/atom/ns#">Samba Configuration</category><category domain="http://www.blogger.com/atom/ns#">Samba Server</category><category domain="http://www.blogger.com/atom/ns#">Ubuntu</category><category domain="http://www.blogger.com/atom/ns#">Windows</category><title>Linux: Configure Samba Server on Ubuntu</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;This will describe the configuration of Samba Server on Ubuntu. It will help you to access Ubuntu files in Windows and vice versa.&lt;br /&gt;&lt;br /&gt;•&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;First install samba server in Ubuntu using command line or Ubuntu software center&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $sudo apt-get install samba samba-common&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;We can check its configuration information using&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $gedit /etc/samba/smb.conf&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; or&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $cat /etc/samba/smb.conf&lt;br /&gt;&lt;br /&gt;•&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;To install graphical interface for samba server configuration use this command&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $sudo apt-get install &amp;nbsp;system-config-samba&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-D87bcazPQ0Q/UA00zZEZpOI/AAAAAAAAAIE/g0NAccoIQAM/s1600/samba.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;264&quot; src=&quot;http://2.bp.blogspot.com/-D87bcazPQ0Q/UA00zZEZpOI/AAAAAAAAAIE/g0NAccoIQAM/s320/samba.JPG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;•&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Now share files using this samba server configuration graphical interface. Set the basic options&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-FUAXmbLMIss/UA01CB8M_5I/AAAAAAAAAIM/_btwOX3XV5o/s1600/samba1.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;267&quot; src=&quot;http://1.bp.blogspot.com/-FUAXmbLMIss/UA01CB8M_5I/AAAAAAAAAIM/_btwOX3XV5o/s320/samba1.JPG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;•&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Set the access to files&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-UmpMnccTaI4/UA01DJEWbII/AAAAAAAAAIU/GykSX3UqyOk/s1600/samba2.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;267&quot; src=&quot;http://1.bp.blogspot.com/-UmpMnccTaI4/UA01DJEWbII/AAAAAAAAAIU/GykSX3UqyOk/s320/samba2.JPG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;•&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;The list of directories shared using samba server&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-rGq76ubWC38/UA01EfgzXLI/AAAAAAAAAIc/xJgQ7_VTajU/s1600/samba3.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;266&quot; src=&quot;http://1.bp.blogspot.com/-rGq76ubWC38/UA01EfgzXLI/AAAAAAAAAIc/xJgQ7_VTajU/s320/samba3.JPG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div class=&quot;MsoListParagraph&quot; style=&quot;mso-list: l0 level1 lfo1; text-indent: -.25in;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;•&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Get the ipv4 address of Ubuntu virtual machine.&lt;br /&gt;Note:&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;If you are using virtual box then in network settings of virtual machine use the ‘host only adapter’ option.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-J9TpuJleTsk/UA01FXGkm7I/AAAAAAAAAIk/EoisbmKyo8g/s1600/samba4.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;267&quot; src=&quot;http://2.bp.blogspot.com/-J9TpuJleTsk/UA01FXGkm7I/AAAAAAAAAIk/EoisbmKyo8g/s320/samba4.JPG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;div&gt;?&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Write the Ipv4 address in the address bar in windows explorer. Enter username and password of &amp;nbsp; &amp;nbsp; windows and then windows explorer will show the shared files of Ubuntu virtual machine.&lt;/div&gt;&lt;div&gt;Note:&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Turn off windows7 firewall for network to avoid any inconvenience.&amp;nbsp;&lt;/div&gt;&lt;div&gt;Here the ‘_i’ directory of Ubuntu is shared directly using the sharing options of the directory.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://3.bp.blogspot.com/-ZHWWqkldgQE/UA01GEqmDlI/AAAAAAAAAIs/0YPVnm1dNHk/s1600/samba5.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;179&quot; src=&quot;http://3.bp.blogspot.com/-ZHWWqkldgQE/UA01GEqmDlI/AAAAAAAAAIs/0YPVnm1dNHk/s320/samba5.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;•&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Choose any of the shared directories to open.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-sHI94OJ9y7U/UA01HajMWHI/AAAAAAAAAI0/b06Ll2TOKx4/s1600/samba6.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;179&quot; src=&quot;http://2.bp.blogspot.com/-sHI94OJ9y7U/UA01HajMWHI/AAAAAAAAAI0/b06Ll2TOKx4/s320/samba6.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Samba Client on Windows&lt;/b&gt;&lt;/div&gt;&lt;div&gt;•&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Share any directory of windows using advanced sharing option.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://3.bp.blogspot.com/-bSRVgZNHvwM/UA03exBzHEI/AAAAAAAAAI8/SXCUh9J4SE8/s1600/wsamba.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;179&quot; src=&quot;http://3.bp.blogspot.com/-bSRVgZNHvwM/UA03exBzHEI/AAAAAAAAAI8/SXCUh9J4SE8/s320/wsamba.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;•&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;In Ubuntu, go to the ‘Network’ directory. Here win-7-pc is the Windows shared place. Double click on it.&amp;nbsp;&lt;/div&gt;&lt;div&gt;Note:&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;For first time you have to enter username and password of the Windows to enter in it.&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-AmZfP5payow/UA03gA9DOcI/AAAAAAAAAJE/EogsUHObCKA/s1600/wsamba1.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;266&quot; src=&quot;http://2.bp.blogspot.com/-AmZfP5payow/UA03gA9DOcI/AAAAAAAAAJE/EogsUHObCKA/s320/wsamba1.JPG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;•&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Here is the recently shared directory ‘Abstract’. Double click on it.&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://4.bp.blogspot.com/--aaGECN6Kcg/UA03hGGXrII/AAAAAAAAAJM/EhaZq4vVoaA/s1600/wsamba2.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;266&quot; src=&quot;http://4.bp.blogspot.com/--aaGECN6Kcg/UA03hGGXrII/AAAAAAAAAJM/EhaZq4vVoaA/s320/wsamba2.JPG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;•&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Enter username and password of the Windows and domain will be ‘WORKGROUP’ and press ‘connect’.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://4.bp.blogspot.com/-EKo4kVTtuNQ/UA03h6L4X5I/AAAAAAAAAJU/mLWA2BxAtIc/s1600/wsamba3.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;266&quot; src=&quot;http://4.bp.blogspot.com/-EKo4kVTtuNQ/UA03h6L4X5I/AAAAAAAAAJU/mLWA2BxAtIc/s320/wsamba3.JPG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;•&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Here are the files in the shared directory.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-1jA7PRTVd6I/UA03i0W9KPI/AAAAAAAAAJY/ysj_tdYvqk8/s1600/wsamba4.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;266&quot; src=&quot;http://1.bp.blogspot.com/-1jA7PRTVd6I/UA03i0W9KPI/AAAAAAAAAJY/ysj_tdYvqk8/s320/wsamba4.JPG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;•&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Another example of accessing Ubuntu documents in Windows.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-sZlmS_usGU4/UA041GWQbwI/AAAAAAAAAJk/8eTeM3Xj0vc/s1600/Accessing_Ubuntu_Documents_in_Windows.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;179&quot; src=&quot;http://2.bp.blogspot.com/-sZlmS_usGU4/UA041GWQbwI/AAAAAAAAAJk/8eTeM3Xj0vc/s320/Accessing_Ubuntu_Documents_in_Windows.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;•&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Another example of accessing Windows7 documents in Ubuntu.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-gJs8kke40XQ/UA042611xMI/AAAAAAAAAJs/ieriNjxP1Ts/s1600/Accessing_Windows7_Documents_in_Ubuntu.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;179&quot; src=&quot;http://1.bp.blogspot.com/-gJs8kke40XQ/UA042611xMI/AAAAAAAAAJs/ieriNjxP1Ts/s320/Accessing_Windows7_Documents_in_Ubuntu.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;References:&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;http://sankethpatel.com/blog/?p=128&quot; target=&quot;_blank&quot;&gt;http://sankethpatel.com/blog/?p=128&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;</description><link>http://usmanali112.blogspot.com/2012/07/linux-configure-samba-server-on-ubuntu.html</link><author>noreply@blogger.com (Unknown)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/-D87bcazPQ0Q/UA00zZEZpOI/AAAAAAAAAIE/g0NAccoIQAM/s72-c/samba.JPG" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9057780077077039372.post-7882426561235053151</guid><pubDate>Mon, 23 Jul 2012 11:03:00 +0000</pubDate><atom:updated>2012-07-26T14:57:35.243+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Bash Script Array</category><category domain="http://www.blogger.com/atom/ns#">Bash Shell Scripting</category><category domain="http://www.blogger.com/atom/ns#">Factorial</category><category domain="http://www.blogger.com/atom/ns#">Linux</category><category domain="http://www.blogger.com/atom/ns#">Ubuntu</category><title>Linux: Bash Shell Scripting</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;It will help you to understand Linux bash shell scripting.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Factorial Program&lt;/b&gt;&lt;br /&gt;Save this program in a file and it should be an executable file. Run it from terminal like ./file_name&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;#!/bin/bash&lt;br /&gt;echo -n &quot;enter the number to calculate factorial:&quot;&lt;br /&gt;read number&lt;br /&gt;&lt;br /&gt;input=$number;&lt;br /&gt;fact=1;&lt;br /&gt;&lt;br /&gt;if [ &quot;$input&quot; -eq &quot;0&quot; ]&lt;br /&gt;then&lt;br /&gt;echo -n &quot;factorial of $input is $fact&quot;&lt;br /&gt;exit 1&lt;br /&gt;else&lt;br /&gt;while [ &quot;$input&quot; -ge &quot;1&quot; ]&lt;br /&gt;do&lt;br /&gt;let &quot;fact =$input * $fact&quot;&lt;br /&gt;&lt;br /&gt;input=$((input-1))&lt;br /&gt;done&lt;br /&gt;fi&lt;br /&gt;echo -n &quot;factorial of $number is $fact&quot;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Array Program&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Save this program in a file and it should be an executable file. Run it from terminal like ./file_name &lt;br /&gt;&lt;br /&gt;#!/bin/bash&lt;br /&gt;echo &quot;enter length of array&quot;&lt;br /&gt;read len1;&lt;br /&gt;declare -a arr;&lt;br /&gt;declare -a arr2;&lt;br /&gt;i=0;&lt;br /&gt;while((&quot;$i&quot; &amp;lt; &quot;$len1&quot;))&lt;br /&gt;do&lt;br /&gt;read num1;&lt;br /&gt;arr[$i]=$num1;&lt;br /&gt;i=$((i+1));&lt;br /&gt;done&lt;br /&gt;&lt;br /&gt;echo &quot;2nd array&quot;&lt;br /&gt;j=0;&lt;br /&gt;while((&quot;$j&quot; &amp;lt; &quot;$len1&quot;))&lt;br /&gt;do&lt;br /&gt;read num;&lt;br /&gt;arr2[$j]=$num;&lt;br /&gt;j=$((j+1));&lt;br /&gt;done&lt;br /&gt;&lt;br /&gt;echo &quot;Arrays multiplication result is &quot;&lt;br /&gt;k=0;&lt;br /&gt;&lt;br /&gt;while((&quot;$k&quot; &amp;lt; &quot;$len1&quot;))&lt;br /&gt;do&lt;br /&gt;&amp;nbsp;let &quot;res = ${arr[$k]} * ${arr2[$k]}&quot;&lt;br /&gt;&amp;nbsp;k=$((k+1));&lt;br /&gt;&amp;nbsp;echo &quot;$res&quot;&lt;br /&gt;done&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;</description><link>http://usmanali112.blogspot.com/2012/07/linux-bash-shell-scripting.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9057780077077039372.post-1989863876935995975</guid><pubDate>Mon, 23 Jul 2012 10:21:00 +0000</pubDate><atom:updated>2012-07-26T12:09:24.793+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Commands</category><category domain="http://www.blogger.com/atom/ns#">Linux</category><category domain="http://www.blogger.com/atom/ns#">Process Management</category><title>Linux: Process Management Commands</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;This lab will help you to learn commands for process management.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;• &amp;nbsp; Start a foreground process, move it to the background and kill it using PID.&lt;br /&gt;Ans. Lets suppose we have 2 files opened in gedit&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $fg %2&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $bg %1&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $kill process_id(1793 etc.)&lt;br /&gt;&lt;br /&gt;• &amp;nbsp; List &amp;nbsp;all &amp;nbsp;the &amp;nbsp;current &amp;nbsp;running &amp;nbsp;processes &amp;nbsp;owned &amp;nbsp;by &amp;nbsp;the &amp;nbsp;current &amp;nbsp;user &amp;nbsp;in &amp;nbsp;user &amp;nbsp;oriented format.&lt;br /&gt;Ans. $ps -u user_name&lt;br /&gt;&lt;br /&gt;• &amp;nbsp; List only running processes in tree mode.&lt;br /&gt;Ans. $pstree -u user_name&lt;br /&gt;&lt;br /&gt;• &amp;nbsp; Run &amp;nbsp;a &amp;nbsp;background &amp;nbsp;process &amp;nbsp;from &amp;nbsp;your &amp;nbsp;shell &amp;nbsp;that &amp;nbsp;finds &amp;nbsp;a &amp;nbsp;file &amp;nbsp;named &amp;nbsp;cpuinfo, &amp;nbsp;with lowest possible priority.&lt;br /&gt;Ans. $nice 20 | find /* -name &quot;cpuinfo&quot;&amp;amp;&lt;br /&gt;&lt;br /&gt;• &amp;nbsp; List &amp;nbsp;priority &amp;nbsp;value &amp;nbsp;of &amp;nbsp;all &amp;nbsp;running &amp;nbsp;processes &amp;nbsp;in &amp;nbsp;your &amp;nbsp;system. &amp;nbsp;Now &amp;nbsp;reduce &amp;nbsp;the &amp;nbsp;priority value of any running process by 5. Compare the new and the old priority values.&lt;br /&gt;Ans. $renice -5 -p process_id(1793 etc.)&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;</description><link>http://usmanali112.blogspot.com/2012/07/linux-commands-for-processmanagement.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-9057780077077039372.post-5756081851746064744</guid><pubDate>Mon, 23 Jul 2012 10:07:00 +0000</pubDate><atom:updated>2012-07-26T12:09:00.011+05:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Commands</category><category domain="http://www.blogger.com/atom/ns#">Linux</category><category domain="http://www.blogger.com/atom/ns#">user and group management</category><title>Linux: User/Group Management Commands</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;This lab will help you to learn commands for user and group management&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;• &amp;nbsp; See the /etc/passwd and /etc/shadow files&lt;br /&gt;Ans. $cat /etc/passwd&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $cat /etc/shadow&lt;br /&gt;&lt;br /&gt;• &amp;nbsp; Make a new user “tux” with default home directory and password “pakistan”&lt;br /&gt;Ans. $adduser tux&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Enter new UNIX password: pakistan&lt;br /&gt;&lt;br /&gt;• &amp;nbsp; See the changes in /etc/passwd and /etc/shadow&lt;br /&gt;Ans. $cat /etc/passwd&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $cat /etc/shadow&lt;br /&gt;&lt;br /&gt;• &amp;nbsp; Create a group “BIT10” with group ID 99 and change tux’s group to “BIT10”&lt;br /&gt;Ans. $groupadd -g 99 BIT10&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $usermod -a -G BIT10 tux&lt;br /&gt;&lt;br /&gt;• &amp;nbsp; Move the user’s current home directory to the new directory “/studentHome”&lt;br /&gt;Ans. $usermod -d /studentHome tux&lt;br /&gt;&lt;br /&gt;• &amp;nbsp; Change this user’s password to “d!g!t@l” with following settings:-&lt;br /&gt;• &amp;nbsp; Lock the account if it has been inactive for 5 days&lt;br /&gt;• &amp;nbsp; Minimum 2 days must be past before the user can change hi/her/its password&lt;br /&gt;Ans. $passwd&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; d!g!t@l&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $passwd -l tux&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $passwd -n 2 tux&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $passwd -i 5 tux&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; or&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $chage tux (It is used to manually enter the values for (minimum,inactive))&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; To view information&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $chage -l tux&lt;br /&gt;&lt;br /&gt;• &amp;nbsp; See the changes in /etc/passwd and /etc/shadow and /etc/group files&lt;br /&gt;Ans. $cat /etc/passwd&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $cat /etc/shadow&lt;br /&gt;&lt;br /&gt;• &amp;nbsp; Delete the group “BIT10” and delete the account of “tux”&lt;br /&gt;Ans. $userdel tux&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $groupdel BIT10&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;</description><link>http://usmanali112.blogspot.com/2012/07/linux-commands-for-userandgroupmanageme.html</link><author>noreply@blogger.com (Unknown)</author><thr:total>0</thr:total></item></channel></rss>