Proxy Authentication To Connect To Internet
Apr 25, 2014
For my job I would to develop a Java application which downloads some data from a webpage and then process them.
The problem is that I have to authenticate to a proxy server to connect to the internet. As I browsed on the net, there is a possible way for implementation.
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
[Code] .....
Sometimes it works fine, but usually I get the following exception:
java.io.IOException: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 407 Proxy Authentication Required"
at sun.net.www.protocol.http.HttpURLConnection.doTunneling(HttpURLConnection.java:2083)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:183)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1511)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1439)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
I don't understand what's the problem and why it's not persistent.
View Replies
ADVERTISEMENT
Jul 11, 2014
i am trying to access an https request on a server and authenticating it after passing on username and passwork. I have even set up the proxy of the employer to get the request back as a zipped folder.
I always get an error on: " InputStream reader = con.getInputStream();"
Can be a proxy setting issue too but I am not sure why it should be.
Is there a way to create a secure channel in java to connect to https or by any way the below code could be modified to connect it to the server?
Code is as below:
import java.net.*;
import java.net.Proxy.Type;
import java.io.*;
import javax.net.ssl.HttpsURLConnection;
import com.sun.org.apache.xerces.internal.impl.dv.util.Ba se64;
public class DownloadFile
{
[Code]...
View Replies
View Related
Jan 22, 2015
I thought there'd be loads of people looking to do the same. I have just got a Github account and uploaded all my source code for a project and would like to upload the associated JAR file with it. I am not too fussed about the JAR file being on github, providing a link to somewhere else it can be downloaded is fine too.
View Replies
View Related
Aug 9, 2010
I have a click button called log off , here once a user clicks it , task goes to logout servlet to end current user session . below is my code , I don't know why it works fine with mozilla firefox and google chrom but not working with internet explorer.
response.setHeader("Cache-Control","no-store"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0);
HttpSession httpSession = request.getSession();
[Code] ....
here it goes fine to my index, but if I logged in again, I should enter a new session , but unfortunately this not happened in explorer , works fine with mozilla , and chroom.
I have also done in my index.jsp the check like below:
<%
if(session!=null){
session.setAttribute("validUser",null);
session.invalidate();
%>
just to erase whatever previous session . But why session exist on same page ! only in explorer , it makes me open new explorer for new user and that is what I don't want !
View Replies
View Related
Feb 20, 2011
What to do with this JAVA code?
This is the code that I need to do without using the Joptionpane:
An Internet service provider has three different subscription packages for its customers:
Package A: For $9.95 per month 10 hours of access are provided. Additional hours are $2.00 per hour.
Package B: For $13.95 per month 20 hours of access are provided. Additional hours are $1.00 per hour.
Package C: For $19.95 per month unlimited access is provided.
Write a program that calculates a customer's monthly bill. It should ask the user to enter the letter of the package the customer has purchased (A, B, or C) and the number of hours that were used. It should then display the total charges.
This is what I have so far : Cannot use Joptionpaneshowinputdialog
/* A demonstration of how to use Decision Structures
import java.util.Scanner;
/**
This program demonstrates a switch statement.
*/
public static void main(String[] args)
{
char packageLetter;
int hoursUsed;
[Code] ....
View Replies
View Related
Feb 19, 2014
I'm using proxy to crawl some data. So, for now I've this snippet,
public static void IPchange() {
String proxy = 121.11.23.21;
String port = 8080;
Properties systemProperties = System.getProperties();
systemProperties.put("proxySet", "true");
systemProperties.setProperty("http.proxyHost", proxy);
systemProperties.setProperty("http.proxyPort", port);
}
Now, I've a thread say T which is calls this IPchange() method to use proxy. Now, Thread T creates other threads say T1, T2. When I give URL to crawl for this T1 and T2. T1 and T2 will not call IPchange() method. To crawl URL, T1 and T2 now using my Original IP?
View Replies
View Related
Mar 16, 2015
how would i use it to restrict certain websites to be accessed.
SimpleProxyServer.java
import java.io.*;
import java.net.*;
public class SimpleProxyServer {
public static void main(String[] args) throws IOException {
try {
String host = "your Proxy Server";
[code]....
View Replies
View Related
Mar 16, 2015
I have this code, how would i use it to restrict certain websites to be accessed.
SimpleProxyServer.java
Java Code:
import java.io.*;
import java.net.*;
public class SimpleProxyServer {
public static void main(String[] args) throws IOException {
try {
String host = "your Proxy Server";
int remoteport = 100;
int localport = 111;
[Code] ....
View Replies
View Related
May 24, 2013
The users of our a enterprise Java based web application must access a third web application through simple HTML links and then navigate in the target application. But for security reasons and constraints the direct exchange between the browers of users and server of the other web application is not allowed. Our web application must retrieve the web page from the other application and must return it to the users's browser. Is there a convenient way to implement this requirement in J2EE ? In this case our web application must play the role of a simple reverse proxy, must request a target JSP page from other application and process it to rewrite the URLs contained in the HTML page, then send the response to user's web browser.
View Replies
View Related
Jul 29, 2014
I have a problem with several java applications. When I start them Java wants to connect to the certificate authority, to check if the certificate is still valid and not on a blacklist.
The problem is: my whole internet is behind a password protected proxy. If I open my browser i get a windows with username and password. I enter it and internet in the browser works. But for Java it isn't working, because I see no point, where I can enter the password and username for the proxy. I can enter the proxy ip and port in the java settings, but not the password and username. So I get a error screen from java, telling me, that java could not connect. I can disable the check in the java settings, but I don't wont that.
Is there a way to tell java, that java uses my proxy with my password and username? I already googled this problem and found nothing except tutorials for connecting with proxy in the java code. But these applications are not from me, I can't change the code ...
View Replies
View Related
Feb 25, 2014
I am making a messenger app using mobile nation, the authentication widget is blocked because im not premium. I have set a text box that says username and password then a login and register button, the register button opens a url to a register page on a xxamp server i have. I made the site with wordpress, so in the mysql database it has wp_users. So when they press the login button id like it to select the username and password entered and run the java script to send that information to the xampp server to authenticate.
View Replies
View Related
Apr 22, 2014
i have build an login form with which a user can login to see next form ,login form is working perfectly but whenever a user enters a wrong userid and clicks on login then nothing happens,i want that there a popup will be called and say wrong userid...
However when a user enters correct userid and wrong password then the popup is working but not when the user id itself wrong...
View Replies
View Related
Mar 30, 2015
I moved some static html pages I was hosting from apache into tomcat. (no point in running two servers) This works as expected, but I'm having trouble with the authentication part. In apache the authentication was handled by htaccess. I tried various tutorials on the web about configuring basic authentication in tomcat using WEB-INF/web.xml in tomcat, but I'm not sure this approach applies to static html pages. Using basic authentication for static html in tomcat?
View Replies
View Related
Aug 1, 2014
I'm building a JavaEE 7 web app and I want to add user authentication. Although I haven't found a complete guide, via the resources I've gathered I think I'm quite close. I can't make it work though. In all honesty I don't understand ALL of the code yet, I'm using it though because it's supposed to work, it's from JavaEE 7 Recipes book.
I've created my database, set up the JDBC realm in GlassFish, added the persistence unit, created the entity classes, the backing bean, the ejb, called the EL expressions...
When I'm supposed to login it throws a "loginBean.username is unreachable" or something. I don't understand why, the inputText's value is supposed to go straight to the backing bean right?
View Replies
View Related
May 2, 2015
I'm trying to build a SSL mutual authenticating private server. I'm not sure what keystores, truststores, or certificates I need to accomplish this. I made keystores for both programs using:
keytool -genkey -keyalg RSA -alias selfsigned -keystore keystore.jks -storepass password -validity 360 -keysize 2048
The server starts up fine, but when I run the client they both give errors.
Server code:
System.setProperty("javax.net.ssl.keyStore", "CLA.jks");
System.setProperty("javax.net.ssl.keyStorePassword", "password");
SSLServerSocketFactory sslServerSocketfactory = (SSLServerSocketFactory)SSLServerSocketFactory.getDefault();
SSLServerSocket sslServerSocket = (SSLServerSocket)sslServerSocketfactory.createServerSocket(9090);
SSLSocket s = (SSLSocket)sslServerSocket.accept();
BufferedReader in =
new BufferedReader(new InputStreamReader(s.getInputStream()));
[code]...
View Replies
View Related
Apr 10, 2014
I am writing a Twitter app, and I am encountering an error whenever I attempt to find the user's name from a screen name. I get the following error:
04-10 21:43:57.402: W/System.err(9326): No authentication challenges found
Which means that somehow, I'm not logged in. However, I am able to post, get the timeline statuses and even get the User of each status. I simply cannot do this:
public String getUserFromScreenName(String screenName) throws TwitterException {
m_twitter.verifyCredentials();
return m_twitter.showUser(screenName).getName();
}
The m_twitter.verifyCredentials() PASSES, which means I am authenticated, and the following line somehow I am not.
My m_twitter is defined here:
public void authenticate(String token, String secret) {
m_accessToken = token;
m_accessSecret = secret;
ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setOAuthConsumerKey(m_consumerKey)
[Code] .....
And as I said before, I can read/post/retweet and all that stuff both before AND after this call, but this one simply will not work.
View Replies
View Related
Feb 25, 2015
In spring there is a Custom Authentication Provider, my question is from a jsf login page how can I execute this provider ?
@Component
public class CustomAuthenticationProvider implements AuthenticationProvider {
@Autowired
private UserService userService;
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
String username = authentication.getName();
String password = (String) authentication.getCredentials();
[Code] ....
View Replies
View Related
Aug 1, 2014
I've created my database, set up the JDBC realm in GlassFish, added the persistence unit, created the entity classes, the backing bean, the ejb, called the EL expressions...
When I'm supposed to login it throws a "loginBean.username is unreachable" or something. I don't understand why, the inputText's value is supposed to go straight to the backing bean right?
I know this is a very vague description but I can provide you with all the code you may want, it's simply I cannot think of anything to do right now since I'm not familiar with the methodology yet...
View Replies
View Related
Dec 26, 2014
I have just started learning about sockets and such... and i have created a chat program with a server and a client
server:
public class Server {
private static ServerSocket server;
private static Socket connection;
private static PrintWriter pw;
private static BufferedReader br;
private static JTextField textOutput;
[Code] ....
so, everything is working fine . There is only one thing i would like to do now: make it so that i can run the server from my computer and then others can run the client from theirs and we will be able to chat . So I tried:
In the client code on line 56 is says:
connection = new Socket("localhost",7777);
So I changed "localhost",7777 to "myip",7777)
But when i run the server on my computer and run the client on another computer i get this error:
java.net.ConnectException: Connection refused: connect
Why is the connection getting refused? is it for security reasons? so hackers cant connect to me or something? And is there a way to tell your computer to allow that client to connect?
View Replies
View Related
Oct 20, 2014
I have compiled and coded the whole thing, but the TIE function when no one wins, isn't popping up. I'm not sure why but here is my code;
import java.applet.AudioClip;
import java.awt.*;
import javax.imageio.ImageIO;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.DataLine;
[code]....
The TIE doesn't pop up, that is all the errors i have, though there is no error messages.
View Replies
View Related
Nov 25, 2014
Our assignment is to make a version of the classic 'Connect Four' game, where we need to construct a GUI that shows the current state of the game and instead of having a winner once a player has four chips in a row, the game needs to continue until no chips can be placed anymore.We currently get stuck in the GUI part. Running it right now results in a board with empty spaces only. Also after choosing a column to place, the board remains empty.
Our question: How do we get the board filled with the right color of chips at the right place?We know the 'ArcsPanel'-class (almost at the bottom of the code) is wrong, but we don't know what to do to make it right.
Main class 'ConnectPanel':
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.GridLayout;
[code]....
At the moment, only the colors white, red and blue are used. This is purely for finding out how to work in general.
View Replies
View Related
Aug 20, 2014
I am trying to learn how to connect to web sites using java. Someone suggested that I learn to "consume an API with java". They also suggested that I practice through a weather website called weather underground and sent me a link [URL] .... I would like to know how to connect to this site to get weather information.
View Replies
View Related
May 1, 2015
soo, is there a way to (via sockets or something like that) connect to a stream via the streamers url (or just via anything) and then get the actual stream? like the images that keeps updating? so that i can display the images/stream on a jframe?
View Replies
View Related
Nov 26, 2014
How can I connect to an SSH server in Java? I don't need/want a shell. I just want to connect to the SSH server and get the content of, say, file.txt. How can I do that? Example : I get host, user,pass in txt and connect it with java code!
View Replies
View Related
Dec 31, 2014
I have a vps set up to running a MySQL database already by zpanel but when I try to connect to the database with Java I am unable to connect and receive the message:
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server."
I have MySQL Connector(dev.mysql.com/downloads/connector/j) already added to my build and tried it with both the url and the ip. This is my connection code:
package net;
import java.sql.*;
import javax.swing.JOptionPane;
public class LoginDatabaseConnection {
Connection conn = null;
[Code] ....
The code is from youtube but when I connect to localhost it works fine however when I try to connect to the VPS the above error happens.
View Replies
View Related
Mar 23, 2014
i want o know that how can i connect my sql database to java
View Replies
View Related