basic-authentication

How to get login attributes from a servlet/jsp

断了今生、忘了曾经 提交于 2019-11-27 22:13:53
Lately I've been working on implementing security for my web application, running on a Glassfish v3. I successfully managed to secure some resources by setting a basic authentication up like following: <login-config> <auth-method>BASIC</auth-method> <realm-name>vcards-admin</realm-name> </login-config> Now I was wondering how to get the user name introduced on the login prompt to fecth the actual data of the user. I thought there could be a session attribute to get that piece of data, but I don't know which one it is. Am I wrong about the session attribute? Is there any other way to access

Download a file from the internet using java : How to authenticate?

▼魔方 西西 提交于 2019-11-27 22:12:07
Thanks to this thread How to download and save a file from Internet using Java? I know how to download a file, now my problem is that I need to authenticate on the sever from which I'm dowloading. It's an http interface to a subversion server. Which field do I need to look up into ? Using the code posted in the last comment, I get this exception: java.io.IOException: Server returned HTTP response code: 401 for URL: http://myserver/systemc-2.0.1.tgz at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1305) at java.net.URL.openStream(URL.java:1009) at mypackage

DropWizard Auth by Example

风流意气都作罢 提交于 2019-11-27 19:24:39
I'm trying to understand how authentication and authorization work in DropWizard . I've read their auth guide as well as the dropwizard-security project on GitHub, but feel like I'm still missing a few important concepts. public class SimpleCredential { private String password; public SimpleCredential(String password) { super(); this.password = password; } } public class SimplePrincipal { pivate String username; public SimplePrincipal(String username) { super(); this.username = username; } } public class SimpleAuthenticator implements Authenticator<SimpleCredential, SimplePrincipal> {

Escaping username characters in basic auth URLs

主宰稳场 提交于 2019-11-27 18:57:15
When using http basic authentication, the username can be passed in the URL, e.g. http://david@foo.com/path/ But now suppose the username is an email address, e.g. david@company.com. Doing this is clearly ambiguous: http://david@company.com@foo.com/path/ Is there a way to escape the @ character in the username? I tried standard URL encoding: http://david%40company.com@foo.com/path/ But that didn't do it. According to RFC 3986 , section 3.2.1, it needs to be percent encoded: userinfo = *( unreserved / pct-encoded / sub-delims / ":" ) So it looks like http://david%40company.com@foo.com/path/ Is

Spring Security exclude url patterns in security annotation configurartion

别来无恙 提交于 2019-11-27 18:23:17
I have spring web application with Spring security configured using java config approach. I want to exclude some URL patterns from authentication(eg: static resources etc..). I have done this earlier with spring security xml config but couldn't figure out with java config as adding antmatchers doesn't help. Following is my code added in security config class extending WebSecurityConfigurerAdapter @Override public void configure(HttpSecurity http) throws Exception { http.authorizeRequests() .antMatchers("/authFailure") .permitAll() .anyRequest() .authenticated() .and() .httpBasic() .and()

Add HTTP basic authentication to this HTTP GET in angularjs

余生长醉 提交于 2019-11-27 18:06:53
问题 I have an existing angularjs code which makes a HTTP GET. Extracted below is some relevant code inside the controller. .controller('imptViewCtrl', ['$scope', '$http', function ($scope, $http, ) { var url = $configuration.webroot + '/impt/list?list=testlist'; $http.get(url).then(function (response) { tableData = response.data; }); }]); I would like to add HTTP basic authentication to the HTTP GET. The username is foo and the password is bar . How can this be done? 回答1: Because in basic

How to add basic authentication header to WebRequest [duplicate]

送分小仙女□ 提交于 2019-11-27 15:46:54
问题 This question already has answers here : HttpWebRequest using Basic authentication (8 answers) Closed 5 years ago . I have a basic WCF service and I want to test it using HttpWebRequest. The problem is that I use basic authentication. How do I add a header with basic authentication? That's my code so far: var request = (HttpWebRequest)WebRequest.Create(url); Thanks 回答1: Easy. In order to add a basic authentication to your HttpRequest you do this: string username = "Your username"; string

Basic Authentication with RestTemplate (3.1)

◇◆丶佛笑我妖孽 提交于 2019-11-27 15:10:56
问题 I am trying to reproduce the following curl command using Java: curl -v -u user:pass http://myapp.com/api This command returns some JSON data. My buggy Java implementation is as follows: @Test public void callTest() { RestTemplate restTemplate = createRestTemplate("user", "pass"); URI uri = new URI("http://myapp.com/api"); String res = restTemplate.getForObject(uri, String.class); } private static RestTemplate createRestTemplate(String username, String password) { UsernamePasswordCredentials

Why my Http client making 2 requests when I specify credentials?

核能气质少年 提交于 2019-11-27 15:06:31
I created RESTful webservice (WCF) where I check credentials on each request. One of my clients is Android app and everything seems to be great on server side. I get request and if it's got proper header - I process it, etc.. Now I created client app that uses this service. This is how I do GET: // Create the web request var request = WebRequest.Create(Context.ServiceURL + uri) as HttpWebRequest; if (request != null) { request.ContentType = "application/json"; // Add authentication to request request.Credentials = new NetworkCredential(Context.UserName, Context.Password); // Get response using

HTTPS and BASIC authentication

…衆ロ難τιáo~ 提交于 2019-11-27 14:47:51
问题 When I use HTTP BASIC authentication along with HTTPS, are the username and password securely passed to the server? I would be happy if you can help me with some references. I mean, it would be great if I can cite StackOverflow Q&A as a reference in, say, assignments, reports, exams, or even in a technical paper. But I think I am not there yet. 回答1: yes. if you're using https the conversation with the web server is entirely encrypted. 回答2: Yes, they are passed securely... if a hacker can