summaryrefslogtreecommitdiffstats
path: root/support/src/test/java
diff options
context:
space:
mode:
authorDan Bornstein <danfuzz@android.com>2011-01-13 11:34:36 -0800
committerDan Bornstein <danfuzz@android.com>2011-01-13 14:29:49 -0800
commit8a9624fcddded08aa352e56369c190d35f234e0a (patch)
treee2ddd6b2fbef81aef74910e632e8e91f54e5c0a0 /support/src/test/java
parent094ef67758c76f2331378a3805b1e6db8ada17fe (diff)
downloadlibcore-8a9624fcddded08aa352e56369c190d35f234e0a.zip
libcore-8a9624fcddded08aa352e56369c190d35f234e0a.tar.gz
libcore-8a9624fcddded08aa352e56369c190d35f234e0a.tar.bz2
Remove pointless tests. DO NOT MERGE.
Change-Id: Ia1bac1abaa44c6341b00005a3142e87073b16bd6
Diffstat (limited to 'support/src/test/java')
-rw-r--r--support/src/test/java/org/apache/harmony/security/tests/support/acl/AclEntryImpl.java118
-rw-r--r--support/src/test/java/org/apache/harmony/security/tests/support/acl/AclEnumerator.java51
-rw-r--r--support/src/test/java/org/apache/harmony/security/tests/support/acl/AclImpl.java211
-rw-r--r--support/src/test/java/org/apache/harmony/security/tests/support/acl/GroupImpl.java112
-rw-r--r--support/src/test/java/org/apache/harmony/security/tests/support/acl/OwnerImpl.java69
-rw-r--r--support/src/test/java/org/apache/harmony/security/tests/support/acl/PermissionImpl.java49
-rw-r--r--support/src/test/java/org/apache/harmony/security/tests/support/acl/PrincipalImpl.java53
7 files changed, 0 insertions, 663 deletions
diff --git a/support/src/test/java/org/apache/harmony/security/tests/support/acl/AclEntryImpl.java b/support/src/test/java/org/apache/harmony/security/tests/support/acl/AclEntryImpl.java
deleted file mode 100644
index 3d922df..0000000
--- a/support/src/test/java/org/apache/harmony/security/tests/support/acl/AclEntryImpl.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * 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.harmony.security.tests.support.acl;
-
-import java.security.Principal;
-import java.security.acl.*;
-import java.util.Enumeration;
-import java.util.Vector;
-
-/**
- * Additional class for verification AclEntry interface
- */
-public class AclEntryImpl implements AclEntry {
-
- private Principal user;
- private Vector permissionSet;
- private boolean negative;
-
- public AclEntryImpl(Principal principal) {
- user = null;
- permissionSet = new Vector(10, 10);
- negative = false;
- user = principal;
- }
-
- public AclEntryImpl() {
- user = null;
- permissionSet = new Vector(10, 10);
- negative = false;
- }
-
- public boolean setPrincipal(Principal principal) {
- if(user != null) {
- return false;
- } else {
- user = principal;
- return true;
- }
- }
-
- public void setNegativePermissions() {
- negative = true;
- }
-
- public boolean isNegative() {
- return negative;
- }
-
- public boolean addPermission(Permission permission) {
- if(permissionSet.contains(permission)) {
- return false;
- } else {
- permissionSet.addElement(permission);
- return true;
- }
- }
-
- public boolean removePermission(Permission permission) {
- return permissionSet.removeElement(permission);
- }
-
- public boolean checkPermission(Permission permission) {
- return permissionSet.contains(permission);
- }
-
- public Enumeration permissions() {
- return permissionSet.elements();
- }
-
- public String toString() {
- StringBuffer stringbuffer = new StringBuffer();
- if(negative)
- stringbuffer.append("-");
- else
- stringbuffer.append("+");
- if(user instanceof Group)
- stringbuffer.append("Group.");
- else
- stringbuffer.append("User.");
- stringbuffer.append((new StringBuilder()).append(user).append("=").toString());
- Enumeration enumeration = permissions();
- do {
- if(!enumeration.hasMoreElements())
- break;
- Permission permission = (Permission)enumeration.nextElement();
- stringbuffer.append(permission);
- if(enumeration.hasMoreElements())
- stringbuffer.append(",");
- } while(true);
- return new String(stringbuffer);
- }
-
- public synchronized Object clone() {
- AclEntryImpl aclentryimpl = new AclEntryImpl(user);
- aclentryimpl.permissionSet = (Vector)permissionSet.clone();
- aclentryimpl.negative = negative;
- return aclentryimpl;
- }
-
- public Principal getPrincipal() {
- return user;
- }
-} \ No newline at end of file
diff --git a/support/src/test/java/org/apache/harmony/security/tests/support/acl/AclEnumerator.java b/support/src/test/java/org/apache/harmony/security/tests/support/acl/AclEnumerator.java
deleted file mode 100644
index df093cd..0000000
--- a/support/src/test/java/org/apache/harmony/security/tests/support/acl/AclEnumerator.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.harmony.security.tests.support.acl;
-
-import java.security.acl.Acl;
-import java.util.*;
-
-final class AclEnumerator implements Enumeration {
-
- Acl acl;
- Enumeration u1;
- Enumeration u2;
- Enumeration g1;
- Enumeration g2;
-
- AclEnumerator(Acl acl1, Hashtable hashtable, Hashtable hashtable1, Hashtable hashtable2, Hashtable hashtable3) {
- acl = acl1;
- u1 = hashtable.elements();
- u2 = hashtable2.elements();
- g1 = hashtable1.elements();
- g2 = hashtable3.elements();
- }
-
- public boolean hasMoreElements() {
- return u1.hasMoreElements() || u2.hasMoreElements() || g1.hasMoreElements() || g2.hasMoreElements();
- }
-
- public Object nextElement() {
- Acl acl1 = acl;
- if(u2.hasMoreElements()) return u2.nextElement();
- if(g1.hasMoreElements()) return g1.nextElement();
- if(u1.hasMoreElements()) return u1.nextElement();
- if(g2.hasMoreElements()) return g2.nextElement();
- return acl1;
- }
-} \ No newline at end of file
diff --git a/support/src/test/java/org/apache/harmony/security/tests/support/acl/AclImpl.java b/support/src/test/java/org/apache/harmony/security/tests/support/acl/AclImpl.java
deleted file mode 100644
index 17c20f9..0000000
--- a/support/src/test/java/org/apache/harmony/security/tests/support/acl/AclImpl.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * 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.harmony.security.tests.support.acl;
-
-import java.security.Principal;
-import java.security.acl.*;
-import java.util.*;
-
-/**
- * Additional class for verification Acl interface
- */
-public class AclImpl extends OwnerImpl implements Acl {
-
- private Hashtable allowedUsersTable;
- private Hashtable allowedGroupsTable;
- private Hashtable deniedUsersTable;
- private Hashtable deniedGroupsTable;
- private String aclName;
- private Vector zeroSet;
-
- public AclImpl(Principal principal, String s) {
- super(principal);
- allowedUsersTable = new Hashtable(23);
- allowedGroupsTable = new Hashtable(23);
- deniedUsersTable = new Hashtable(23);
- deniedGroupsTable = new Hashtable(23);
- aclName = null;
- zeroSet = new Vector(1, 1);
- try {
- setName(principal, s);
- } catch(Exception exception) { }
- }
-
- public void setName(Principal principal, String s)
- throws NotOwnerException {
- if(!isOwner(principal)) {
- throw new NotOwnerException();
- } else {
- aclName = s;
- return;
- }
- }
-
- public String getName() {
- return aclName;
- }
-
- public synchronized boolean addEntry(Principal principal, AclEntry aclentry)
- throws NotOwnerException {
- if(!isOwner(principal)) throw new NotOwnerException();
- Hashtable hashtable = findTable(aclentry);
- Principal principal1 = aclentry.getPrincipal();
- if(hashtable.get(principal1) != null) {
- return false;
- } else {
- hashtable.put(principal1, aclentry);
- return true;
- }
- }
-
- public synchronized boolean removeEntry(Principal principal, AclEntry aclentry)
- throws NotOwnerException {
- if(!isOwner(principal)) {
- throw new NotOwnerException();
- } else {
- Hashtable hashtable = findTable(aclentry);
- Principal principal1 = aclentry.getPrincipal();
- Object obj = hashtable.remove(principal1);
- return obj != null;
- }
- }
-
- public synchronized Enumeration getPermissions(Principal principal) {
- Enumeration enumeration2 = subtract(getGroupPositive(principal), getGroupNegative(principal));
- Enumeration enumeration3 = subtract(getGroupNegative(principal), getGroupPositive(principal));
- Enumeration enumeration = subtract(getIndividualPositive(principal), getIndividualNegative(principal));
- Enumeration enumeration1 = subtract(getIndividualNegative(principal), getIndividualPositive(principal));
- Enumeration enumeration4 = subtract(enumeration2, enumeration1);
- Enumeration enumeration5 = union(enumeration, enumeration4);
- enumeration = subtract(getIndividualPositive(principal), getIndividualNegative(principal));
- enumeration1 = subtract(getIndividualNegative(principal), getIndividualPositive(principal));
- enumeration4 = subtract(enumeration3, enumeration);
- Enumeration enumeration6 = union(enumeration1, enumeration4);
- return subtract(enumeration5, enumeration6);
- }
-
- public boolean checkPermission(Principal principal, Permission permission) {
- for(Enumeration enumeration = getPermissions(principal); enumeration.hasMoreElements();) {
- Permission permission1 = (Permission)enumeration.nextElement();
- if(permission1.equals(permission))
- return true;
- }
- return false;
- }
-
- public synchronized Enumeration entries() {
- return new AclEnumerator(this, allowedUsersTable, allowedGroupsTable, deniedUsersTable, deniedGroupsTable);
- }
-
- public String toString() {
- StringBuffer stringbuffer = new StringBuffer();
- for(Enumeration enumeration = entries(); enumeration.hasMoreElements(); stringbuffer.append("\n")) {
- AclEntry aclentry = (AclEntry)enumeration.nextElement();
- stringbuffer.append(aclentry.toString().trim());
- }
- return stringbuffer.toString();
- }
-
- private Hashtable findTable(AclEntry aclentry) {
- Hashtable hashtable = null;
- Principal principal = aclentry.getPrincipal();
- if(principal instanceof Group) {
- if(aclentry.isNegative())
- hashtable = deniedGroupsTable;
- else
- hashtable = allowedGroupsTable;
- } else
- if(aclentry.isNegative())
- hashtable = deniedUsersTable;
- else
- hashtable = allowedUsersTable;
- return hashtable;
- }
-
- private static Enumeration union(Enumeration enumeration, Enumeration enumeration1) {
- Vector vector = new Vector(20, 20);
- for(; enumeration.hasMoreElements(); vector.addElement(enumeration.nextElement()));
- do {
- if(!enumeration1.hasMoreElements())
- break;
- Object obj = enumeration1.nextElement();
- if(!vector.contains(obj))
- vector.addElement(obj);
- } while(true);
- return vector.elements();
- }
-
- private Enumeration subtract(Enumeration enumeration, Enumeration enumeration1) {
- Vector vector = new Vector(20, 20);
- for(; enumeration.hasMoreElements(); vector.addElement(enumeration.nextElement()));
- do {
- if(!enumeration1.hasMoreElements())
- break;
- Object obj = enumeration1.nextElement();
- if(vector.contains(obj))
- vector.removeElement(obj);
- } while(true);
- return vector.elements();
- }
-
- private Enumeration getGroupPositive(Principal principal) {
- Enumeration enumeration = zeroSet.elements();
- Enumeration enumeration1 = allowedGroupsTable.keys();
- do {
- if(!enumeration1.hasMoreElements())
- break;
- Group group = (Group)enumeration1.nextElement();
- if(group.isMember(principal)) {
- AclEntry aclentry = (AclEntry)allowedGroupsTable.get(group);
- enumeration = union(aclentry.permissions(), enumeration);
- }
- } while(true);
- return enumeration;
- }
-
- private Enumeration getGroupNegative(Principal principal) {
- Enumeration enumeration = zeroSet.elements();
- Enumeration enumeration1 = deniedGroupsTable.keys();
- do {
- if(!enumeration1.hasMoreElements())
- break;
- Group group = (Group)enumeration1.nextElement();
- if(group.isMember(principal)) {
- AclEntry aclentry = (AclEntry)deniedGroupsTable.get(group);
- enumeration = union(aclentry.permissions(), enumeration);
- }
- } while(true);
- return enumeration;
- }
-
- private Enumeration getIndividualPositive(Principal principal) {
- Enumeration enumeration = zeroSet.elements();
- AclEntry aclentry = (AclEntry)allowedUsersTable.get(principal);
- if(aclentry != null)
- enumeration = aclentry.permissions();
- return enumeration;
- }
-
- private Enumeration getIndividualNegative(Principal principal) {
- Enumeration enumeration = zeroSet.elements();
- AclEntry aclentry = (AclEntry)deniedUsersTable.get(principal);
- if(aclentry != null)
- enumeration = aclentry.permissions();
- return enumeration;
- }
-} \ No newline at end of file
diff --git a/support/src/test/java/org/apache/harmony/security/tests/support/acl/GroupImpl.java b/support/src/test/java/org/apache/harmony/security/tests/support/acl/GroupImpl.java
deleted file mode 100644
index fe910fb..0000000
--- a/support/src/test/java/org/apache/harmony/security/tests/support/acl/GroupImpl.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * 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.harmony.security.tests.support.acl;
-
-import java.security.Principal;
-import java.security.acl.Group;
-import java.util.Enumeration;
-import java.util.Vector;
-
-/**
- * Additional class for verification Group interface
- */
-public class GroupImpl implements Group {
-
- private Vector groupMembers;
- private String group;
-
- public GroupImpl(String s) {
- groupMembers = new Vector(50, 100);
- group = s;
- }
-
- public boolean addMember(Principal principal) {
- if(groupMembers.contains(principal))
- return false;
- if(group.equals(principal.toString())) {
- throw new IllegalArgumentException();
- } else {
- groupMembers.addElement(principal);
- return true;
- }
- }
-
- public boolean removeMember(Principal principal) {
- return groupMembers.removeElement(principal);
- }
-
- public Enumeration members() {
- return groupMembers.elements();
- }
-
- public boolean equals(Object obj) {
- if(this == obj)
- return true;
- if(!(obj instanceof Group)) {
- return false;
- } else {
- Group group1 = (Group)obj;
- return group.equals(group1.toString());
- }
- }
-
- public boolean equals(Group group1) {
- return equals(group1);
- }
-
- public String toString() {
- return group;
- }
-
- public int hashCode() {
- return group.hashCode();
- }
-
- public boolean isMember(Principal principal) {
- if(groupMembers.contains(principal)) {
- return true;
- } else {
- Vector vector = new Vector(10);
- return isMemberRecurse(principal, vector);
- }
- }
-
- public String getName() {
- return group;
- }
-
- boolean isMemberRecurse(Principal principal, Vector vector) {
- for(Enumeration enumeration = members(); enumeration.hasMoreElements();) {
- boolean flag = false;
- Principal principal1 = (Principal)enumeration.nextElement();
- if(principal1.equals(principal))
- return true;
- if(principal1 instanceof GroupImpl) {
- GroupImpl groupimpl = (GroupImpl)principal1;
- vector.addElement(this);
- if(!vector.contains(groupimpl))
- flag = groupimpl.isMemberRecurse(principal, vector);
- } else if(principal1 instanceof Group) {
- Group group1 = (Group)principal1;
- if(!vector.contains(group1)) flag = group1.isMember(principal);
- }
- if(flag) return flag;
- }
- return false;
- }
-} \ No newline at end of file
diff --git a/support/src/test/java/org/apache/harmony/security/tests/support/acl/OwnerImpl.java b/support/src/test/java/org/apache/harmony/security/tests/support/acl/OwnerImpl.java
deleted file mode 100644
index c3012b6..0000000
--- a/support/src/test/java/org/apache/harmony/security/tests/support/acl/OwnerImpl.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.harmony.security.tests.support.acl;
-
-import java.security.Principal;
-import java.security.acl.*;
-import java.util.Enumeration;
-
-/**
- * Additional class for verification Owner interface
- */
-public class OwnerImpl implements Owner {
-
- private Group ownerGroup;
-
- public OwnerImpl(Principal principal) {
- ownerGroup = new GroupImpl("AclOwners");
- ownerGroup.addMember(principal);
- }
-
- public synchronized boolean addOwner(Principal principal, Principal principal1)
- throws NotOwnerException {
-
- if(!isOwner(principal))
- {
- throw new NotOwnerException();
- } else {
- if (ownerGroup.isMember(principal1)) return false;
- if (!ownerGroup.isMember(principal1)) {
- ownerGroup.addMember(principal1);
- return true;
- }
- }
- return false;
- }
-
- public synchronized boolean deleteOwner(Principal principal, Principal principal1)
- throws NotOwnerException, LastOwnerException {
-
- if(!isOwner(principal)) throw new NotOwnerException();
- Enumeration enumeration = ownerGroup.members();
- Object obj = enumeration.nextElement();
- if(enumeration.hasMoreElements()) {
- return ownerGroup.removeMember(principal1);
- } else {
- throw new LastOwnerException();
- }
- }
-
- public synchronized boolean isOwner(Principal principal)
- {
- return ownerGroup.isMember(principal);
- }
-}
diff --git a/support/src/test/java/org/apache/harmony/security/tests/support/acl/PermissionImpl.java b/support/src/test/java/org/apache/harmony/security/tests/support/acl/PermissionImpl.java
deleted file mode 100644
index 2d355f9..0000000
--- a/support/src/test/java/org/apache/harmony/security/tests/support/acl/PermissionImpl.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.harmony.security.tests.support.acl;
-
-import java.security.acl.Permission;
-
-/**
- * Additional class for verification Permission interface
- */
-public class PermissionImpl implements Permission {
-
- private String permission;
-
- public PermissionImpl(String s) {
- permission = s;
- }
-
- public boolean equals(Object obj) {
- if(obj instanceof Permission) {
- Permission permission1 = (Permission)obj;
- return permission.equals(permission1.toString());
- } else {
- return false;
- }
- }
-
- public String toString() {
- return permission;
- }
-
-/* public int hashCode() {
- return toString().hashCode();
- }*/
-} \ No newline at end of file
diff --git a/support/src/test/java/org/apache/harmony/security/tests/support/acl/PrincipalImpl.java b/support/src/test/java/org/apache/harmony/security/tests/support/acl/PrincipalImpl.java
deleted file mode 100644
index f7dcba5..0000000
--- a/support/src/test/java/org/apache/harmony/security/tests/support/acl/PrincipalImpl.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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.harmony.security.tests.support.acl;
-
-import java.security.Principal;
-
-/**
- * Additional class for verification Principal interface
- */
-public class PrincipalImpl implements Principal {
-
- private String user;
-
- public PrincipalImpl(String s) {
- user = s;
- }
-
- public boolean equals(Object obj) {
- if(obj instanceof PrincipalImpl) {
- PrincipalImpl principalimpl = (PrincipalImpl)obj;
- return user.equals(principalimpl.toString());
- } else {
- return false;
- }
- }
-
- public String toString() {
- return user;
- }
-
- public int hashCode() {
- return user.hashCode();
- }
-
- public String getName() {
- return user;
- }
-}