Skip to content

Commit 6724019

Browse files
authored
Merge pull request #12 from topcoder-platform/dev
Sync - group check for resources
2 parents 8fe9750 + 0b8c8e9 commit 6724019

File tree

8 files changed

+2518
-2050
lines changed

8 files changed

+2518
-2050
lines changed

build-dependencies.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@
171171
<pathelement location="${aws.jar}" />
172172
<pathelement location="${httpclient.jar}" />
173173
<pathelement location="${httpcore.jar}" />
174+
<pathelement location="${xerces.jar}" />
174175

175176
<path refid="spring_libs"/>
176177
<path refid="poi_libs"/>

conf/MessageResources.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,6 +1328,7 @@ error.com.cronos.onlinereview.actions.editProject.AggregationReviewMustFollow=Ag
13281328
error.com.cronos.onlinereview.actions.editProject.FinalFixMustFollow=Final fix must follow either appeals response or aggregation or aggregation review, or final review
13291329
error.com.cronos.onlinereview.actions.editProject.FinalFixMustBeFollowed=Final fix must be followed by final review
13301330
error.com.cronos.onlinereview.actions.editProject.FinalReviewMustFollow=Final review must follow final fix
1331+
error.com.cronos.onlinereview.actions.editProject.Resource.GroupPermissionDenied=User is restricted by challenge groups
13311332
error.com.cronos.onlinereview.actions.editProject.Resource.Empty=*Specify resource''s handle
13321333
error.com.cronos.onlinereview.actions.editProject.Resource.NotFound=*There''s no such member
13331334
error.com.cronos.onlinereview.actions.editProject.Resource.TrueSubmitterHandleChanged=*Handle for this submitter can not be changed as this resource has already submitted for the project

conf/OnlineReview.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5213,6 +5213,22 @@
52135213
<Property name="topcoder_api_base_url">
52145214
<Value>@topcoder_api_base_url@</Value>
52155215
</Property>
5216+
5217+
<Property name="user_group_membership_url">
5218+
<Value>@topcoder_api_base_url_v3@/groups?memberId=%s&amp;membershipType=User</Value>
5219+
</Property>
5220+
<Property name="v3jwt_cookie_name">
5221+
<Value>v3jwt</Value>
5222+
</Property>
5223+
<Property name="v2jwt_cookie_name">
5224+
<Value>tcjwt</Value>
5225+
</Property>
5226+
<Property name="v3jwt_authorization_url">
5227+
<Value>http://api.topcoder-dev.com/v3/authorizations</Value>
5228+
</Property>
5229+
<Property name="sso_domain_for_v3jwt_cookie">
5230+
<Value>.topcoder.com</Value>
5231+
</Property>
52165232
</Config>
52175233

52185234
<!--

src/java/main/com/cronos/onlinereview/actions/project/SaveProjectAction.java

Lines changed: 2166 additions & 2047 deletions
Large diffs are not rendered by default.

src/java/main/com/cronos/onlinereview/dataaccess/ProjectDataAccess.java

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,17 @@
1616
import com.topcoder.management.project.ProjectPropertyType;
1717
import com.topcoder.management.project.ProjectStatus;
1818
import com.topcoder.shared.dataAccess.resultSet.ResultSetContainer;
19+
import com.topcoder.shared.dataAccess.resultSet.ResultSetContainer.ResultSetRow;
1920
import com.topcoder.shared.util.DBMS;
2021

2122
/**
2223
* <p>A simple DAO for projects backed up by Query Tool.</p>
24+
*
25+
* Changes in version 2.1 Topcoder - Add Group Permission Check For Adding Resources v1.0
26+
* - add the checkUserChallengeEligibility method to check user group permission
2327
*
2428
* @author TCSASSEMBLER
25-
* @version 2.0
29+
* @version 2.1
2630
*/
2731
public class ProjectDataAccess extends BaseDataAccess {
2832

@@ -305,4 +309,39 @@ public long getProjectClient(long directProjectId) {
305309
}
306310
return 0;
307311
}
312+
313+
314+
/**
315+
* Check user challenge eligibility
316+
*
317+
* @param userId the userId to use
318+
* @param challengeId the challengeId to use
319+
* @return the Map<String,Long> result contains the group and challenge info
320+
*/
321+
public Map<String, Long> checkUserChallengeEligibility(long userId, long challengeId) {
322+
String queryName = "get_challenge_accessibility_and_groups";
323+
ResultSetContainer resultContainer = runQueryInDB(DBMS.OLTP_DATASOURCE_NAME, queryName,
324+
new String[] {"userId", "challengeId"}, new String[] {userId + "", challengeId + ""}).get(queryName);
325+
326+
if (resultContainer != null && resultContainer.getRowCount() > 0) {
327+
Map<String, Long> map = new HashMap<String, Long>();
328+
ResultSetRow row = resultContainer.getRow(0);
329+
330+
Object obj = row.getItem("user_group_xref_found").getResultData();
331+
if (obj != null) {
332+
map.put("user_group_xref_found", Long.parseLong(obj.toString()));
333+
}
334+
obj = row.getItem("challenge_group_ind").getResultData();
335+
if (obj != null) {
336+
map.put("challenge_group_ind", Long.parseLong(obj.toString()));
337+
}
338+
obj = row.getItem("group_id").getResultData();
339+
if (obj != null) {
340+
map.put("group_id", Long.parseLong(obj.toString()));
341+
}
342+
return map;
343+
}
344+
345+
return null;
346+
}
308347
}

src/java/main/com/cronos/onlinereview/util/ConfigHelper.java

Lines changed: 103 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@
2626
* This class is thread-safe as its inner state is initialized only once and
2727
* is not changed afterwards.
2828
* </p>
29+
*
30+
* Changes in version 2.1 Topcoder - Add Group Permission Check For Adding Resources v1.0
31+
* - add the userGroupMemebershipUrl, v3jwtCookieName, v2jwtCookieName, v3jwtAuthorizationUrl,
32+
* ssoDomainForV3jwtCookie configuration values
2933
*
3034
* @author TCSASSEMBLER
31-
* @version 2.0
35+
* @version 2.1
3236
*/
3337
public class ConfigHelper {
3438

@@ -553,6 +557,31 @@ public class ConfigHelper {
553557
*/
554558
private static final String THURGOOD_PASSWORD_PROP = "thurgood_password";
555559

560+
/**
561+
* <p>A <code>String</code> providing the name for v3 jwt cookie name property.</p>
562+
*/
563+
private static final String V3_JWT_COOKIE_NAME = "v3jwt_cookie_name";
564+
565+
/**
566+
* <p>A <code>String</code> providing the name for user group memeber ship url property.</p>
567+
*/
568+
private static final String USER_GROUP_MEMBERSHIP_URL = "user_group_membership_url";
569+
570+
/**
571+
* <p>A <code>String</code> providing the name for v2 jwt cookie name property.</p>
572+
*/
573+
private static final String V2_JWT_COOKIE_NAME = "v2jwt_cookie_name";
574+
575+
/**
576+
* <p>A <code>String</code> providing the name for sso domain for v3 jwt cookie property.</p>
577+
*/
578+
private static final String SSO_DOMAIN_FOR_V3_JWT_COOKIE = "sso_domain_for_v3jwt_cookie";
579+
580+
/**
581+
* <p>A <code>String</code> providing the name for v3 jwt authorization url property.</p>
582+
*/
583+
private static final String V3_JWT_AUTHORIZATION_URL = "v3jwt_authorization_url";
584+
556585
/**
557586
* This member variable holds the submitter role id.
558587
*/
@@ -909,6 +938,31 @@ public class ConfigHelper {
909938
* <p>Represents the password of the Thurgood user.</p>
910939
*/
911940
private static String thurgoodPassword;
941+
942+
/**
943+
* <p>Represents the userGroupMembershipUrl.</p>
944+
*/
945+
private static String userGroupMembershipUrl;
946+
947+
/**
948+
* <p>Represents the v3jwtCookieBame.</p>
949+
*/
950+
private static String v3jwtCookieName;
951+
952+
/**
953+
* <p>Represents the v2jwtCookieBame.</p>
954+
*/
955+
private static String v2jwtCookieName;
956+
957+
/**
958+
* <p>Represents the v3jwtAuthorizationUrl.</p>
959+
*/
960+
private static String v3jwtAuthorizationUrl;
961+
962+
/**
963+
* <p>Represents the ssoDomainForV3jwtCookie.</p>
964+
*/
965+
private static String ssoDomainForV3jwtCookie;
912966

913967
static {
914968
// Obtaining the instance of Configuration Manager
@@ -1505,6 +1559,11 @@ public class ConfigHelper {
15051559
thurgoodPassword = value;
15061560
}
15071561

1562+
userGroupMembershipUrl = cfgMgr.getString(ONLINE_REVIEW_CFG_NS, USER_GROUP_MEMBERSHIP_URL);
1563+
v3jwtCookieName = cfgMgr.getString(ONLINE_REVIEW_CFG_NS, V3_JWT_COOKIE_NAME);
1564+
v2jwtCookieName = cfgMgr.getString(ONLINE_REVIEW_CFG_NS, V2_JWT_COOKIE_NAME);
1565+
ssoDomainForV3jwtCookie = cfgMgr.getString(ONLINE_REVIEW_CFG_NS, SSO_DOMAIN_FOR_V3_JWT_COOKIE);
1566+
v3jwtAuthorizationUrl = cfgMgr.getString(ONLINE_REVIEW_CFG_NS, V3_JWT_AUTHORIZATION_URL);
15081567
} catch (UnknownNamespaceException une) {
15091568
System.out.println(une.getMessage());
15101569
une.printStackTrace();
@@ -2332,5 +2391,47 @@ public static String getThurgoodUsername() {
23322391
public static String getThurgoodPassword() {
23332392
return thurgoodPassword;
23342393
}
2335-
2394+
2395+
/**
2396+
* Get user group membership url
2397+
*
2398+
* @return the userGroupMembershipUrl
2399+
*/
2400+
public static String getUserGroupMembershipUrl() {
2401+
return userGroupMembershipUrl;
2402+
}
2403+
2404+
/**
2405+
* Get v3jwt cookie name
2406+
*
2407+
* @return the v3jwtCookieName
2408+
*/
2409+
public static String getV3jwtCookieName() {
2410+
return v3jwtCookieName;
2411+
}
2412+
2413+
/**
2414+
* Get v2jwtCookieName.
2415+
* @return the v2jwtCookieName.
2416+
*/
2417+
public static String getV2jwtCookieName() {
2418+
return v2jwtCookieName;
2419+
}
2420+
2421+
/**
2422+
* Get v3jwtAuthorizationUrl.
2423+
* @return the v3jwtAuthorizationUrl.
2424+
*/
2425+
public static String getV3jwtAuthorizationUrl() {
2426+
return v3jwtAuthorizationUrl;
2427+
}
2428+
2429+
/**
2430+
* Get ssoDomainForV3jwtCookie.
2431+
* @return the ssoDomainForV3jwtCookie.
2432+
*/
2433+
public static String getSsoDomainForV3jwtCookie() {
2434+
return ssoDomainForV3jwtCookie;
2435+
}
2436+
23362437
}

0 commit comments

Comments
 (0)