This repository has been archived by the owner on Nov 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #269 from galasa-dev/Iss1976
Implemented get user's access token by loginId
- Loading branch information
Showing
29 changed files
with
1,421 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
...parent/dev.galasa.auth.couchdb/src/main/java/dev/galasa/auth/couchdb/internal/Errors.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* Copyright contributors to the Galasa project | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
|
||
package dev.galasa.auth.couchdb.internal; | ||
|
||
|
||
import java.text.MessageFormat; | ||
|
||
public enum Errors { | ||
|
||
ERROR_FAILED_TO_PARSE_COUCHDB_DESIGN_DOC (7500, | ||
"GAL7500E: The Galasa auth extension could not check that couchdb has the correct definition for the dababase in which access tokens are stored."+ | ||
"The design of the database could not be parsed. Please report this error to your Galasa system administrator. Detailed cause of this problem: {}"), | ||
ERROR_FAILED_TO_UPDATE_COUCHDB_DESING_DOC_CONFLICT (7501, | ||
"GAL7501E: The Galasa auth extension could not upgrade the definition of the couchdb database in which access tokens are stored."+ | ||
"The design of the database could not be updated due to clashing updates. Please report this error to your Galasa system administrator."), | ||
; | ||
|
||
private String template; | ||
private int expectedParameterCount; | ||
private Errors(int ordinal, String template ) { | ||
this.template = template ; | ||
this.expectedParameterCount = this.template.split("[{]").length-1; | ||
} | ||
|
||
public String getMessage() { | ||
String msg ; | ||
int actualParameterCount = 0; | ||
|
||
if (actualParameterCount!= this.expectedParameterCount) { | ||
msg = getWrongNumberOfParametersErrorMessage(actualParameterCount,expectedParameterCount); | ||
} else { | ||
msg = this.template; | ||
} | ||
|
||
return msg; | ||
} | ||
|
||
public String getMessage(Object o1) { | ||
|
||
String msg ; | ||
int actualParameterCount = 1; | ||
|
||
if (actualParameterCount!= this.expectedParameterCount) { | ||
msg = getWrongNumberOfParametersErrorMessage(actualParameterCount,expectedParameterCount); | ||
} else { | ||
msg = MessageFormat.format(this.template,o1); | ||
} | ||
|
||
return msg; | ||
} | ||
|
||
public String getMessage(Object o1, Object o2) { | ||
|
||
String msg ; | ||
int actualParameterCount = 2; | ||
|
||
if (actualParameterCount!= this.expectedParameterCount) { | ||
msg = getWrongNumberOfParametersErrorMessage(actualParameterCount,expectedParameterCount); | ||
} else { | ||
msg = MessageFormat.format(this.template,o1,o2); | ||
} | ||
|
||
return msg; | ||
} | ||
|
||
public String getMessage(Object o1, Object o2, Object o3) { | ||
|
||
String msg ; | ||
int actualParameterCount = 3; | ||
|
||
if (actualParameterCount!= this.expectedParameterCount) { | ||
msg = getWrongNumberOfParametersErrorMessage(actualParameterCount,expectedParameterCount); | ||
} else { | ||
msg = MessageFormat.format(this.template,o1,o2,o3); | ||
} | ||
|
||
return msg; | ||
} | ||
|
||
private String getWrongNumberOfParametersErrorMessage(int actualParameterCount,int expectedParameterCount) { | ||
String template = "Failed to render message template. Not the expected number of parameters. Got ''{0}''. Expected ''{1}''"; | ||
String msg = MessageFormat.format(template,actualParameterCount, this.expectedParameterCount); | ||
return msg ; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...a.auth.couchdb/src/main/java/dev/galasa/auth/couchdb/internal/beans/TokenDBLoginView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* Copyright contributors to the Galasa project | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package dev.galasa.auth.couchdb.internal.beans; | ||
|
||
public class TokenDBLoginView { | ||
public String map; | ||
} |
13 changes: 13 additions & 0 deletions
13
...alasa.auth.couchdb/src/main/java/dev/galasa/auth/couchdb/internal/beans/TokenDBViews.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Copyright contributors to the Galasa project | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package dev.galasa.auth.couchdb.internal.beans; | ||
|
||
import com.google.gson.annotations.SerializedName; | ||
|
||
public class TokenDBViews { | ||
@SerializedName("loginId-view") | ||
public TokenDBLoginView loginIdView; | ||
} |
24 changes: 24 additions & 0 deletions
24
....couchdb/src/main/java/dev/galasa/auth/couchdb/internal/beans/TokensDBNameViewDesign.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright contributors to the Galasa project | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package dev.galasa.auth.couchdb.internal.beans; | ||
|
||
//{ | ||
// "_id": "_design/docs", | ||
// "_rev": "3-xxxxxxxxxxx9c9072dyy", | ||
// "views": { | ||
// "loginId-view": { | ||
// "map": "function (doc) {\n if (doc.owner && doc.owner.loginId) {\n emit(doc.owner.loginId, doc);\n }\n}" | ||
// } | ||
// }, | ||
// "language": "javascript" | ||
// } | ||
public class TokensDBNameViewDesign { | ||
public String _rev; | ||
public String _id; | ||
public TokenDBViews views; | ||
public String language; | ||
} | ||
|
Oops, something went wrong.