Thursday 8 May 2014

Connecting to a remote application using JVisualVM.



If the runtime environment of JVisualVm and the process/ Server which you are running are the same then VisualVm will automatically fork and profile your application.


Requirements for profiling Java Applications with VisualVM.

Java JDK installed along with JVisualVM.exe


Older versions of Java do not have JVisualVms in the JDK folder.


Connecting / Profiling remote application using JVisualVM.


The firewall settings or the Security policy on the remote machine should support RMI Invocations.


Just goto JDK bin foder in remote machine in Command prompt and type jstatd.


If this start normal without any exception then we have permission to start profiling.


Else in general / most of the cases it throuws rmiinvocation error.In such case


Open NotePad type the following


grant codebase "file:${java.home}/../lib/tools.jar" {permission java.security.AllPermission;};


Save the Notepad file with Name as jstatd.all.policy with type as any i.e. *.* and save this file under the same JDK bin folder where we have jstatd.


Now in command propmt under JDK\bin folder type jstatd -J-Djava.security.policy=jstatd.all.policy


This start the jstatd process and it doesnt give any response.


Now start JVisualVM in your local machine.


Connect to the remote Server in JVisualVM giving the IP in the Textbox.


This gives all the processes that are attached to the runtime in the Remote machine.


Source :

Remote Connection in JVisualVM http://visualvm.java.net/applications_remote.html

Handling RMIExcepton in jstatd : http://www.codefactorycr.com/java-visualvm-to-profile-a-remote-server.html


Finding Memory Leaks using JVisualVM : http://www.captaincasa.com/pdf/techdoc_memprofiling.pdf

Tuesday 11 March 2014

Full Screen in HTML using Java Script

After Successful Logging in Redirect to some Dummy HTML page which has the following page instead of Homepage


function
openFullScreenWindow()
{

var vl = null;
var w = null;
var h = null;
var wres = null;
var hres = null;
var theWin = null;
var browser = null;
var ua = navigator.userAgent.toLowerCase();
if ( ua.indexOf( "msie" ) != -1 ) {
browser =
"msie";
}
else if ( ua.indexOf( "firefox" ) != -1 ) {
browser =
"firefox";
}
else if ( ua.indexOf( "chrome" ) != -1 ){
browser=
"chrome";
}
else{
browser=
"opera";
}
if(browser != "firefox"){
self.opener =
'dummy';
}
if(browser == "msie") {
vl=Math.random()*12345;
vl=Math.round(vl);
w = screen.availWidth;
h = screen.availHeight;
h =h-60;
w = w-15;
wres = screen.width
hres = screen.height
}
else {
vl=Math.random()*12345;
vl=Math.round(vl);
w = screen.availWidth;
h = screen.availHeight;
h =h-60;
w = w-15;
wres = screen.width
hres = screen.height
}
if(window.self != window.top) {
mainWindowName = window.top.name;
}
else {
mainWindowName =
'iLogistics'+vl;
}
theWin = window.open(
'login.do?method=redirectHome',mainWindowName,'top=0,left=0,height='+h+',width='+w+',toolbar=no,menubar=no,location=no,scrollbars=no,directories=no,status=yes');
if (theWin) {
theWin.focus();
theWin =
null;
}
self.close();  //Closes Parent Window
}
window.onload=openFullScreenWindow;
</script>

Tuesday 10 July 2012

Method to remove HTML tags from a given Text


public static String formatHTMLTags(String s)
    {
String returnStr = s;
        try
        {
  String sTag = "<[^>]*>";
           String s3 = "";
Pattern pattern = Pattern.compile(sTag);
            Matcher matcher = pattern.matcher(s);
            returnStr = matcher.replaceAll(s3);
        }
        catch(Exception exception) { }
        return returnStr;
    }

Monday 9 July 2012

Regular Expression for Consecutive DOTS



In order to replace consecutive DOTS In a string we use the following Regular Expression.


String regex = "\\.\\.*";
String contentText =" This i sa Sample Text...... And to replace the previous dots we add the following LINE This i sa Sample Text...... And to replace the previous dots we add the following LINEThis i sa Sample Text...... And to replace the previous dots we add the following LINEThis i sa Sample Text...... And to replace the previous dots we add the following LINE";
contentText = contentText .replaceAll(regex,"");

Thursday 31 May 2012

Repetitive text in IE

In-spite of all the precautions we talk to build a html page cleanly IE shows a lot of bugs or we can say IE strictly follows standards.

One such irritating error we find is the repetitive text.
This can be due to comments in between DIV tags.
Eliminate all the comments and you can find no repetitive text at all.

Source :http://www.impressivewebs.com/ie6-ghost-text-bug-with-multiple-solutions/

Tuesday 17 April 2012

Jsp not passing values to request object



Possible Reasons :

1.FORM tag in wrong place i.e. the parameter you are trying to pass is not included in the form.

2.The request object does not exist i.e the value you are trying to retrieve in the request object does not exist.


3.There is another case which i came across recently in which the css property uniform is not allowing the radio button object to be defined.Radio button value is not passed to next form thereof.....So CSS properties might also prevent radio button values to be passed or undefined.(express interest in matrimony live example)

Others can also be

4. Javascript errors that prevent a value to be populated.

5.Improper JavaScript validations

Wednesday 21 March 2012

How to downshift from HTTPS to HTTP in your web application



From Oracle Blogs
Problem description

Web applications will normally protect any of their web resources that process security-sensitive information (e.g., the login page used by FORM authentication) with SSL, to ensure that the information submitted by the user (e.g., username and password security credentials) will not be transmitted in the clear.

Some web applications will only protect web resources that process security-sensitive information in this manner, while allowing requests for other resources to travel in the clear.

Imagine a user accessing some of the unprotected resources of a web application (over HTTP) before accessing a resource that requires FORM authentication, where the FORM login page is guarded by a transport guarantee ofCONFIDENTIAL according to the web application's deployment descriptor. In this case, the protocol will change from HTTP to HTTPS (to satisfy the transport guarantee of the login page), and will remain HTTPS even after the user has authenticated successfully and continues accessing any of the unprotected resources.


The fact that the protocol remains HTTPS once it has been changed to HTTPS, even though HTTPS may no longer be required, can be a problem for performance sensitive applications that do not want to incur the overhead of SSL unless required.

This blog explains how a web application can be written so that the protocol changes back to HTTP when HTTPS is no longer needed.
Solution

Imagine a very simple web application containing two servlets UseHttp.java and UseHttps.java, which are mapped to /useHttp and /useHttps, respectively. Further assume that the web application must satisfy the following requirements:
REQ_1: Access to "/useHttps" must be over HTTPS (otherwise, the servlet will throw an exception). This means that if the current protocol is HTTP, it must be upgraded to HTTPS.
REQ_2: Access to "/useHttp" must be over HTTP (otherwise, the servlet will throw an exception). This means that if the current protocol is HTTPS, it must be downshifted to HTTP.


REQ_1 will be handled automatically by the container, by declaring the following security constraint in the web application's web.xml: <security-constraint> <web-resource-collection> <web-resource-name>Protected resource</web-resource-name> <url-pattern>/useHttps</url-pattern> <http-method>GET</http-method> </web-resource-collection> <user-data-constraint> <transport-guarantee>CONFIDENTIAL</transport-guarantee> </user-data-constraint> </security-constraint>


REQ_2 cannot be handled automatically by the container, and must be implemented by the application itself. In order to address REQ_2, we are going to implement a filter that intercepts every request and determines programmtically whether the target resource is guarded by a transport guarantee of CONFIDENTIAL. If it is not, and the request came in over HTTPS, the filter will issue a redirect to the target resource over HTTP.


In order to determine if a requested resource is guarded by HTTPS, the filter leverages the JavaTM Authorization Contract for Containers (Java ACC), which defines new java.security.Permission classes to satisfy the authorization model of the Java Platform, Enterprise Edition. In our particular case, the filter creates and uses an instance of javax.security.jacc.WebUserDataPermission to check if the target resource of a request is guarded by HTTPS.


The complete source code of the filter and the two servlets, as well as the web.xml, are provided as part of the sample application's WAR file and may be downloaded from this link.


For the sake of simplicity, we assume the default GlassFish configuration of three HTTP listeners: one listener reserved for any admin requests, a second listener for user traffic over HTTP (on port 8080), and a third listener for user traffic over HTTPS (on port 8181). (Notice that when you are using GlassFish v3 Prelude, you must enable the HTTPS listener on port 8181, which is disabled by default.)


The port number of the HTTP port for user requests is fed into the filter via an init parameter in web.xml: <filter> <filter-name>MyFilter</filter-name> <filter-class>MyFilter</filter-class> <init-param> <param-name>httpPort</param-name> <param-value>8080</param-value> </init-param> </filter>


This is necessary so that the filter will know which port number to use when redirecting from HTTPS to HTTP.
Demo


To see the upshift from HTTP to HTTPS, and downshift from HTTPS to HTTP in action, follow these simple steps:
Download and install GlassFish v2 UR2 or GlassFish v3 Prelude.
Download the sample web application sample.war, and deploy it to GlassFish.
Access this URL: http://leah:8080/sample/useHttps. Notice how the request gets redirected to the HTTPS port, and how the protocol changes from HTTP to HTTPS:https://localhost:8181/sample/useHttps.
Now edit the above HTTPS URL in your browser's address window by removing the trailing s fromuseHttps, so that the URL reads: https://localhost:8181/sample/useHttp, and hit return. Notice how the browser displays this warning message: You are about to leave an encrypted page. Information you send or receive from now on could easily be read by a third party, before issuing a redirect to the HTTP port and downshifting the protocol from HTTPS to HTTP:http://localhost:8080/sample/useHttp


I hope you found this blog useful. Please send any questions or comments you may have to the GlassFish webtier alias, or post them to the GlassFish webtier forum. I also would like to thank GlassFish security architect Ron Monzillo for his Java ACC related contribution to the idea behind this blog and to the filter code of the sample web application.

Security Today


The cyber landscape is quickly evolving from hacking by teenagers to nation-sponsored cyber crime.As a result, in the next decade, we will face new cyber security issues and trends. To cope with these more complex and powerful cyber threats, organizations must shore up their existing cyber defenses to protect and mitigate these malicious attacks with a combination of security software and new real-time capabilities.



In 1983, the nation was introduced to WarGames, an Academy Award-nominated film chronicling the exploits of fictional hacker David Lightman as he successfully (and unwittingly) penetrates a U.S. military supercomputer, almost starting World War III. Back then, hacking was left to teenagers, and the Internet itself was hardly a household term. This thriller introduced the extraordinary idea that a common hacker could wield his keyboard as a weapon to initiate mass destruction.



The Evolving Cyber LandscapeSince the film was released, computer knowledge and access have increased, and we’ve become a truly Internet-centric society. In fact, in just this past decade, worldwide Internet usage has grown 444.8 percent1. It’s an astounding number, yet it’s hardly surprising:



The Internet has become the foundation of our everyday personal and business lives. We use it to do our banking, our grocery shopping and our general communicating. On a larger scale, the Internet powers critical infrastructures – utility grids, aviation, space transport, shipping and mass transit, to name a few — and carries information relating to national security and safety.While advances and expansion in the Internet and technology in general revolutionized our lives and how we conducted business in the first decade of the 21st century, they also presented new cracks through which nations and well-financed and sophisticated cyber criminals obtained data and manipulated our critical infrastructures — and made a boatload of money. Hacking, for one, was tagged as a billion-dollar business run by criminal cartels.



In fact, wave3.com reported that one busted organized cyber crime gang in the Ukraine made $900 million in a single month2.Viruses, spyware and malware have also been on the rise since 2000. Remember “SQL Slammer,” “Conficker,” “MyDoom” and “ILOVEYOU”? And McAfee reports that the first six months of 2010 alone was the most active half-year ever for total malware production3.Distributed Denial of Service (DDoS) attacks also popped up all over the news, moving from fun to profit to politics. First, in 2000, “Mafiaboy” shut down Amazon, CNN, Dell, eBay and Yahoo! with a DDoS attack. Then opportunist criminals used DDoS attacks to hold various gambling sites for ransom.



In 2007, DDoS attacks turned political when Russian sympathizers used them to literally shut down Estonia’s entire network of government Web sites. The following year, Russian organized crime targeted Georgia with a DDoS attack.Zero-day attacks, botnets and attacks on social networks also entered the cyber crime fray over the past 10 years, and are poised to continue their destruction in the foreseeable future.



Looking Forward: Top Cyber Issues for the Start of the New DecadeNarus believes that we will be faced with a continuation of cyber threats that originated over the past several years, as well as new threats along the lines we indicate here. We expect to see more cyber security threats launched for financial remuneration or political gain, à la the current Wikipedia DoS and DDoS attacks to shut down PayPal, Visa, MasterCard and counter-attacks.



Here, are the compiled a list of the top 10 key cyber threat trends for 2011 and beyond.



Mobile devices and wireless networks.


The world has become increasingly mobile, as smart phone, iPad and other mobile device use spreads at an exponential pace. Mobile computing devices contain the same vulnerabilities as laptops and desktops, but they are also susceptible to DDoS attacks specifically designed for wireless devices. New custom financial applications like digital wallets and pocket ATMs are also particularly attractive to hackers. Moreover, wireless networks themselves put entire companies at risk, especially as the mobile workforce does not have the benefit of the secured corporate LAN. Cyber criminals may therefore intercept a company’s intellectual property via laptops and smartphones in the field that access unsecured wireless networks. Detecting cloned devices or unauthorized laptop tethering is important for providers in order to retain revenue sources



Attack of the USB.


Cyber criminals are taking advantage of individuals’ inclination to share with friends and the growing memory capacities of USBs. As USB drives become cheaper and information is made available on them at trade shows, the possibility of Trojans and other malware increases. In fact, research conducted by analysts at the Avast! Virus Lab has found that 1 out of every 8 attacks on computers now enters via a USB device4.



Large-scale, targeted botnet attacks.


Bots seem to be the weapon of choice. Botnets have begun using protocols such as HTTP and DNS for coordinating their bots since these traffic flows are always allowed by firewalls by default. The challenge therefore lies in detecting which HTTP or DNS traffic corresponds to bots vs. legitimate users. In the future, expect to see more sophisticated targeted peer-to-peer-based botnets (along the lines of “Storm”) that will be completely distributed with no standard command-and-control traffic.



DDoS attacks


There are two types of DDoS attacks: those that intend to disrupt services and those that crash services by flooding servers. Regardless of the intent, DDoS attacks spurred by political activism or for disruption and destruction of critical infrastructures will continue to rise.



Increased attacks on and via social network.


Social network users can expect more threats to travel virally, infecting everyone on a user’s friends list. Future viruses will likely be designed to steal or delete users’ personal information, which can be sold in numerous black markets and used to acquire credit card and bank information.




Click jacking and cross-site scripting


These social attacks are related to No. 4 on our list. The goal of click jacking and cross-site scripting is to trick users into revealing confidential information, or taking control of a user’s computer while they click on seemingly innocuous Web pages. It takes the form of embedded code or scripts that can execute without the user’s knowledge, such as clicking on a button that appears to perform another function.




Phishing attacks from “trusted third parties.”


These attacks originated over the past several years and will continue, especially with the increased use of smart phones for mobile e-mail. The most common attacks come in the form of e-mails from recognizable companies, banks or organizations that tempt the reader to open a link. The attacks can come via office or personal e-mail. The most recent incident was the malware-infected holiday e-card purportedly sent from the White House. It’s reported that those who downloaded the links became infected with a Zeus Trojan variant that would steal passwords and documents. The hijacked information was uploaded to a server in Belarus. It has already stolen sensitive data from numerous people.




Online fraud and money mules.


This is another side of phishing attacks and has become a bigger problem with increased unemployment and the unstable economy. The dramatic rise in phishing and identity theft attacks includes a well-organized offline component — the not-so-innocent “money mules” recruited by fraudsters to launder stolen money across the globe. The ads appear innocently on all the major employment listing sites, offering stay-at-home positions titled “financial rep” or “sales representative.” These, however, are active attempts to enlist people to transfer illegal funds from credit card thieves. Easy money-transfer sites like PayPal are targeted. The number of money mule sites is increasing exponentially each year.




Cloud computing concerns.


As cloud computing becomes more of a reality for many companies, the opportunities to compromise data and cloud networks increase. Companies that adopt cloud-based services are made vulnerable as sensitive information (financial, employee, corporate and medical) travels to and from protected networks via a public pipe, creating many more opportunities for data infection or theft.9.Data exfiltration and insider threats. No.




The Last on our list is a bit tricky, as technology alone will not solve it. Unfortunately, untrustworthy people will always find a way to anonymously leak private (government, enterprise, etc.) information; hence, this trend will grow. Criminal elements or nations will try to entice employees to exfiltrate data and compromise company and government assets.

Innovation versus Creation



The fierce warrior in the sky settling down sending awesome screenplay of the hills

A skylark singing lullabies heading for its nest

The Last Rush hour of the day v-rooming up the scene spoiling the Screenplay above

A Chandeliers tree before me hanging its yellow flowers in the Churchyard that was built ages before

One might think who has time to see all this.Yes in this world of Money,fame and Desire none has even a nick of time to stand and stare.

But high above our intelligence there is a source which is creating this screen play one may think its force of nature,one may think its GOD.

A complete cycle of creation without a proof of mistake anywhere....

A 19-year old summing up calculations with his friends in a shed with Ideas in his Brain asking him to do whatever he wanted him to His friend is a Genius the most complicated brain he has ever astonished me. A machine that could take one room made into a carry box within no time This is what the 19year old lad wanted his friend to do. A machine that can store some records of data and is portable ata the same time.

Finally the 19 year old lad is now 20 with 1 million dollars in his hand. Another Idea struck him so he hired two school students who were of course genius and worked for him after school hours The 20 year old lad auctioned his invention for 100 pieces in a gathering. The piece which his friends made was a marvel of all the prototypes that existed.

Finally the boy turned 21 and is now having 100 million dollars.

A great idea and a creative one turned him into millionaire in just three years For those of you who are still thinking who i am speaking about ask your IPOD or your IPHONE.

Yes to the fullest of the story i am speaking about Steve Paul Jobs

A great person once said to me in person "A company or a person cannot survive for long unless it creates/Stands something new above all".

I never believed this but when i read the Biographies of many Entrepreneurs I saw one great characteristic i.e. Creation One created machines , One created business where everyone thought this is the END(Vittal Mallya F/O Vijay Mallya)

As the great Jobs says connecting the Dots in his Stanford speech ..Yes everyone cant be great unless they have the urge or the passions that fires it up.

Creation is one difficult thing that most of us lack.

Creation in the sense a new Concept/Invention/Entity that is born out of you(like a bulb created by T.A Edison) not an innovated product(Tube light).

As said the software industry needs both Creators and Innovators.One that has both stands above all like the Apple,Microsoft,Cisco and a lot more. May we live to earn our bread and butter but who knows that one can create History and becomes a Legend Standing above all and hiding in the notebooks of schoolkids for generations to read