    001    package org.bouncycastle.jcajce.provider.config;
    002
    003    import cpw.mods.fml.common.Side;
    004    import cpw.mods.fml.common.asm.SideOnly;
    005    import java.security.BasicPermission;
    006    import java.security.Permission;
    007    import java.util.StringTokenizer;
    008    import org.bouncycastle.util.Strings;
    009
    010    public class ProviderConfigurationPermission extends BasicPermission
    011    {
    012        private final String actions;
    013        private final int permissionMask;
    014
    015        @SideOnly(Side.CLIENT)
    016        public ProviderConfigurationPermission(String par1Str)
    017        {
    018            super(par1Str);
    019            this.actions = "all";
    020            this.permissionMask = 15;
    021        }
    022
    023        public ProviderConfigurationPermission(String par1Str, String par2Str)
    024        {
    025            super(par1Str, par2Str);
    026            this.actions = par2Str;
    027            this.permissionMask = this.calculateMask(par2Str);
    028        }
    029
    030        private int calculateMask(String par1Str)
    031        {
    032            StringTokenizer var2 = new StringTokenizer(Strings.toLowerCase(par1Str), " ,");
    033            int var3 = 0;
    034
    035            while (var2.hasMoreTokens())
    036            {
    037                String var4 = var2.nextToken();
    038
    039                if (var4.equals("threadlocalecimplicitlyca"))
    040                {
    041                    var3 |= 1;
    042                }
    043                else if (var4.equals("ecimplicitlyca"))
    044                {
    045                    var3 |= 2;
    046                }
    047                else if (var4.equals("threadlocaldhdefaultparams"))
    048                {
    049                    var3 |= 4;
    050                }
    051                else if (var4.equals("dhdefaultparams"))
    052                {
    053                    var3 |= 8;
    054                }
    055                else if (var4.equals("all"))
    056                {
    057                    var3 |= 15;
    058                }
    059            }
    060
    061            if (var3 == 0)
    062            {
    063                throw new IllegalArgumentException("unknown permissions passed to mask");
    064            }
    065            else
    066            {
    067                return var3;
    068            }
    069        }
    070
    071        public String getActions()
    072        {
    073            return this.actions;
    074        }
    075
    076        public boolean implies(Permission par1Permission)
    077        {
    078            if (!(par1Permission instanceof ProviderConfigurationPermission))
    079            {
    080                return false;
    081            }
    082            else if (!this.getName().equals(par1Permission.getName()))
    083            {
    084                return false;
    085            }
    086            else
    087            {
    088                ProviderConfigurationPermission var2 = (ProviderConfigurationPermission)par1Permission;
    089                return (this.permissionMask & var2.permissionMask) == var2.permissionMask;
    090            }
    091        }
    092
    093        public boolean equals(Object par1Obj)
    094        {
    095            if (par1Obj == this)
    096            {
    097                return true;
    098            }
    099            else if (!(par1Obj instanceof ProviderConfigurationPermission))
    100            {
    101                return false;
    102            }
    103            else
    104            {
    105                ProviderConfigurationPermission var2 = (ProviderConfigurationPermission)par1Obj;
    106                return this.permissionMask == var2.permissionMask && this.getName().equals(var2.getName());
    107            }
    108        }
    109
    110        public int hashCode()
    111        {
    112            return this.getName().hashCode() + this.permissionMask;
    113        }
    114    }