/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.
 */
package org.apache.jackrabbit.core.security.principal;

import javax.jcr.RepositoryException;
import javax.jcr.Session;
import java.security.Principal;
import java.security.acl.Group;
import java.util.Properties;

import org.apache.jackrabbit.api.security.principal.JackrabbitPrincipal;
import org.apache.jackrabbit.api.security.principal.PrincipalIterator;
import org.apache.jackrabbit.test.AbstractJCRTest;
import org.apache.jackrabbit.test.NotExecutableException;
import sun.security.acl.GroupImpl;


/**
 * <code>PrincipalManagerTest</code>...
 */
public class PrincipalManagerTest extends AbstractJCRTest {

    private static final String TESTGROUP_NAME = "org.apache.jackrabbit.core.security.principal.PrincipalManagerTest.testgroup";
    private static final Group TESTGROUP = new GroupImpl(TESTGROUP_NAME);

    private static class CustomPrincipalProvider extends AbstractPrincipalProvider {

        @Override
        protected Principal providePrincipal(String principalName) {
            return TESTGROUP_NAME.equals(principalName) ? TESTGROUP : null;
        }

        @Override
        public PrincipalIterator findPrincipals(String simpleFilter) {
            throw new UnsupportedOperationException();
        }

        @Override
        public PrincipalIterator findPrincipals(String simpleFilter, int searchType) {
            throw new UnsupportedOperationException();
        }

        @Override
        public PrincipalIterator getPrincipals(int searchType) {
            throw new UnsupportedOperationException();
        }

        @Override
        public PrincipalIterator getGroupMembership(Principal principal) {
            throw new UnsupportedOperationException();
        }

        @Override
        public boolean canReadPrincipal(Session session, Principal principalToRead) {
            return true;
        }
    }

    /**
     * Test if a group which is not item based will be wrapped by a JackrabbitPrincipal implementation.
     * @throws NotExecutableException
     * @throws RepositoryException
     */
    public void testJackrabbitPrincipal() throws NotExecutableException, RepositoryException {

        final PrincipalProvider testProvider = new CustomPrincipalProvider();
        testProvider.init(new Properties());
        PrincipalManagerImpl principalManager = new PrincipalManagerImpl(superuser, new PrincipalProvider[] { testProvider });
        Principal principalFromManager = principalManager.getPrincipal(TESTGROUP_NAME);
        assertTrue(principalFromManager instanceof JackrabbitPrincipal);
    }
}
@@ -1699,34 +1699,16 @@
 ider %7B%0A%0A
-        @Override%0A
         
@@ -1764,24 +1764,24 @@
 ipalName) %7B%0A
+
             
@@ -1855,34 +1855,16 @@
      %7D%0A%0A
-        @Override%0A
         
@@ -1992,34 +1992,16 @@
      %7D%0A%0A
-        @Override%0A
         
@@ -2145,34 +2145,16 @@
      %7D%0A%0A
-        @Override%0A
         
@@ -2276,34 +2276,16 @@
      %7D%0A%0A
-        @Override%0A
         
@@ -2421,26 +2421,8 @@
  %7D%0A%0A
-        @Override%0A
     

remove @override annotations for JDK 1.5 compat