001/*******************************************************************************
002 * Copyright 2017 The MIT Internet Trust Consortium
003 *
004 * Portions copyright 2011-2013 The MITRE Corporation
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 *******************************************************************************/
018/**
019 *
020 */
021package org.mitre.openid.connect.view;
022
023import java.util.Set;
024
025import org.springframework.stereotype.Component;
026import org.springframework.validation.BeanPropertyBindingResult;
027
028import com.google.common.collect.ImmutableSet;
029import com.google.gson.ExclusionStrategy;
030import com.google.gson.FieldAttributes;
031
032/**
033 *
034 * View bean for full view of client entity, for admins.
035 *
036 * @see ClientEntityViewForUsers
037 * @author jricher
038 *
039 */
040@Component(ClientEntityViewForAdmins.VIEWNAME)
041public class ClientEntityViewForAdmins extends AbstractClientEntityView {
042
043        public static final String VIEWNAME = "clientEntityViewAdmins";
044        private Set<String> blacklistedFields = ImmutableSet.of("additionalInformation");
045
046        /**
047         * @return
048         */
049        @Override
050        protected ExclusionStrategy getExclusionStrategy() {
051                return new ExclusionStrategy() {
052
053                        @Override
054                        public boolean shouldSkipField(FieldAttributes f) {
055                                if (blacklistedFields.contains(f.getName())) {
056                                        return true;
057                                } else {
058                                        return false;
059                                }
060                        }
061
062                        @Override
063                        public boolean shouldSkipClass(Class<?> clazz) {
064                                // skip the JPA binding wrapper
065                                if (clazz.equals(BeanPropertyBindingResult.class)) {
066                                        return true;
067                                }
068                                return false;
069                        }
070
071                };
072        }
073}