Skip to content

Commit 722a2da

Browse files
author
Swathi Shenoy
committed
Adding java sample application
0 parents  commit 722a2da

File tree

29 files changed

+1979
-0
lines changed

29 files changed

+1979
-0
lines changed

.github/linters/sun_checks.xml

Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE module PUBLIC
3+
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
4+
"https://checkstyle.org/dtds/configuration_1_3.dtd">
5+
6+
<!--
7+
8+
Checkstyle configuration that checks the sun coding conventions from:
9+
10+
- the Java Language Specification at
11+
https://docs.oracle.com/javase/specs/jls/se11/html/index.html
12+
13+
- the Sun Code Conventions at https://www.oracle.com/java/technologies/javase/codeconventions-contents.html
14+
15+
- the Javadoc guidelines at
16+
https://www.oracle.com/technical-resources/articles/java/javadoc-tool.html
17+
18+
- the JDK Api documentation https://docs.oracle.com/en/java/javase/11/
19+
20+
- some best practices
21+
22+
Checkstyle is very configurable. Be sure to read the documentation at
23+
https://checkstyle.org (or in your downloaded distribution).
24+
25+
Most Checks are configurable, be sure to consult the documentation.
26+
27+
To completely disable a check, just comment it out or delete it from the file.
28+
To suppress certain violations please review suppression filters.
29+
30+
Finally, it is worth reading the documentation.
31+
32+
-->
33+
34+
<module name="Checker">
35+
<!--
36+
If you set the basedir property below, then all reported file
37+
names will be relative to the specified directory. See
38+
https://checkstyle.org/config.html#Checker
39+
40+
<property name="basedir" value="${basedir}"/>
41+
-->
42+
<property name="severity" value="error"/>
43+
44+
<property name="fileExtensions" value="java, properties, xml"/>
45+
46+
<!-- Excludes all 'module-info.java' files -->
47+
<!-- See https://checkstyle.org/config_filefilters.html -->
48+
<module name="BeforeExecutionExclusionFileFilter">
49+
<property name="fileNamePattern" value="module\-info\.java$"/>
50+
</module>
51+
52+
<!-- https://checkstyle.org/config_filters.html#SuppressionFilter -->
53+
<module name="SuppressionFilter">
54+
<property name="file" value="${org.checkstyle.sun.suppressionfilter.config}" default="checkstyle-suppressions.xml" />
55+
<property name="optional" value="true"/>
56+
</module>
57+
58+
<!-- Checks that a package-info.java file exists for each package. -->
59+
<!-- See https://checkstyle.org/config_javadoc.html#JavadocPackage -->
60+
<!--module name="JavadocPackage"/-->
61+
62+
<!-- Checks whether files end with a new line. -->
63+
<!-- See https://checkstyle.org/config_misc.html#NewlineAtEndOfFile -->
64+
<module name="NewlineAtEndOfFile"/>
65+
66+
<!-- Checks that property files contain the same keys. -->
67+
<!-- See https://checkstyle.org/config_misc.html#Translation -->
68+
<module name="Translation"/>
69+
70+
<!-- Checks for Size Violations. -->
71+
<!-- See https://checkstyle.org/config_sizes.html -->
72+
<module name="FileLength"/>
73+
<module name="LineLength">
74+
<property name="fileExtensions" value="java"/>
75+
<property name="severity" value="warning" />
76+
</module>
77+
78+
<!-- Checks for whitespace -->
79+
<!-- See https://checkstyle.org/config_whitespace.html -->
80+
<!--<module name="FileTabCharacter"/>-->
81+
82+
<!-- Miscellaneous other checks. -->
83+
<!-- See https://checkstyle.org/config_misc.html
84+
<module name="RegexpSingleline">
85+
<property name="format" value="\s+$"/>
86+
<property name="minimum" value="0"/>
87+
<property name="maximum" value="0"/>
88+
<property name="message" value="Line has trailing spaces."/>
89+
</module>-->
90+
91+
<!-- Checks for Headers -->
92+
<!-- See https://checkstyle.org/config_header.html -->
93+
<!-- <module name="Header"> -->
94+
<!-- <property name="headerFile" value="${checkstyle.header.file}"/> -->
95+
<!-- <property name="fileExtensions" value="java"/> -->
96+
<!-- </module> -->
97+
98+
<!-- Enables @SuppressWarnings Support -->
99+
<module name="SuppressWarningsFilter"/>
100+
<module name="TreeWalker">
101+
102+
<!-- Checks for Javadoc comments. -->
103+
<!-- See https://checkstyle.org/config_javadoc.html -->
104+
<module name="InvalidJavadocPosition">
105+
<property name="severity" value="warning" />
106+
</module>
107+
<!--module name="JavadocMethod"/-->
108+
<module name="JavadocType">
109+
<property name="severity" value="warning" />
110+
</module>
111+
<!--module name="JavadocVariable"/-->
112+
<module name="JavadocStyle">
113+
<property name="severity" value="warning" />
114+
</module>
115+
<module name="MissingJavadocMethod">
116+
<property name="severity" value="warning" />
117+
</module>
118+
<!-- Enables @SuppressWarnings Support -->
119+
<module name="SuppressWarningsHolder"/>
120+
121+
<!-- Checks for Naming Conventions. -->
122+
<!-- See https://checkstyle.org/config_naming.html -->
123+
<!--<module name="ConstantName"/>-->
124+
<module name="LocalFinalVariableName"/>
125+
<!--<module name="LocalVariableName"/>-->
126+
<!--<module name="MemberName"/>-->
127+
<!--<module name="MethodName"/>-->
128+
<module name="PackageName"/>
129+
<module name="ParameterName"/>
130+
<module name="StaticVariableName"/>
131+
<module name="TypeName"/>
132+
133+
<!-- Checks for imports -->
134+
<!-- See https://checkstyle.org/config_imports.html -->
135+
<module name="AvoidStarImport">
136+
<property name="excludes" value="com.linkedin.oauth.util.Constants"/>
137+
</module>
138+
<module name="IllegalImport"/>
139+
<!-- defaults to sun.* packages -->
140+
<module name="RedundantImport"/>
141+
<module name="UnusedImports">
142+
<property name="processJavadoc" value="false"/>
143+
</module>
144+
145+
<!-- Checks for Size Violations. -->
146+
<!-- See https://checkstyle.org/config_sizes.html -->
147+
<module name="MethodLength"/>
148+
<module name="ParameterNumber"/>
149+
150+
<!-- Checks for whitespace -->
151+
<!-- See https://checkstyle.org/config_whitespace.html -->
152+
<module name="EmptyForIteratorPad"/>
153+
<!--<module name="GenericWhitespace"/>-->
154+
<module name="MethodParamPad"/>
155+
<module name="NoWhitespaceAfter"/>
156+
<module name="NoWhitespaceBefore"/>
157+
<module name="OperatorWrap"/>
158+
<!--<module name="ParenPad"/>-->
159+
<module name="TypecastParenPad"/>
160+
<module name="WhitespaceAfter"/>
161+
<module name="WhitespaceAround"/>
162+
163+
<!-- Modifier Checks -->
164+
<!-- See https://checkstyle.org/config_modifiers.html -->
165+
<module name="ModifierOrder"/>
166+
<module name="RedundantModifier"/>
167+
168+
<!-- Checks for blocks. You know, those {}'s -->
169+
<!-- See https://checkstyle.org/config_blocks.html -->
170+
<module name="AvoidNestedBlocks"/>
171+
<module name="EmptyBlock"/>
172+
<module name="LeftCurly"/>
173+
<module name="NeedBraces"/>
174+
<module name="RightCurly"/>
175+
176+
<!-- Checks for common coding problems -->
177+
<!-- See https://checkstyle.org/config_coding.html -->
178+
<module name="EmptyStatement"/>
179+
<module name="EqualsHashCode"/>
180+
<module name="HiddenField">
181+
<property name="ignoreSetter" value="true" />
182+
<property name="ignoreConstructorParameter" value="true" />
183+
<property name="severity" value="warning" />
184+
</module>
185+
<module name="IllegalInstantiation"/>
186+
<module name="InnerAssignment"/>
187+
<module name="MagicNumber"/>
188+
<module name="MissingSwitchDefault"/>
189+
<module name="MultipleVariableDeclarations"/>
190+
<module name="SimplifyBooleanExpression"/>
191+
<module name="SimplifyBooleanReturn"/>
192+
193+
<!-- Checks for class design -->
194+
<!-- See https://checkstyle.org/config_design.html -->
195+
<module name="DesignForExtension"/>
196+
<module name="FinalClass"/>
197+
<!--<module name="HideUtilityClassConstructor"/>-->
198+
<module name="InterfaceIsType"/>
199+
<!--<module name="VisibilityModifier"/>-->
200+
201+
<!-- Miscellaneous other checks. -->
202+
<!-- See https://checkstyle.org/config_misc.html -->
203+
<module name="ArrayTypeStyle"/>
204+
<module name="FinalParameters"/>
205+
<module name="TodoComment"/>
206+
<module name="UpperEll"/>
207+
208+
<!-- https://checkstyle.org/config_filters.html#SuppressionXpathFilter -->
209+
<module name="SuppressionXpathFilter">
210+
<property name="file" value="${org.checkstyle.sun.suppressionxpathfilter.config}" default="checkstyle-xpath-suppressions.xml" />
211+
<property name="optional" value="true"/>
212+
</module>
213+
214+
</module>
215+
216+
</module>

.github/workflows/main.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Workflow setup to test Client and Server components
2+
3+
name: LinkedIn Java OAuth Sample App Validation
4+
5+
6+
on:
7+
push:
8+
branches: [ main ]
9+
pull_request:
10+
branches: [ main ]
11+
12+
# Allows you to run this workflow manually from the Actions tab
13+
#workflow_dispatch:
14+
15+
16+
jobs:
17+
build:
18+
19+
runs-on: ubuntu-latest
20+
steps:
21+
22+
- uses: actions/checkout@v2
23+
24+
- name: Set up JDK 11
25+
uses: actions/setup-java@v2
26+
with:
27+
java-version: '11'
28+
distribution: 'adopt'
29+
- name: Super-Linter
30+
uses: github/[email protected]
31+
env:
32+
GITHUB_TOKEN : ${{secrets.GITHUB_TOKEN}}
33+
VALIDATE_JAVA : true
34+
35+
# Runs a spring boot server and test cases
36+
- name: Build and Run Tests for client & Server
37+
run: |
38+
cd client
39+
mvn clean install
40+
cd ..
41+
cd server
42+
mvn clean install
43+
44+
45+
46+

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
*.DS_Store
2+
target/
3+
bin/
4+
/.settings
5+
/.classpath
6+
/.project
7+
/.DS_Store
8+
*.settings/
9+
*.class
10+
*.classpath
11+
*.project
12+
config.properties

License.pdf

56.9 KB
Binary file not shown.

README.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Sample Application for LinkedIn APIs
2+
3+
## Overview
4+
5+
Sample Application is a ready-to-use code example that enables you to try out RESTful calls to LinkedIn's APIs. The application provides scalable and customizable code for your requirements as you begin API development with LinkedIn.
6+
7+
The sample application contains the client and server component you can use to manage your requests to LinkedIn's APIs. The server creates and stores your access token and invokes APIs upon request from the client application. You can download or clone the OAuth sample application and try out these APIs.
8+
9+
> **Note**: For a detailed demo, please visit LinkedIn's public documentation page
10+
11+
The sample application uses the following development tools:
12+
13+
* Spring Boot: Used as web server framework [<https://spring.io/projects/spring-boot>]
14+
* LinkedIn OAuth 2.0: user authorization and API authentication
15+
* Maven: app building and management
16+
* Java: SE 7 or later versions are required for development
17+
18+
## Prerequisites
19+
20+
* Ensure that you have an application registered in [LinkedIn Developer Portal](https://developer.linkedin.com/).
21+
Once you have your application, note down the Client ID and Client Secret
22+
* Add <http://localhost:8080/login> to the Authorized Redirect URLs under the **Authentication** section
23+
* Configure the application build by installing MAVEN using [Installing Apache Maven](https://maven.apache.org/install.html)
24+
25+
## Configure the application
26+
27+
**Configure the client app:**
28+
29+
1. Navigate to the **application.properties** file. You can find this file under: **/client/src/main/resources/application.properties**
30+
1. To edit server link or port with custom values modify the following values:
31+
32+
> server.port = <replace_with_required_port_no>
33+
34+
> SERVER_URL = <replace_with_required_server_url>
35+
36+
1. Save the changes.
37+
38+
**Configure the server app:**
39+
40+
1. Navigate to the **config.properties** file. You can find this file under: **/server/src/main/resources/config.properties**
41+
2. Edit the following properties in the file with your client credentials:
42+
43+
> clientId = <replace_with_client_id>
44+
45+
> clientSecret = <replace_with_client_secret>
46+
47+
> redirectUri = <replace_with_redirect_url_set_in_developer_portal>
48+
49+
> scope = <replace_with_api_scope>
50+
client_url = <replace_with_client_url>
51+
52+
3. Save the changes.
53+
54+
## Start the application
55+
56+
To start the server:
57+
58+
1. Navigate to the server folder.
59+
2. Open the terminal and run the following command to install dependencies:
60+
`mvn install`
61+
3. Execute the following command to run the spring-boot server:
62+
`mvn spring-boot:run`
63+
64+
> **Note:** The server will be running on <http://localhost:8080/>
65+
66+
To start the client:
67+
68+
1. Navigate to the client folder.
69+
2. Open the terminal and run the following command to install dependencies:
70+
`mvn install`
71+
3. Execute the following command to run the spring-boot server:
72+
`mvn spring-boot:run`
73+
74+
> **Note**: The client will be running on <http://localhost:8989/>
75+
76+
## List of dependencies
77+
78+
|Component Name |License |Linked |Modified |
79+
|---------------|--------|--------|----------|
80+
|[boot:spring-boot-starter-parent:2.5.2](<https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-parent/2.5.2>) |Apache 2.0 |Static |No |
81+
|[boot:spring-boot-starter-parent:2.5.2](https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-parent/2.5.2) |Apache 2.0 |Static |No |
82+
|[org.springframework.boot:spring-boot-starter-thymeleaf:2.2.2.RELEASE](https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-thymeleaf/2.2.2.RELEASE) |Apache 2.0 |Static |No |
83+
|[org.springframework.boot:spring-boot-devtools:2.6.0](https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-devtools/2.6.0) |Apache 2.0 |Static |No |
84+
|[com.fasterxml.jackson.core:jackson-databind:2.13.0](https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind/2.13.0) |Apache 2.0 |Static |No |
85+
|[com.fasterxml.jackson.core:jackson-core:2.13.0](https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core/2.13.0) |Apache 2.0 |Static |No |
86+
|[org.springframework.boot:spring-boot-starter-web:2.5.2](https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web/2.5.2) |Apache 2.0 |Static |No |
87+
| [org.springframework.boot:spring-boot-starter-test:2.6.0](https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-test/2.6.0) |Apache 2.0 |Static |No |
88+
|[org.springframework:spring-core:5.3.13](https://mvnrepository.com/artifact/org.springframework/spring-core/5.3.13) |Apache 2.0 |Static |No |

0 commit comments

Comments
 (0)