Adding to project based security, and where to store data?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Adding to project based security, and where to store data?

Michael Carter
Two questions this morning.

Want to add my own options to the:

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/91a00107-68d1-4b25-abcd-df63810a2fa0o%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Adding to project based security, and where to store data?

Michael Carter
Managed to find my own answers.   So posting here for completeness for anyone searching.

Seems to add entries to the security area you just need these somewhere.

import hudson.security.Permission;
import hudson.security.PermissionGroup;
import hudson.security.PermissionScope;
import hudson.Extension;
import jenkins.model.Jenkins;
import org.jenkinsci.Symbol;

@Extension

@Symbol("myPermissions")
public class MyPermissions  {


   
public static final PermissionGroup PERMISSION_GROUP =
           
new PermissionGroup(MyPermissions.class,  
                               
Messages._PermissionGroup_Title());


   
public static final Permission MANUAL_SYNC_PERMISSION =
           
new Permission(PERMISSION_GROUP,
                           
"ManualSync",
                           
Messages._PermissionManualSync_Description(),
                           
Jenkins.ADMINISTER,
                           
PermissionScope.JENKINS);


   
public static final Permission UPLOAD_MAP_PERMISSION =
           
new Permission(PERMISSION_GROUP,
                           
"UploadMap",
                           
Messages._PermissionUploadMap_Description(),
                           
Jenkins.ADMINISTER,
                           
PermissionScope.JENKINS);


}


As for storing arbitrary data, this is doing my trick:


import org.jenkinsci.plugins.database.Database;
import org.jenkinsci.plugins.database.GlobalDatabaseConfiguration;
import org.jenkinsci.plugins.database.BasicDataSource2;
import javax.sql.DataSource;


import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.PreparedStatement;
import java.sql.Statement;
import java.sql.SQLException;


...


 
private GlobalDatabaseConfiguration globalDatabaseConfiguration;
 
private Database database;
 
private DataSource datasource;


...


     
this.globalDatabaseConfiguration = GlobalDatabaseConfiguration.get();
     
this.database   = this.globalDatabaseConfiguration.getDatabase();
     
this.datasource = this.database.getDataSource();
     
CreateTables();




On Saturday, July 25, 2020 at 11:18:49 AM UTC-4, Michael Carter wrote:
Two questions this morning.

Want to add my own options to the:

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/e9188523-0d1e-48ca-af98-cd476e026a5co%40googlegroups.com.