001    /*
002     * Copyright (C) 2014 XStream Committers.
003     * All rights reserved.
004     *
005     * Created on 19. January 2014 by Joerg Schaible
006     */
007    package com.thoughtworks.xstream.security;
008    
009    import java.lang.reflect.Proxy;
010    
011    import com.thoughtworks.xstream.mapper.DynamicProxyMapper;
012    
013    
014    /**
015     * Permission for any array type.
016     * 
017     * @author Jörg Schaible
018     * @since 1.4.7
019     */
020    public class ProxyTypePermission implements TypePermission {
021        /**
022         * @since 1.4.7
023         */
024        public static final TypePermission PROXIES = new ProxyTypePermission();
025    
026        public boolean allows(final Class type) {
027            return type != null && (Proxy.isProxyClass(type) || type == DynamicProxyMapper.DynamicProxy.class);
028        }
029    
030        public int hashCode() {
031            return 17;
032        }
033    
034        public boolean equals(final Object obj) {
035            return obj != null && obj.getClass() == ProxyTypePermission.class;
036        }
037    }