Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Regular Contributor
Zenkology
Posts: 92
Registered: ‎01-31-2012
My Device: curve 8520
My Carrier: vodafone

authorization problem

um using connection to a site which requires user and password but it doesn't connect and I don't know the reason can you help me doing this please

 

that's the code um using

 

{HttpsConnection connection;
	connection = (HttpsConnection) Connector.open(url
					+ getBlackBerryConnectionParams());

			connection.setRequestProperty("Authorization", "Basic"
					+ new String(getEncode()));
}
public byte[] getEncode() {
		String login = "user:@@iPass";
		byte[] encoded = null;
		try {
			encoded = Base64OutputStream.encode(login.getBytes(), 0,
					login.length(), false, false);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return encoded;
	}

 actually password is start with "@@" and there's a capital letter,thnx in advance

Please use plain text.
Developer
simon_hain
Posts: 16,113
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: authorization problem

the password method looks correct, most likely your issue is somewhere else.

what does getBlackBerryConnectionParams() do? maybe you can simply use connectionfactory.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Regular Contributor
Zenkology
Posts: 92
Registered: ‎01-31-2012
My Device: curve 8520
My Carrier: vodafone

Re: authorization problem

actually it's for adding network parameters, and it's working well in other projects, do you think the problem in the special characters in the password ?, or where's the problem ?!
Please use plain text.
Developer
simon_hain
Posts: 16,113
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: authorization problem

do you get a 403 from the server? then it is a problem with the password, otherwise the problem is somewhere else.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Regular Contributor
Zenkology
Posts: 92
Registered: ‎01-31-2012
My Device: curve 8520
My Carrier: vodafone

Re: authorization problem

password is right when I entered it on the browser, you think that '@' is able to be post normally without escape characters or what?, as you see code is right and the password also is right
Please use plain text.
Developer
simon_hain
Posts: 16,113
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: authorization problem

"!it doesn't connect" is not a helpful error description.
if you do not get a response code from the server the authorization is not even tried and your problem is somewhere else.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Regular Contributor
Zenkology
Posts: 92
Registered: ‎01-31-2012
My Device: curve 8520
My Carrier: vodafone

Re: authorization problem

the response message on the debug section is : UNAUTHORIZED
Please use plain text.