diff --git a/spring-security-rest-basic-auth/README.md b/spring-security-rest-basic-auth/README.md
index 221e6de505..723bcebbdd 100644
--- a/spring-security-rest-basic-auth/README.md
+++ b/spring-security-rest-basic-auth/README.md
@@ -6,3 +6,4 @@
### Relevant Articles:
- [RestTemplate with Basic Authentication in Spring](http://www.baeldung.com/2012/04/16/how-to-use-resttemplate-with-basic-authentication-in-spring-3-1)
- [HttpClient Timeout](http://www.baeldung.com/httpclient-timeout)
+- [HttpClient with SSL](http://www.baeldung.com/httpclient-ssl)
diff --git a/spring-security-rest-custom/.classpath b/spring-security-rest-custom/.classpath
index 5dea193677..5b66010de6 100644
--- a/spring-security-rest-custom/.classpath
+++ b/spring-security-rest-custom/.classpath
@@ -16,6 +16,7 @@
+
diff --git a/spring-security-rest-custom/.settings/org.eclipse.wst.common.component b/spring-security-rest-custom/.settings/org.eclipse.wst.common.component
index 3b22cb60bb..4bf6e222f3 100644
--- a/spring-security-rest-custom/.settings/org.eclipse.wst.common.component
+++ b/spring-security-rest-custom/.settings/org.eclipse.wst.common.component
@@ -4,6 +4,7 @@
+
diff --git a/spring-security-rest-custom/pom.xml b/spring-security-rest-custom/pom.xml
index d0092f861b..4e5436523f 100644
--- a/spring-security-rest-custom/pom.xml
+++ b/spring-security-rest-custom/pom.xml
@@ -1,242 +1,267 @@
-
- 4.0.0
- org.baeldung
- spring-security-rest-custom
- 0.1-SNAPSHOT
+
+ 4.0.0
+ org.baeldung
+ spring-security-rest-custom
+ 0.1-SNAPSHOT
- spring-security-rest-custom
- war
+ spring-security-rest-custom
+ war
-
+
-
+
-
- org.springframework.security
- spring-security-web
- ${org.springframework.security.version}
-
-
- org.springframework.security
- spring-security-config
- ${org.springframework.security.version}
-
+
+ org.springframework.security
+ spring-security-web
+ ${org.springframework.security.version}
+
+
+ org.springframework.security
+ spring-security-config
+ ${org.springframework.security.version}
+
-
+
-
- org.springframework
- spring-core
- ${org.springframework.version}
-
-
- org.springframework
- spring-context
- ${org.springframework.version}
-
-
- org.springframework
- spring-jdbc
- ${org.springframework.version}
-
-
- org.springframework
- spring-beans
- ${org.springframework.version}
-
-
- org.springframework
- spring-aop
- ${org.springframework.version}
-
-
- org.springframework
- spring-tx
- ${org.springframework.version}
-
-
- org.springframework
- spring-expression
- ${org.springframework.version}
-
+
+ org.springframework
+ spring-core
+ ${org.springframework.version}
+
+
+ org.springframework
+ spring-context
+ ${org.springframework.version}
+
+
+ org.springframework
+ spring-jdbc
+ ${org.springframework.version}
+
+
+ org.springframework
+ spring-beans
+ ${org.springframework.version}
+
+
+ org.springframework
+ spring-aop
+ ${org.springframework.version}
+
+
+ org.springframework
+ spring-tx
+ ${org.springframework.version}
+
+
+ org.springframework
+ spring-expression
+ ${org.springframework.version}
+
-
- org.springframework
- spring-web
- ${org.springframework.version}
-
-
- org.springframework
- spring-webmvc
- ${org.springframework.version}
-
-
-
- org.springframework
- spring-oxm
- ${org.springframework.version}
-
+
+ org.springframework
+ spring-web
+ ${org.springframework.version}
+
+
+ org.springframework
+ spring-webmvc
+ ${org.springframework.version}
+
-
+
+ org.springframework
+ spring-oxm
+ ${org.springframework.version}
+
-
- com.fasterxml.jackson.core
- jackson-databind
- 2.2.2
-
+
-
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ 2.2.2
+
-
- javax.servlet
- javax.servlet-api
- 3.0.1
- provided
-
+
-
- javax.servlet
- jstl
- 1.2
- runtime
-
+
+ javax.servlet
+ javax.servlet-api
+ 3.0.1
+ provided
+
-
+
+ javax.servlet
+ jstl
+ 1.2
+ runtime
+
-
- com.google.guava
- guava
- ${guava.version}
-
+
-
+
+ org.apache.httpcomponents
+ httpcore
+ ${httpcore.version}
+
+
+ commons-logging
+ commons-logging
+
+
+
-
- junit
- junit-dep
- ${junit.version}
- test
-
+
+ org.apache.httpcomponents
+ httpclient
+ ${httpclient.version}
+
+
+ commons-logging
+ commons-logging
+
+
+
-
- org.hamcrest
- hamcrest-core
- ${org.hamcrest.version}
- test
-
-
- org.hamcrest
- hamcrest-library
- ${org.hamcrest.version}
- test
-
+
-
- org.mockito
- mockito-core
- ${mockito.version}
- test
-
+
+ com.google.guava
+ guava
+ ${guava.version}
+
-
+
-
- spring-security-rest-custom
-
-
- src/main/resources
- true
-
-
+
+ junit
+ junit-dep
+ ${junit.version}
+ test
+
-
+
+ org.hamcrest
+ hamcrest-core
+ ${org.hamcrest.version}
+ test
+
+
+ org.hamcrest
+ hamcrest-library
+ ${org.hamcrest.version}
+ test
+
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.1
-
-
- 1.7
- true
- source
-
-
+
+ org.mockito
+ mockito-core
+ ${mockito.version}
+ test
+
-
- org.apache.maven.plugins
- maven-surefire-plugin
- ${maven-surefire-plugin.version}
-
-
-
-
-
-
-
-
-
+
-
- org.codehaus.cargo
- cargo-maven2-plugin
- ${cargo-maven2-plugin.version}
-
- true
-
- jetty8x
- embedded
-
-
-
-
-
-
- 8082
-
-
-
-
+
+ spring-security-rest-custom
+
+
+ src/main/resources
+ true
+
+
-
+
-
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.1
+
+
+ 1.7
+ true
+ source
+
+
-
-
- 3.2.4.RELEASE
- 3.1.4.RELEASE
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ ${maven-surefire-plugin.version}
+
+
+
+
+
+
+
+
+
-
- 4.2.3.Final
- 5.1.26
+
+ org.codehaus.cargo
+ cargo-maven2-plugin
+ ${cargo-maven2-plugin.version}
+
+ true
+
+ jetty8x
+ embedded
+
+
+
+
+
+
+ 8082
+
+
+
+
-
- 1.7.5
- 1.0.11
+
-
- 5.0.1.Final
+
-
- 14.0.1
- 3.1
+
+
+ 3.2.4.RELEASE
+ 3.1.4.RELEASE
-
- 1.3
- 4.11
- 1.9.5
+
+ 4.2.3.Final
+ 5.1.26
- 4.2.4
- 4.2.5
+
+ 1.7.5
+ 1.0.11
- 1.8.1
- 1.8.9
+
+ 5.0.1.Final
-
- 1.4.3
- 2.15
-
+
+ 14.0.1
+ 3.1
+
+
+ 1.3
+ 4.11
+ 1.9.5
+
+ 4.2.4
+ 4.2.5
+
+ 1.8.1
+ 1.8.9
+
+
+ 1.4.3
+ 2.15
+
\ No newline at end of file
diff --git a/spring-security-rest-custom/src/test/java/org/baeldung/live/HttpLiveServiceTemp.java b/spring-security-rest-custom/src/test/java/org/baeldung/live/HttpLiveServiceTemp.java
new file mode 100644
index 0000000000..1e1a08088b
--- /dev/null
+++ b/spring-security-rest-custom/src/test/java/org/baeldung/live/HttpLiveServiceTemp.java
@@ -0,0 +1,102 @@
+package org.baeldung.live;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.junit.Assert.assertThat;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.http.Header;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpHeaders;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.params.BasicHttpParams;
+import org.apache.http.params.HttpParams;
+import org.apache.http.util.EntityUtils;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.google.common.base.Preconditions;
+
+public class HttpLiveServiceTemp {
+
+ private DefaultHttpClient client;
+
+ // fixtures
+
+ @Before
+ public final void before() {
+ final HttpParams httpParameters = new BasicHttpParams();
+ httpParameters.setParameter("http.protocol.handle-redirects", false);
+
+ client = new DefaultHttpClient(httpParameters);
+ }
+
+ // tests
+
+ @Test
+ public final void givenShortenedOnce_whenUrlIsUnshortened_thenCorrectResult() throws IOException {
+ final String expectedResult = "http://www.baeldung.com/rest-versioning";
+ final String actualResult = expandSingleLevel("http://bit.ly/13jEoS1");
+ assertThat(actualResult, equalTo(expectedResult));
+ }
+
+ @Test
+ public final void givenShortenedMultiple_whenUrlIsUnshortened_thenCorrectResult() throws IOException {
+ final String expectedResult = "http://www.baeldung.com/rest-versioning";
+ final String actualResult = expand("http://t.co/e4rDDbnzmk");
+ assertThat(actualResult, equalTo(expectedResult));
+ }
+
+ // API
+
+ final String expand(final String urlArg) throws IOException {
+ String originalUrl = urlArg;
+ String newUrl = expandSingleLevel(originalUrl);
+ while (!originalUrl.equals(newUrl)) {
+ originalUrl = newUrl;
+ newUrl = expandSingleLevel(originalUrl);
+ }
+
+ return newUrl;
+ }
+
+ final String expandSingleLevel(final String url) throws IOException {
+ HttpGet request = null;
+ HttpEntity httpEntity = null;
+ InputStream entityContentStream = null;
+
+ try {
+ request = new HttpGet(url);
+ final HttpResponse httpResponse = client.execute(request);
+
+ httpEntity = httpResponse.getEntity();
+ entityContentStream = httpEntity.getContent();
+
+ final int statusCode = httpResponse.getStatusLine().getStatusCode();
+ if (statusCode != 301 && statusCode != 302) {
+ return url;
+ }
+ final Header[] headers = httpResponse.getHeaders(HttpHeaders.LOCATION);
+ Preconditions.checkState(headers.length == 1);
+ final String newUrl = headers[0].getValue();
+
+ return newUrl;
+ } catch (final IllegalArgumentException uriEx) {
+ return url;
+ } finally {
+ if (request != null) {
+ request.releaseConnection();
+ }
+ if (entityContentStream != null) {
+ entityContentStream.close();
+ }
+ if (httpEntity != null) {
+ EntityUtils.consume(httpEntity);
+ }
+ }
+ }
+
+}
diff --git a/spring-security-rest-digest-auth/pom.xml b/spring-security-rest-digest-auth/pom.xml
index db8a47f86b..5b8cc88dc7 100644
--- a/spring-security-rest-digest-auth/pom.xml
+++ b/spring-security-rest-digest-auth/pom.xml
@@ -93,18 +93,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
org.apache.httpcomponents
httpcore