Package org.exist.security

Examples of org.exist.security.Subject


    private void after(DBBroker broker, Txn transaction, DocumentImpl document, boolean remove) {
      if (documentPath == null || documentPath.startsWith(VERSIONS_COLLECTION))
        return;

      Subject activeSubject = broker.getSubject();

      try {
        broker.setSubject(broker.getBrokerPool().getSecurityManager().getSystemSubject());

        if (!remove) {
View Full Code Here


    @Test
    public void copyOf_calls_getMetadata() {

        BrokerPool mockBrokerPool = EasyMock.createMock(BrokerPool.class);
        Database mockDatabase = EasyMock.createMock(Database.class);
        Subject mockCurrentSubject = EasyMock.createMock(Subject.class);
        Group mockCurrentSubjectGroup= EasyMock.createMock(Group.class);
        SecurityManager mockSecurityManager = EasyMock.createMock(SecurityManager.class);
        PermissionFactory.sm = mockSecurityManager;

        //test values
        final DocumentMetadata otherMetadata = new DocumentMetadata();

        //expectations
        expect(mockSecurityManager.getDatabase()).andReturn(mockDatabase).times(2);
        expect(mockDatabase.getSubject()).andReturn(mockCurrentSubject).times(2);
        expect(mockCurrentSubject.getUserMask()).andReturn(Permission.DEFAULT_UMASK).times(2);
        expect(mockCurrentSubject.getId()).andReturn(RealmImpl.SYSTEM_ACCOUNT_ID).times(2);
        expect(mockCurrentSubject.getDefaultGroup()).andReturn(mockCurrentSubjectGroup).times(2);
        expect(mockCurrentSubjectGroup.getId()).andReturn(RealmImpl.DBA_GROUP_ID).times(2);

        replay(mockBrokerPool, mockDatabase, mockCurrentSubject, mockCurrentSubjectGroup, mockSecurityManager);

        //test setup
View Full Code Here

    @Test
    public void copyOf_calls_metadata_copyOf() {
        BrokerPool mockBrokerPool = EasyMock.createMock(BrokerPool.class);
        Database mockDatabase = EasyMock.createMock(Database.class);
        Subject mockCurrentSubject = EasyMock.createMock(Subject.class);
        Group mockCurrentSubjectGroup= EasyMock.createMock(Group.class);
        SecurityManager mockSecurityManager = EasyMock.createMock(SecurityManager.class);
        PermissionFactory.sm = mockSecurityManager;

        //test values
        final TestableDocumentMetadata docMetadata = new TestableDocumentMetadata();
        final DocumentMetadata otherMetadata = new DocumentMetadata();

        //expectations
        expect(mockSecurityManager.getDatabase()).andReturn(mockDatabase).times(2);
        expect(mockDatabase.getSubject()).andReturn(mockCurrentSubject).times(2);
        expect(mockCurrentSubject.getUserMask()).andReturn(Permission.DEFAULT_UMASK).times(2);
        expect(mockCurrentSubject.getId()).andReturn(RealmImpl.SYSTEM_ACCOUNT_ID).times(2);
        expect(mockCurrentSubject.getDefaultGroup()).andReturn(mockCurrentSubjectGroup).times(2);
        expect(mockCurrentSubjectGroup.getId()).andReturn(RealmImpl.DBA_GROUP_ID).times(2);

        replay(mockBrokerPool, mockDatabase, mockCurrentSubject, mockCurrentSubjectGroup, mockSecurityManager);

        //test setup
View Full Code Here

    @Test
    public void copyOf_updates_metadata_created_and_lastModified() {
        BrokerPool mockBrokerPool = EasyMock.createMock(BrokerPool.class);
        Database mockDatabase = EasyMock.createMock(Database.class);
        Subject mockCurrentSubject = EasyMock.createMock(Subject.class);
        Group mockCurrentSubjectGroup= EasyMock.createMock(Group.class);
        SecurityManager mockSecurityManager = EasyMock.createMock(SecurityManager.class);
        PermissionFactory.sm = mockSecurityManager;

        //test values
        final DocumentMetadata docMetadata = new TestableDocumentMetadata();
        final DocumentMetadata otherMetadata = new DocumentMetadata();
        final long otherCreated = System.currentTimeMillis() - 2000;
        final long otherLastModified = System.currentTimeMillis() - 1000;

        //expectations
        expect(mockSecurityManager.getDatabase()).andReturn(mockDatabase).times(2);
        expect(mockDatabase.getSubject()).andReturn(mockCurrentSubject).times(2);
        expect(mockCurrentSubject.getUserMask()).andReturn(Permission.DEFAULT_UMASK).times(2);
        expect(mockCurrentSubject.getId()).andReturn(RealmImpl.SYSTEM_ACCOUNT_ID).times(2);
        expect(mockCurrentSubject.getDefaultGroup()).andReturn(mockCurrentSubjectGroup).times(2);
        expect(mockCurrentSubjectGroup.getId()).andReturn(RealmImpl.DBA_GROUP_ID).times(2);

        replay(mockBrokerPool, mockDatabase, mockCurrentSubject, mockCurrentSubjectGroup, mockSecurityManager);

        //test setup
View Full Code Here

    }

    private boolean login(String user, String pass) throws XPathException {
        try {
            org.exist.security.SecurityManager sm = BrokerPool.getInstance().getSecurityManager();
            Subject subject = sm.authenticate(user, pass);
            if (subject == null)
                return false;
            context.getBroker().setSubject(subject);
            return true;
        } catch (AuthenticationException e) {
View Full Code Here

       
        manager.getScheduler().createCronJob(cronExpression, jobDescription, null, true);
    }

    private Subject getSubject() {
        final Subject subject;
        final SecurityManager sm = manager.getDatabase().getSecurityManager();
        if(account == null || account.isEmpty()) {
            subject = manager.getDatabase().getSecurityManager().getGuestSubject();
        } else {
            final AbstractAccount acc = (AbstractAccount) sm.getAccount(account);
View Full Code Here

  /**
   * Test method for {@link org.exist.security.realm.activedirectory.ActiveDirectoryRealm#authenticate(java.lang.String, java.lang.Object)}.
   */
  @Test
  public void testAuthenticate() {
    Subject currentUser = null;
    try {
      currentUser = realm.authenticate("accounter@bulungur", "password");
    } catch (AuthenticationException e) {
      e.printStackTrace();
      fail(e.getMessage());
View Full Code Here

    @Override
    public void run() {
          try {
            BrokerPool db = BrokerPool.getInstance();
       
            Subject subject = db.getSecurityManager().getSystemSubject();
        try {
          db.enterServiceMode(subject);
              System.out.println("enter servise mode "+Thread.currentThread());
         
          //do something
View Full Code Here

    @Override
    public void run() {
          try {
            BrokerPool db = BrokerPool.getInstance();
       
            Subject subject = db.getSecurityManager().getSystemSubject();
           
            DBBroker broker = null;
        try {
          broker = db.get(subject);
              System.out.println("get broker "+Thread.currentThread());
View Full Code Here

        BrokerPool pool = BrokerPool.getInstance();
        DBBroker broker = null;
        TransactionManager transact = null;
        Txn txn = null;
        try {
            Subject admin = pool.getSecurityManager().authenticate(ADMIN_UID, ADMIN_PWD);

            broker = pool.get(admin);

            transact = pool.getTransactionManager();
            txn = transact.beginTransaction();
View Full Code Here

TOP

Related Classes of org.exist.security.Subject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.