Skip to content

Commit ef9a36d

Browse files
authored
Merge pull request #25 from SAP/bug/CXCDC-10555-classes-conflict-org-json
Bug/cxcdc 10555 classes conflict org json
2 parents bcb9bdd + f8979bf commit ef9a36d

45 files changed

Lines changed: 741 additions & 5767 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Built application files
22
build/
3+
.DS_Store
34

45
# IntelliJ IDEA
56
.idea/

auth/.gitignore

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
.gradle
2+
build/
3+
!gradle/wrapper/gradle-wrapper.jar
4+
!**/src/main/**/build/
5+
!**/src/test/**/build/
6+
7+
### IntelliJ IDEA ###
8+
.idea/modules.xml
9+
.idea/jarRepositories.xml
10+
.idea/compiler.xml
11+
.idea/libraries/
12+
*.iws
13+
*.iml
14+
*.ipr
15+
out/
16+
!**/src/main/**/out/
17+
!**/src/test/**/out/
18+
19+
### Eclipse ###
20+
.apt_generated
21+
.classpath
22+
.factorypath
23+
.project
24+
.settings
25+
.springBeans
26+
.sts4-cache
27+
bin/
28+
!**/src/main/**/bin/
29+
!**/src/test/**/bin/
30+
31+
### NetBeans ###
32+
/nbproject/private/
33+
/nbbuild/
34+
/dist/
35+
/nbdist/
36+
/.nb-gradle/
37+
38+
### VS Code ###
39+
.vscode/
40+
41+
### Mac OS ###
42+
.DS_Store

auth/build.gradle

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
plugins {
2+
id 'java-library'
3+
id 'maven-publish'
4+
}
5+
6+
group = 'com.gigya'
7+
archivesBaseName = 'gigya-java-sdk-auth'
8+
version = auth_library_version
9+
10+
repositories {
11+
maven { url "https://jitpack.io" }
12+
mavenCentral()
13+
}
14+
15+
java {
16+
withSourcesJar()
17+
}
18+
19+
repositories {
20+
mavenCentral()
21+
}
22+
23+
dependencies {
24+
testImplementation group: 'junit', name: 'junit', version: '4.13.1'
25+
testImplementation 'org.json:json:20230227'
26+
testImplementation 'org.skyscreamer:jsonassert:1.2.3'
27+
testImplementation 'org.mockito:mockito-core:2.8.9'
28+
testImplementation 'org.powermock:powermock-module-junit4:1.7.4'
29+
testImplementation 'org.powermock:powermock-api-mockito2:1.7.4'
30+
testImplementation 'io.jsonwebtoken:jjwt-api:0.10.5'
31+
//noinspection VulnerableLibrariesLocal
32+
testImplementation 'io.jsonwebtoken:jjwt-impl:0.10.5',
33+
'io.jsonwebtoken:jjwt-jackson:0.10.5'
34+
35+
compileOnly project(path: ':sdk')
36+
37+
38+
implementation 'io.jsonwebtoken:jjwt-api:0.10.7'
39+
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.10.7',
40+
'io.jsonwebtoken:jjwt-jackson:0.10.7'
41+
42+
compileOnly 'org.json:json:20230227'
43+
}
44+
45+
test {
46+
useJUnitPlatform()
47+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.gigya.auth;
2+
3+
import com.gigya.socialize.GSObject;
4+
import com.gigya.socialize.GSRequest;
5+
6+
public class GSAnonymousRequest extends GSRequest {
7+
8+
/**
9+
* @param apiKey Site api key.
10+
* @param apiDomain Site api domain.
11+
* @param apiMethod Request api method.
12+
*/
13+
public GSAnonymousRequest(String apiKey, String apiDomain, String apiMethod) {
14+
super(apiKey, null, null, apiMethod, null, true, null);
15+
setAPIDomain(apiDomain);
16+
}
17+
18+
/**
19+
* @param apiKey Site api key.
20+
* @param apiDomain Site api domain.
21+
* @param clientParams Request parameters.
22+
* @param apiMethod Request api method.
23+
*/
24+
public GSAnonymousRequest(String apiKey, String apiDomain, GSObject clientParams, String apiMethod) {
25+
super(apiKey, null, null, apiMethod, clientParams, true, null);
26+
setAPIDomain(apiDomain);
27+
}
28+
29+
@Override
30+
protected void signRequest(String token, String secret, String httpMethod, String resourceURI) {
31+
// Override super call.
32+
if (this.apiKey != null) {
33+
setParam("apiKey", this.apiKey);
34+
}
35+
}
36+
37+
@Override
38+
protected boolean evaluateRequestAuthorization() {
39+
return this.apiKey != null;
40+
}
41+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.gigya.auth;
2+
3+
import com.gigya.socialize.GSRequest;
4+
5+
public class GSAuthRequest extends GSRequest {
6+
7+
private String privateKey;
8+
9+
/**
10+
* @param userKey Account user key.
11+
* @param privateKey Account private key.
12+
* @param apiMethod Request api method.
13+
* @param apiKey Site api key.
14+
*/
15+
public GSAuthRequest(String userKey, String privateKey, String apiKey, String apiMethod) {
16+
super(apiKey, null, null, apiMethod, null, true, userKey);
17+
this.privateKey = privateKey;
18+
}
19+
20+
@Override
21+
protected void signRequest(String token, String secret, String httpMethod, String resourceURI) {
22+
// Compose jwt && add to request header.
23+
final String jwt = GSAuthRequestUtils.composeJwt(this.userKey, this.privateKey);
24+
if (jwt == null) {
25+
logger.write("Failed to generate authorization JWT");
26+
}
27+
addHeader("Authorization", "Bearer " + jwt);
28+
// Api key is required.
29+
params.put("apiKey", token);
30+
}
31+
32+
@Override
33+
protected boolean evaluateRequestAuthorization() {
34+
return true;
35+
}
36+
37+
}

0 commit comments

Comments
 (0)