Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search Coderanch
Advance search
Google search
Register / Login
sai sudhakar
Greenhorn
+ Follow
news
4
Posts
3
Threads
since Mar 04, 2011
Merit badge:
grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads
Recent posts by sai sudhakar
DES Encryption and Decryption . how to find the encrypted msg has been changed
I am Using DES Encryption and Decryption.
I want to know whether the data is modified or not..Currently when i changed the encrypted data . it is giving different data .but how could i find that the data is modified.. is there any option...
show more
12 years ago
Security
post url connection not working
i am getting a response code as 400 for request type POST
show more
14 years ago
Sockets and Internet Protocols
post url connection not working
I am providing the below given code. it is working well for POST TYPE=GET but not working for POST:: i need some help
public class URLChecking { public static String excutePost(String targetURL, String urlParameters) { URL url; HttpURLConnection connection = null; try { // Create connection url = new URL(targetURL); System.out.println(url.getQuery()); connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("POST"); connection.setRequestProperty("Content-type","application/atom+xml"); connection.setRequestProperty("User-Agent","Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13 (.NET CLR 3.5.30729)"); // connection.setRequestProperty("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); connection.setRequestProperty("Content-Language", "en-US"); // connection.setRequestProperty("Accept-Encoding", "gzip,deflate"); // connection.setRequestProperty("Accept-Charset","ISO-8859-1,utf-8;q=0.7,*;q=0.7"); connection.setRequestProperty("Keep-Alive", "115"); // connection.setRequestProperty("Connection", "keep-alive"); connection.setUseCaches(false); /*connection.setRequestProperty("Content-Length", "" + Integer.toString(urlParameters.getBytes().length));*/ connection.setDoInput(true); connection.setDoOutput(true); System.out.println("urlParameters is:"+urlParameters); System.out.println("Test ????:"+url.getQuery()); DataOutputStream wr = new DataOutputStream ( connection.getOutputStream ()); wr.writeBytes (urlParameters); wr.flush (); wr.close (); // Get Response InputStream is = connection.getInputStream(); System.out.println("response code"+connection.getResponseCode()); BufferedReader rd = new BufferedReader(new InputStreamReader(is)); String line; StringBuffer response = new StringBuffer(); while ((line = rd.readLine()) != null) { System.out.println(line); response.append(line); response.append('\r'); } rd.close(); return response.toString(); } catch (Exception e) { e.printStackTrace(); return null; } finally { if (connection != null) { connection.disconnect(); } } } public static void main(String[] args) { String data="hl=en&oi=spell&q=cairn+india&ie=utf-8&num=10&output=rss"; try { data ="hl="+URLEncoder.encode("en", "UTF-8") + "&oi="+URLEncoder.encode("spell", "UTF-8")+ "&q="+URLEncoder.encode("cairn+india", "UTF-8")+ "&ie="+URLEncoder.encode("utf-8", "UTF-8")+ "&num="+URLEncoder.encode("10", "UTF-8")+ "&output="+URLEncoder.encode("rss", "UTF-8") ; System.out.println("the data " + data); } catch (UnsupportedEncodingException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } try { excutePost("http://blogsearch.google.com/blogsearch_feeds", data); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); } } }
show more
14 years ago
Sockets and Internet Protocols
sending email
import java.security.Security; import java.util.Properties; import javax.mail.Message; import javax.mail.MessagingException; import javax.mail.PasswordAuthentication; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; public class GoogleTest { private static final String SMTP_HOST_NAME = "smtp.gmail.com"; // for gmail for yahoo :: smtp.mail.yahoo.com private static final String SMTP_PORT = "465"; private static final String emailMsgTxt = "Test Message Contents"; private static final String emailSubjectTxt = "A test from gmail"; private static final String emailFromAddress = "xxxxx@gmail.com"; private static final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory"; private static final String[] sendTo = { xxxxxx@gmail.com" }; public static void main(String args[]) throws Exception { Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); new GoogleTest().sendSSLMessage(sendTo, emailSubjectTxt, emailMsgTxt, emailFromAddress); System.out.println("Sucessfully Sent mail to All Users"); } public void sendSSLMessage(String recipients[], String subject, String message, String from) throws MessagingException { boolean debug = true; Properties props = new Properties(); props.put("mail.smtp.host", SMTP_HOST_NAME); props.put("mail.smtp.auth", "true"); props.put("mail.debug", "true"); props.put("mail.smtp.port", SMTP_PORT); props.put("mail.smtp.socketFactory.port", SMTP_PORT); props.put("mail.smtp.socketFactory.class", SSL_FACTORY); Session session = Session.getDefaultInstance(props, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication("xxxxxx", ""); } }); session.setDebug(debug); Message msg = new MimeMessage(session); InternetAddress addressFrom = new InternetAddress(from); msg.setFrom(addressFrom); InternetAddress[] addressTo = new InternetAddress[recipients.length]; for (int i = 0; i < recipients.length; i++) { addressTo[i] = new InternetAddress(recipients[i]); } msg.setRecipients(Message.RecipientType.TO, addressTo); // Setting the Subject and Content Type msg.setSubject(subject); msg.setContent(message, "text/plain"); Transport.send(msg); } }
show more
14 years ago
Other JSE/JEE APIs