use of org.exist.security.Account in project exist by eXist-db.
the class Restore method setAdminCredentials.
private void setAdminCredentials(final DBBroker broker, final String adminPassword) throws EXistException, PermissionDeniedException {
final SecurityManager securityManager = broker.getBrokerPool().getSecurityManager();
final Account dba = securityManager.getAccount(SecurityManager.DBA_USER);
if (dba == null) {
throw new EXistException("'" + SecurityManager.DBA_USER + "' account can't be found.");
}
dba.setCredential(new Password(dba, adminPassword));
securityManager.updateAccount(dba);
}
use of org.exist.security.Account in project exist by eXist-db.
the class DocumentView method viewDocument.
public void viewDocument() {
try {
if (// $NON-NLS-1$
"XMLResource".equals(resource.getResourceType())) {
setText((String) resource.getContent());
} else {
setText(new String((byte[]) resource.getContent()));
}
// lock the resource for editing
final UserManagementService service = (UserManagementService) // $NON-NLS-1$ //$NON-NLS-2$
client.current.getService("UserManagementService", "1.0");
// $NON-NLS-1$
final Account user = service.getAccount(properties.getProperty("user"));
final String lockOwner = service.hasUserLock(resource);
if (lockOwner != null) {
if (JOptionPane.showConfirmDialog(this, // $NON-NLS-1$
Messages.getString("DocumentView.6") + lockOwner + // $NON-NLS-1$
Messages.getString("DocumentView.7"), // $NON-NLS-1$
Messages.getString("DocumentView.8"), JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) {
dispose();
this.setCursor(Cursor.getDefaultCursor());
return;
}
}
try {
service.lockResource(resource, user);
} catch (final XMLDBException ex) {
System.out.println(ex.getMessage());
JOptionPane.showMessageDialog(this, // $NON-NLS-1$
Messages.getString("DocumentView.9"));
setReadOnly();
}
setVisible(true);
} catch (final XMLDBException ex) {
// $NON-NLS-1$
showErrorMessage(Messages.getString("DocumentView.10") + ex.getMessage(), ex);
}
}
use of org.exist.security.Account in project exist by eXist-db.
the class ChownTask method execute.
/* (non-Javadoc)
* @see org.apache.tools.ant.Task#execute()
*/
public void execute() throws BuildException {
super.execute();
if ((name == null) || (group == null)) {
throw (new BuildException("Must specify user and group"));
}
try {
final Account usr = service.getAccount(name);
if (resource != null) {
final Resource res = base.getResource(resource);
service.chown(res, usr, group);
} else {
service.chown(usr, group);
}
} catch (final XMLDBException e) {
final String msg = "XMLDB exception caught: " + e.getMessage();
if (failonerror) {
throw (new BuildException(msg, e));
} else {
log(msg, e, Project.MSG_ERR);
}
}
}
use of org.exist.security.Account in project exist by eXist-db.
the class UserPasswordTask method execute.
@Override
public void execute() throws BuildException {
super.execute();
if (name == null) {
throw (new BuildException("Must specify at least a user name"));
}
try {
log("Looking up user " + name, Project.MSG_INFO);
final Account usr = service.getAccount(name);
if (usr != null) {
log("Setting password for user " + name, Project.MSG_INFO);
if (secret != null) {
usr.setCredential(new Password(usr, secret));
this.service.updateAccount(usr);
}
} else {
final String msg = "user " + name + " not found";
if (failonerror) {
throw (new BuildException(msg));
} else {
log(msg, Project.MSG_ERR);
}
}
} catch (final XMLDBException e) {
final String msg = "XMLDB exception caught: " + e.getMessage();
if (failonerror) {
throw (new BuildException(msg, e));
} else {
log(msg, e, Project.MSG_ERR);
}
}
}
use of org.exist.security.Account in project exist by eXist-db.
the class CreateCollectionsTest method setUp.
@Before
public void setUp() throws XMLDBException {
// create a test collection
final CollectionManagementService cms = (CollectionManagementService) existEmbeddedServer.getRoot().getService("CollectionManagementService", "1.0");
final Collection test = cms.createCollection(TEST_COLLECTION);
final UserManagementService ums = (UserManagementService) test.getService("UserManagementService", "1.0");
// change ownership to guest
Account guest = ums.getAccount(GUEST_DB_USER);
ums.chown(guest, guest.getPrimaryGroup());
ums.chmod("rwxrwxrwx");
}
Aggregations