View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.syncope.client.console.clientapps;
20  
21  import java.util.List;
22  import org.apache.commons.lang3.StringUtils;
23  import org.apache.syncope.client.console.rest.ClientAppRestClient;
24  import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.BooleanConditionColumn;
25  import org.apache.syncope.common.lib.to.OIDCRPClientAppTO;
26  import org.apache.syncope.common.lib.types.AMEntitlement;
27  import org.apache.syncope.common.lib.types.ClientAppType;
28  import org.apache.wicket.PageReference;
29  import org.apache.wicket.authroles.authorization.strategies.role.metadata.MetaDataRoleAuthorizationStrategy;
30  import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
31  import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
32  import org.apache.wicket.model.IModel;
33  import org.apache.wicket.model.StringResourceModel;
34  
35  public class OIDCRPDirectoryPanel extends ClientAppDirectoryPanel<OIDCRPClientAppTO> {
36  
37      private static final long serialVersionUID = -9182884609300468766L;
38  
39      public OIDCRPDirectoryPanel(final String id, final ClientAppRestClient restClient, final PageReference pageRef) {
40          super(id, restClient, ClientAppType.OIDCRP, pageRef);
41  
42          OIDCRPClientAppTO defaultItem = new OIDCRPClientAppTO();
43  
44          addNewItemPanelBuilder(new ClientAppModalPanelBuilder<>(
45                  ClientAppType.OIDCRP,
46                  defaultItem,
47                  modal,
48                  policyRestClient,
49                  clientAppRestClient,
50                  realmRestClient,
51                  pageRef),
52                  true);
53          MetaDataRoleAuthorizationStrategy.authorize(addAjaxLink, RENDER, AMEntitlement.CLIENTAPP_CREATE);
54  
55          initResultTable();
56      }
57  
58      @Override
59      protected void addCustomColumnFields(final List<IColumn<OIDCRPClientAppTO, String>> columns) {
60          columns.add(new PropertyColumn<>(new StringResourceModel("clientId", this), "clientId", "clientId"));
61          columns.add(new PropertyColumn<>(
62                  new StringResourceModel("redirectUris", this), "redirectUris", "redirectUris"));
63          columns.add(new BooleanConditionColumn<>(new StringResourceModel("logout")) {
64  
65              private static final long serialVersionUID = -8236820422411536323L;
66  
67              @Override
68              protected boolean isCondition(final IModel<OIDCRPClientAppTO> rowModel) {
69                  return StringUtils.isNotBlank(rowModel.getObject().getLogoutUri());
70              }
71          });
72      }
73  }