According to X.509, you can create certificates with either RSA or DSA key pairs. But only RSA key pairs are capable of exchanging keys when starting a new SSL connection with a SSL server. You can only use RSA key pairs as your server certificates. On the other hand, CAs do not have to exchange keys. They only issue other certificates. You can use either RSA or DSA key pair as your CAs. But, some SSL programs do not support the DSA algorithm yet.
Sometimes u need check certificate valid date on server. U can do this in java simple:
Tuesday, December 25, 2012
Monday, November 19, 2012
Captcha for Java
A CAPTCHA is a program that protects websites against bots by generating and grading tests that humans can pass but current computer programs cannot. For example, humans can read distorted text as the one shown on image, but current computer programs can't.
The term CAPTCHA (for Completely Automated Public Turing Test To Tell Computers and Humans Apart) was coined in 2000 by Luis von Ahn, Manuel Blum, Nicholas Hopper and John Langford of Carnegie Mellon University.
When u create web project sometimes u need captcha with colors of your site. That cases u can create captcha yourself as following:
The term CAPTCHA (for Completely Automated Public Turing Test To Tell Computers and Humans Apart) was coined in 2000 by Luis von Ahn, Manuel Blum, Nicholas Hopper and John Langford of Carnegie Mellon University.
When u create web project sometimes u need captcha with colors of your site. That cases u can create captcha yourself as following:
Sunday, November 4, 2012
Parse XML and Properties config files
.xml(Extensible Markup Language) and .properties is a file extension for files mainly used in Java related technologies to store the configurable parameters of an application.(.properties files can also be used for storing strings for Internationalization and localization - these are known as Property Resource Bundles.)
Let's first start with XML config files. There are many XML parser technologies, but I will show how u can use Apache Commons Configuration library to parse and use XML config files.
The Commons Configuration software library provides a generic configuration interface which enables a Java application to read configuration data from a variety of sources:
Let's first start with XML config files. There are many XML parser technologies, but I will show how u can use Apache Commons Configuration library to parse and use XML config files.
The Commons Configuration software library provides a generic configuration interface which enables a Java application to read configuration data from a variety of sources:
Thursday, October 18, 2012
Power of Spring's @ModelAttribute and @SessionAttributes
The Spring Framework is an open source application framework that aims to make J2EE development easier. Unlike single-tier frameworks, such as Struts or Hibernate, Spring aims to help structure whole applications in a consistent, productive manner, pulling together best-of-breed single-tier frameworks to create a coherent architecture.
How does @ModelAttribute work?
@ModelAttribute is a Spring-MVC specific annotation used for preparing the model data. It is also used to define the command object that would be bound with the HTTP request data. The annotation works only if the class is a Controller class (i.e. annotated with @Controller).
ModelAttribute can be applied on both methods as well as method-parameters. It accepts an optional "value", which indicates the name of the attribute. If no value is supplied to the annotation, then the value would be defaulted to the return type name in case of methods and parameter type name in case of method-parameters.
How does @ModelAttribute work?
@ModelAttribute is a Spring-MVC specific annotation used for preparing the model data. It is also used to define the command object that would be bound with the HTTP request data. The annotation works only if the class is a Controller class (i.e. annotated with @Controller).
ModelAttribute can be applied on both methods as well as method-parameters. It accepts an optional "value", which indicates the name of the attribute. If no value is supplied to the annotation, then the value would be defaulted to the return type name in case of methods and parameter type name in case of method-parameters.
Tuesday, September 18, 2012
Spring 3 MVC Internationalization & Localization (i18n & l10N) and Reloader
In this post I will discuss about Internationalization (I18N) and Localization (L10N) in Spring 3.0 MVC.
What is i18n and L10n?
What is i18n and L10n?
In computing, internationalization and localization are means of adapting computer software to different languages and regional differences. Internationalization is the process of designing a software application so that it can be adapted to various languages and regions without engineering changes. Localization is the process of adapting internationalized software for a specific region or language by adding locale-specific components and translating text.
The terms are frequently abbreviated to the numeronyms i18n (where 18 stands for the number of letters between the first i and last n in internationalization) and L10n respectively, due to the length of the words. The capital L in L10n helps to distinguish it from the lowercase i in i18n. Let's begin:
Thursday, September 13, 2012
Intercepting requests (annotation based request mapping)
Spring Interceptors has the ability to pre-handle and post-handle the web requests. Each interceptor class should extend the HandlerInterceptorAdapter class. Here we will create a Login Interceptor by extending the HandlerInterceptorAdapter class. You can override any of the three callback methods preHandle(), postHandle() and afterCompletion(). As the names indicate the preHandle() method will be called before handling the request, the postHandle() method will be called after handling the request and the afterCompletion() method will be called after rendering the view.
Tuesday, June 5, 2012
Difference between Oracle DATE, TIMESTAMP, TIMESTAMP WITH TIME ZONE, TIMESTAMP WITH LOCAL TIME ZONE
In Oracle there are four date&time datatype:
- DATE
- TIMESTAMP
- TIMESTAMP WITH TIME ZONE
- TIMESTAMP WITH LOCAL TIME ZONE
What is difference between this datatypes???
TIMESTAMP datatype differs from DATE only with that it includes fractional seconds. But TIMESTAMP WITH TIME ZONE and TIMESTAMP WITH LOCAL TIME ZONE is more interesting :-)
Friday, May 25, 2012
Avoiding the "javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed" error
Hey folks,
today I'm gonna share one solution for a problem related to https hand-shake.
The SSLHandshakeException is thrown by java when the host you are trying to contact doesn't have a valid SSL certificate for that hostname.
For example, when I wanted to connect to the site which certificate details look like "This CA Root certificate is not trusted because it is not in the Trusted Root Certification Authorities store."
So when we are making a request to that site using java URLConnection it gives us an exception look like "javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed" . Then I did research for this problem and found a solution as follows:
today I'm gonna share one solution for a problem related to https hand-shake.
The SSLHandshakeException is thrown by java when the host you are trying to contact doesn't have a valid SSL certificate for that hostname.
For example, when I wanted to connect to the site which certificate details look like "This CA Root certificate is not trusted because it is not in the Trusted Root Certification Authorities store."
So when we are making a request to that site using java URLConnection it gives us an exception look like "javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed" . Then I did research for this problem and found a solution as follows:
Friday, April 6, 2012
Broken pipe and Transactional update cache is full
In your web applications u can see errors like following:
2012-04-06 10:01:05,031 WARN [webscripts.connector.RemoteClient] [http-80-1] Exception during close() of HTTP API connection ClientAbortException: java.net.SocketException: Broken pipe
Solution: In most situations this occurs when your client ajax connection is closed but response is ready. And server can't write response for client. In my case, I used YUI AJAX Get connection and set timeout "5000". When I see this warning message I increase timeout time to "300000" and log tail is happy now :)
Friday, March 2, 2012
End old tasks in Alfresco from Admin
I have been working with Alfresco for a while now. It is a very comprehensive tool, but today I need delete old tasks in archive task node.
The purpose of the Workflow JavaScript API is to allow access to Alfresco advanced workflows from within JavaScript. The API supports EMCA Script 1.6 compatible JavaScript. Through this API workflow definitions, instances, paths, tasks and transitions can be accessed and managed.
Wednesday, February 29, 2012
Connect to Remote database through SSH using Port Forwarding with Java
Yesterday I need connect connect our remote MySQL database that was setup on SSH enabled server and query database. Since it was on SSH enabled server, we can’t connect it directly using JDBC connection API.To achieve this, we first need to create SSH session and then using Port Forwarding we can forward the request to server and connect to database. I used JSch. JSch is a pure Java implementation of SSH2.
Monday, February 27, 2012
Setting the background image of an Android TextView
TextView displays text to the user and optionally allows them to edit it. A TextView is a complete text editor, however the basic class is configured to not allow editing; see for a subclass that configures the text view for editing.
In most cases u want add image as textView background. It's so easy. In layout xml file u must write:
In most cases u want add image as textView background. It's so easy. In layout xml file u must write:
Friday, January 27, 2012
Lucene İndex Recovery (Alfresco)
Last week I searched some documents in our DM system. However my program failed to find them. (fts-alfresco)
I remember that in some files has problems and it doesn’t let lucene to create index for those documents. Solution is recovery of index. How to recovery index ???
Step1. Stop Alfresco
Step2. Delete everything under/alf_data/lucene-indexes (don't delete folder)
Delete everything under/alf_data/backup-lucene-indexes (don't delete folder)
Step3. Edit file/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/repository.properties
Set the property index.recovery.mode as follows: index.recovery.mode=FULL
Step4. Start Alfresco see logs, must create index
Step5. Stop Alfresco + change "index.recovery.mode=FULL" to default
Step6. Start Alfresco
I remember that in some files has problems and it doesn’t let lucene to create index for those documents. Solution is recovery of index. How to recovery index ???
Step1. Stop Alfresco
Step2. Delete everything under
Delete everything under
Step3. Edit file
Set the property index.recovery.mode as follows: index.recovery.mode=FULL
Step4. Start Alfresco see logs, must create index
Step5. Stop Alfresco + change "index.recovery.mode=FULL" to default
Subscribe to:
Posts (Atom)