summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/odlux/apps/helpApp/pom.xml
blob: 37a06341b44fa851634aaefa4544e53bb2c4beca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ ============LICENSE_START=======================================================
  ~ ONAP : ccsdk features
  ~ ================================================================================
  ~ Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
  ~ ================================================================================
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~     http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  ~ ============LICENSE_END=======================================================
  ~
  -->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.onap.ccsdk.parent</groupId>
        <artifactId>odlparent</artifactId>
        <version>1.5.2</version>
        <relativePath/>
    </parent>

    <groupId>org.onap.ccsdk.features.sdnr.wt</groupId>
    <artifactId>sdnr-wt-odlux-app-helpApp</artifactId>
    <version>0.7.2-SNAPSHOT</version>
    <packaging>bundle</packaging>

    <name>ccsdk-features :: ${project.artifactId}</name>
    <licenses>
        <license>
            <name>Apache License, Version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0</url>
        </license>
    </licenses>

    <dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>sdnr-wt-odlux-core-model</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>sdnr-wt-odlux-core-provider</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <sourceDirectory>src2/main/java</sourceDirectory>
        <resources>
            <resource>
                <directory>dist</directory>
                <targetPath>odlux</targetPath>
            </resource>
            <resource>
                <directory>src2/main/resources</directory>
            </resource>
            <resource>
                <directory>src2/test/resources</directory>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>dist</directory>
                            <followSymlinks>false</followSymlinks>
                        </fileset>
                        <fileset>
                            <directory>node</directory>
                            <followSymlinks>false</followSymlinks>
                        </fileset>
                        <fileset>
                            <directory>node_modules</directory>
                            <followSymlinks>false</followSymlinks>
                        </fileset>
                        <fileset>
                            <directory>../node_modules</directory>
                            <followSymlinks>false</followSymlinks>
                        </fileset>
                        <!-- eclipse bug build bin folder in basedir -->
                        <fileset>
                            <directory>bin</directory>
                            <followSymlinks>false</followSymlinks>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>add-test-source</id>
                        <phase>generate-test-sources</phase>
                        <goals>
                            <goal>add-test-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>src2/test/java</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>de.jacks-it-lab</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <version>1.7.2</version>
                <executions>
                    <execution>
                        <id>install node and yarn</id>
                        <goals>
                            <goal>install-node-and-yarn</goal>
                        </goals>
                        <!-- optional: default phase is "generate-resources" -->
                        <phase>initialize</phase>
                        <configuration>
                            <nodeVersion>v10.16.3</nodeVersion>
                            <yarnVersion>v1.19.0</yarnVersion>
                        </configuration>
                    </execution>
                    <execution>
                        <id>yarn build</id>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <configuration>
                            <arguments>run build</arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Import-Package>org.onap.ccsdk.features.sdnr.wt.odlux.model.*,com.opensymphony.*</Import-Package>
                        <Private-Package/>
                    </instructions>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
w Hashtable(); private Hashtable reportUsers = new Hashtable(); public ReportSecurity(String reportID) { this(reportID, null, null, null, null, null, false); } // ReportSecurity public ReportSecurity(String reportID, String ownerID, String createID, String createDate, String updateID, String updateDate, boolean isPublic) { super(); if (ownerID == null) // Need to load the report record from the database if (!reportID.equals("-1")) try { /*DataSet ds = DbUtils .executeQuery("SELECT NVL(cr.owner_id, cr.create_id) owner_id, cr.create_id, TO_CHAR(cr.create_date, '" + Globals.getOracleTimeFormat() + "') create_date, maint_id, TO_CHAR(cr.maint_date, '" + Globals.getOracleTimeFormat() + "') update_date, cr.public_yn FROM cr_report cr WHERE cr.rep_id=" + reportID);*/ String sql = Globals.getReportSecurity(); sql = sql.replace("[rw.getReportID()]", reportID); DataSet ds = DbUtils.executeQuery(sql); ownerID = ds.getString(0, 0); createID = ds.getString(0, 1); createDate = ds.getString(0, 2); updateID = ds.getString(0, 3); updateDate = ds.getString(0, 4); isPublic = nvl(ds.getString(0, 5)).equals("Y"); } catch (Exception e) { String eMsg = "ReportSecurity.ReportSecurity: Unable to load report record details. Exception: " + e.getMessage(); //Log.write(eMsg); logger.debug(EELFLoggerDelegate.debugLogger, ("[EXCEPTION ENCOUNTERED IN RAPTOR] "+eMsg)); throw new RuntimeException(eMsg); } this.reportID = reportID; this.ownerID = ownerID; this.createID = createID; this.createDate = createDate; this.updateID = updateID; this.updateDate = updateDate; this.isPublic = isPublic; /* * reportUsers.put(ownerID, "N"); // Owner has full access * reportRoles.put(AppUtils.getSuperRoleID(), "N"); // Super role has * full access for(Iterator iter=AppUtils.getAdminRoleIDs().iterator(); * iter.hasNext(); ) reportRoles.put((String) iter.next(), "Y"); // * Admin role(s) have read-only access */ try { String reportUserAccessSql= Globals.getReportUserAccess(); reportUserAccessSql = reportUserAccessSql.replace("[reportID]", reportID); DataSet ds = DbUtils .executeQuery(reportUserAccessSql); for (int i = 0; i < ds.getRowCount(); i++) { String roleID = nvl(ds.getString(i, 0)); if (roleID.length() > 0) reportRoles.put(roleID, ds.getString(i, 2)); String userID = nvl(ds.getString(i, 1)); if (userID.length() > 0) reportUsers.put(userID, ds.getString(i, 2)); } // for } catch (Exception e) { String eMsg = "ReportSecurity.ReportSecurity: Unable to load access priviledges - error " + e.getMessage(); logger.error(EELFLoggerDelegate.debugLogger, ("[EXCEPTION ENCOUNTERED IN RAPTOR] " + eMsg)); throw new RuntimeException(eMsg); } } // ReportSecurity public String getOwnerID() { return ownerID; } public String getCreateID() { return createID; } public String getCreateDate() { return createDate; } public String getUpdateID() { return updateID; } public String getUpdateDate() { return updateDate; } public void setOwnerID(String ownerID) { this.ownerID = ownerID; } public void setPublic(boolean isPublic) { this.isPublic = isPublic; } public void reportCreate(String reportID, String userID, boolean isPublic) { this.reportID = reportID; this.ownerID = userID; this.createID = userID; this.createDate = Utils.getCurrentDateTime(); this.updateID = userID; this.updateDate = this.createDate; this.isPublic = isPublic; } // reportCreate public void reportUpdate(HttpServletRequest request) throws RaptorException { checkUserWriteAccess(request); String userID = AppUtils.getUserID(request); this.updateID = userID; this.updateDate = Utils.getCurrentDateTime(); } // reportUpdate /** ************************************************************* */ public Vector getReportUsers(HttpServletRequest request) throws RaptorException { HttpSession session = request.getSession(); String query = Globals.getCustomizedScheduleQueryForUsers(); String[] sessionParameters = Globals.getSessionParams().split(","); session.setAttribute("login_id", AppUtils.getUserBackdoorLoginId(request)); String param = ""; for (int i = 0; i < sessionParameters.length; i++) { param = (String)session.getAttribute(sessionParameters[0]); query = Utils.replaceInString(query, "[" + sessionParameters[i].toUpperCase()+"]", (String)session.getAttribute(sessionParameters[i]) ); } boolean isAdmin = AppUtils.isAdminUser(request); Vector allUsers = AppUtils.getAllUsers(query,param, isAdmin); Vector rUsers = new Vector(allUsers.size()); for (Iterator iter = allUsers.iterator(); iter.hasNext();) { IdNameValue user = (IdNameValue) iter.next(); String readOnlyAccess = (String) reportUsers.get(user.getId()); if (readOnlyAccess != null) rUsers.add(new SecurityEntry(user.getId(), user.getName(), readOnlyAccess .equals("Y"))); } // for return rUsers; } // getReportUsers public Vector getReportRoles(HttpServletRequest request) throws RaptorException { HttpSession session = request.getSession(); String query = Globals.getCustomizedScheduleQueryForRoles(); String[] sessionParameters = Globals.getSessionParams().split(","); String param = ""; for (int i = 0; i < sessionParameters.length; i++) { param = (String)session.getAttribute(sessionParameters[0]); query = Utils.replaceInString(query, "[" + sessionParameters[i].toUpperCase()+"]", (String)session.getAttribute(sessionParameters[i]) ); } boolean isAdmin = AppUtils.isAdminUser(request); Vector allRoles = AppUtils.getAllRoles(query, param, isAdmin); Vector rRoles = new Vector(allRoles.size()); for (Iterator iter = allRoles.iterator(); iter.hasNext();) { IdNameValue role = (IdNameValue) iter.next(); String readOnlyAccess = (String) reportRoles.get(role.getId()); if (readOnlyAccess != null) rRoles.add(new SecurityEntry(role.getId(), role.getName(), readOnlyAccess .equals("Y"))); } // for return rRoles; } // getReportRoles /** ************************************************************* */ private void validateReadOnlyAccess(String readOnlyAccess) throws Exception { if (!(readOnlyAccess != null && (readOnlyAccess.equals("Y") || readOnlyAccess .equals("N")))) throw new RuntimeException( "[ReportSecurity.validateReadOnlyAccess] Invalid parameter value"); } // validateReadOnlyAccess public void addUserAccess(String userID, String readOnlyAccess) throws Exception { validateReadOnlyAccess(readOnlyAccess); reportUsers.put(userID, readOnlyAccess); String addUserAccessSql= Globals.getAddUserAccess(); addUserAccessSql = addUserAccessSql.replace("[reportID]", reportID); addUserAccessSql = addUserAccessSql.replace("[userID]", userID); addUserAccessSql = addUserAccessSql.replace("[readOnlyAccess]", readOnlyAccess); DbUtils .executeUpdate(addUserAccessSql); } // addUserAccess public void updateUserAccess(String userID, String readOnlyAccess) throws Exception { validateReadOnlyAccess(readOnlyAccess); reportUsers.remove(userID); reportUsers.put(userID, readOnlyAccess); String updateUserAccessSql= Globals.getUpdateUserAccess(); updateUserAccessSql = updateUserAccessSql.replace("[reportID]", reportID); updateUserAccessSql = updateUserAccessSql.replace("[userID]", userID); updateUserAccessSql = updateUserAccessSql.replace("[readOnlyAccess]", readOnlyAccess); DbUtils.executeUpdate(updateUserAccessSql); } // updateUserAccess public void removeUserAccess(String userID) throws Exception { reportUsers.remove(userID); String removeUserAccessSql= Globals.getRemoveUserAccess(); removeUserAccessSql = removeUserAccessSql.replace("[reportID]", reportID); removeUserAccessSql = removeUserAccessSql.replace("[userID]", userID); DbUtils.executeUpdate(removeUserAccessSql); } // removeUserAccess public void addRoleAccess(String roleID, String readOnlyAccess) throws Exception { validateReadOnlyAccess(readOnlyAccess); reportRoles.put(roleID, readOnlyAccess); String addRoleAccessSql= Globals.getAddRoleAccess(); addRoleAccessSql = addRoleAccessSql.replace("[reportID]", reportID); addRoleAccessSql = addRoleAccessSql.replace("[roleID]", roleID); addRoleAccessSql = addRoleAccessSql.replace("[readOnlyAccess]", readOnlyAccess); DbUtils .executeUpdate(addRoleAccessSql); } // addRoleAccess public void updateRoleAccess(String roleID, String readOnlyAccess) throws Exception { validateReadOnlyAccess(readOnlyAccess); reportRoles.remove(roleID); reportRoles.put(roleID, readOnlyAccess); String updateRoleAccessSql= Globals.getUpdateRoleAccess(); updateRoleAccessSql = updateRoleAccessSql.replace("[reportID]", reportID); updateRoleAccessSql = updateRoleAccessSql.replace("[roleID]", roleID); updateRoleAccessSql = updateRoleAccessSql.replace("[readOnlyAccess]", readOnlyAccess); DbUtils.executeUpdate(updateRoleAccessSql); } // updateRoleAccess public void removeRoleAccess(String roleID) throws Exception { reportRoles.remove(roleID); String removeRoleAccessSql= Globals.getRemoveRoleAccess(); removeRoleAccessSql = removeRoleAccessSql.replace("[reportID]", reportID); removeRoleAccessSql = removeRoleAccessSql.replace("[roleID]", roleID); DbUtils.executeUpdate(removeRoleAccessSql); } // removeRoleAccess /** ************************************************************* */ public void checkUserReadAccess(HttpServletRequest request, String userID) throws RaptorException { if(userID == null) userID = AppUtils.getUserID(request); if(userID != null) { //userID = AppUtils.getUserID(request); if (nvl(reportID).equals("-1")) return; if (true) //todo: replace with proper check isPublic return; if (userID.equals(ownerID)) return; if (reportUsers.get(userID) != null) return; } Vector userRoles = null; String userName = null; if(userID == null) { userRoles = AppUtils.getUserRoles(request); userName = AppUtils.getUserName(request); userID = AppUtils.getUserID(request); } else { userRoles = AppUtils.getUserRoles(userID); userName = AppUtils.getUserName(userID); } if (nvl(reportID).equals("-1")) return; if (isPublic) return; if (userID.equals(ownerID)) return; if (reportUsers.get(userID) != null) return; for (Iterator iter = userRoles.iterator(); iter.hasNext();) { String userRole = (String) iter.next(); if (nvl(userRole).equals(AppUtils.getSuperRoleID())) return; } for (Iterator iter = userRoles.iterator(); iter.hasNext();) { String userRole = (String) iter.next(); if (nvl(userRole).equals(AppUtils.getSuperRoleID())) return; if (reportRoles.get(userRole) != null) return; for (Iterator iterA = AppUtils.getAdminRoleIDs().iterator(); iterA.hasNext();) if (nvl(userRole).equals((String) iterA.next())) return; } // for throw new UserAccessException(reportID, "[" + userID + "] " + userName, AppConstants.UA_READ); } // checkUserReadAccess public void checkUserWriteAccess(HttpServletRequest request) throws RaptorException { String userID = AppUtils.getUserID(request); if (nvl(reportID).equals("-1")) return; if (userID.equals(ownerID)) return; if (nvl((String) reportUsers.get(userID)).equals("N")) return; for (Iterator iter = AppUtils.getUserRoles(request).iterator(); iter.hasNext();) { String userRole = (String) iter.next(); if (nvl(userRole).equals(AppUtils.getSuperRoleID())) return; if (nvl((String) reportRoles.get(userRole)).equals("N")) return; for (Iterator iterA = AppUtils.getAdminRoleIDs().iterator(); iterA.hasNext();) if (nvl(userRole).equals((String) iterA.next())) return; } // for throw new UserAccessException(reportID, "[" + userID + "] " + AppUtils.getUserName(request), AppConstants.UA_WRITE); } // checkUserWriteAccess public void checkUserDeleteAccess(HttpServletRequest request) throws RaptorException { String userID = AppUtils.getUserID(request); if (Globals.getDeleteOnlyByOwner()) { if (!userID.equals(ownerID)) throw new UserAccessException(reportID, "[" + userID + "] " + AppUtils.getUserName(request), AppConstants.UA_DELETE); } else checkUserWriteAccess(request); } // checkUserDeleteAccess } // ReportSecurity