Compare commits
11 Commits
master
...
feature/us
| Author | SHA1 | Date |
|---|---|---|
|
|
912bb7b178 | 3 years ago |
|
|
404a744f07 | 3 years ago |
|
|
cf79616e92 | 3 years ago |
|
|
eab60906db | 3 years ago |
|
|
6f6f7b6122 | 3 years ago |
|
|
5df941e02b | 3 years ago |
|
|
512666f655 | 3 years ago |
|
|
43b4e1e515 | 3 years ago |
|
|
49ca333a0f | 3 years ago |
|
|
2d71ecd71d | 3 years ago |
|
|
cce091734b | 3 years ago |
6 changed files with 127 additions and 17 deletions
@ -0,0 +1,30 @@ |
|||||||
|
pipeline{ |
||||||
|
agent any |
||||||
|
|
||||||
|
tools{ |
||||||
|
maven '3.8.6' |
||||||
|
jdk 'JDK 18' |
||||||
|
} |
||||||
|
|
||||||
|
stages { |
||||||
|
stage ('Initialize') { |
||||||
|
steps { |
||||||
|
sh ''' |
||||||
|
echo "PATH = ${PATH}" |
||||||
|
echo "M2_HOME = ${M2_HOME}" |
||||||
|
''' |
||||||
|
} |
||||||
|
} |
||||||
|
stage('Build'){ |
||||||
|
steps{ |
||||||
|
sh 'mvn -Dmaven.test.failure.ignore=true install test' |
||||||
|
} |
||||||
|
post{ |
||||||
|
success{ |
||||||
|
junit 'target/surefire-reports/**/*.xml' |
||||||
|
archiveArtifacts artifacts: 'target/*.jar, *.pom', fingerprint: true, followSymlinks: false, onlyIfSuccessful: true |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,46 @@ |
|||||||
|
package org.leolo.nrapi.util; |
||||||
|
|
||||||
|
|
||||||
|
import org.leolo.nrapi.manager.DatabaseManager; |
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
|
||||||
|
import java.sql.Connection; |
||||||
|
import java.sql.PreparedStatement; |
||||||
|
import java.sql.ResultSet; |
||||||
|
import java.sql.SQLException; |
||||||
|
|
||||||
|
public class RoleUtil { |
||||||
|
|
||||||
|
private static Logger log = LoggerFactory.getLogger(RoleUtil.class); |
||||||
|
|
||||||
|
public static boolean hasPermission(long userId, String prem){ |
||||||
|
try( |
||||||
|
Connection conn = DatabaseManager.getInstance().getConnection(); |
||||||
|
PreparedStatement pstmt = conn.prepareStatement( |
||||||
|
"SELECT 1 FROM user_perm WHERE user_id = ? AND perm_name = ? " + |
||||||
|
"UNION ALL SELECT 1 FROM user_groups ug JOIN group_perm gp on ug.group_id = gp.group_id " + |
||||||
|
"WHERE ug.user_id = ? and gp.perm_name = ?" |
||||||
|
) |
||||||
|
){ |
||||||
|
pstmt.setLong(1, userId); |
||||||
|
pstmt.setString(2, prem); |
||||||
|
pstmt.setLong(3, userId); |
||||||
|
pstmt.setString(4, prem); |
||||||
|
try(ResultSet rs = pstmt.executeQuery()){ |
||||||
|
return rs.next(); |
||||||
|
} |
||||||
|
}catch (SQLException e){ |
||||||
|
log.error(e.getMessage(),e); |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
public static boolean hasPermission(String permission){ |
||||||
|
long userId = HttpReqRespUtils.getUserId(); |
||||||
|
if(userId!=-1){ |
||||||
|
return hasPermission(userId, permission); |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue