Skip to content

Commit a33925b

Browse files
committed
basic authentication with Open Feign
1 parent 97dcd27 commit a33925b

14 files changed

Lines changed: 221 additions & 0 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
okhttp-examples/.settings/org.eclipse.core.resources.prefs
2+
okhttp-examples/.settings/org.eclipse.m2e.core.prefs

open-feign-example/.classpath

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" output="target/classes" path="src/main/java">
4+
<attributes>
5+
<attribute name="optional" value="true"/>
6+
<attribute name="maven.pomderived" value="true"/>
7+
</attributes>
8+
</classpathentry>
9+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
10+
<attributes>
11+
<attribute name="maven.pomderived" value="true"/>
12+
</attributes>
13+
</classpathentry>
14+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
15+
<attributes>
16+
<attribute name="maven.pomderived" value="true"/>
17+
</attributes>
18+
</classpathentry>
19+
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
20+
<attributes>
21+
<attribute name="maven.pomderived" value="true"/>
22+
</attributes>
23+
</classpathentry>
24+
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
25+
<attributes>
26+
<attribute name="optional" value="true"/>
27+
<attribute name="maven.pomderived" value="true"/>
28+
</attributes>
29+
</classpathentry>
30+
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
31+
<attributes>
32+
<attribute name="maven.pomderived" value="true"/>
33+
</attributes>
34+
</classpathentry>
35+
<classpathentry kind="output" path="target/classes"/>
36+
</classpath>

open-feign-example/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target/

open-feign-example/.project

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>open-feign-example</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.springframework.ide.eclipse.core.springbuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>org.eclipse.m2e.core.maven2Builder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
</buildSpec>
24+
<natures>
25+
<nature>org.springframework.ide.eclipse.core.springnature</nature>
26+
<nature>org.eclipse.jdt.core.javanature</nature>
27+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
28+
</natures>
29+
</projectDescription>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
eclipse.preferences.version=1
2+
encoding//src/main/java=UTF-8
3+
encoding//src/main/resources=UTF-8
4+
encoding//src/test/java=UTF-8
5+
encoding//src/test/resources=UTF-8
6+
encoding/<project>=UTF-8
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
3+
org.eclipse.jdt.core.compiler.compliance=1.8
4+
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
5+
org.eclipse.jdt.core.compiler.source=1.8
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
activeProfiles=
2+
eclipse.preferences.version=1
3+
resolveWorkspaceProjects=true
4+
version=1

open-feign-example/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Open Feign example
2+
3+
## 1. Import source code into Eclipse
4+
5+
Menu **File –> Import –> Maven –> Existing Maven Projects**
6+
7+
Browse to your source code location
8+
9+
Click **Finish** button to finish the importing
10+
11+
12+
Source code are described:
13+
###[Convert Java Objects To JSON And Vice Versa](

open-feign-example/pom.xml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.howtoprogram</groupId>
5+
<artifactId>open-feign-example</artifactId>
6+
<version>0.0.1-SNAPSHOT</version>
7+
<properties>
8+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
9+
<maven.compiler.source>1.8</maven.compiler.source>
10+
<maven.compiler.target>1.8</maven.compiler.target>
11+
</properties>
12+
13+
<dependencies>
14+
<!-- Begin Netflix Feign dependencies -->
15+
<dependency>
16+
<groupId>com.netflix.feign</groupId>
17+
<artifactId>feign-core</artifactId>
18+
<version>8.18.0</version>
19+
</dependency>
20+
<dependency>
21+
<groupId>com.netflix.feign</groupId>
22+
<artifactId>feign-jackson</artifactId>
23+
<version>8.18.0</version>
24+
</dependency>
25+
<!-- End Netflix Feign dependencies -->
26+
<dependency>
27+
<groupId>junit</groupId>
28+
<artifactId>junit</artifactId>
29+
<version>4.8.1</version>
30+
<scope>test</scope>
31+
</dependency>
32+
</dependencies>
33+
</project>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.howtoprogram.repository.feign.auth;
2+
3+
public class AuthStatus {
4+
private boolean authenticated;
5+
private String user;
6+
7+
// getters and setters are omitted for shortly
8+
9+
public boolean isAuthenticated() {
10+
return authenticated;
11+
}
12+
13+
public void setAuthenticated(boolean authenticated) {
14+
this.authenticated = authenticated;
15+
}
16+
17+
public String getUser() {
18+
return user;
19+
}
20+
21+
public void setUser(String user) {
22+
this.user = user;
23+
}
24+
25+
}

0 commit comments

Comments
 (0)