001/* 002 * oauth2-oidc-sdk 003 * 004 * Copyright 2012-2016, Connect2id Ltd and contributors. 005 * 006 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use 007 * this file except in compliance with the License. You may obtain a copy of the 008 * 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 distributed 013 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 014 * CONDITIONS OF ANY KIND, either express or implied. See the License for the 015 * specific language governing permissions and limitations under the License. 016 */ 017 018package com.nimbusds.openid.connect.sdk.federation.policy.operations; 019 020 021import com.nimbusds.openid.connect.sdk.federation.policy.language.OperationName; 022import com.nimbusds.openid.connect.sdk.federation.policy.language.PolicyOperation; 023 024 025/** 026 * The default policy operation factory. 027 * 028 * <p>Supports all standard OpenID Connect federation policy operations: 029 * 030 * <ul> 031 * <li>{@link SubsetOfOperation subset_of} 032 * <li>{@link OneOfOperation one_of} 033 * <li>{@link SupersetOfOperation superset_of} 034 * <li>{@link AddOperation add} 035 * <li>{@link ValueOperation value} 036 * <li>{@link DefaultOperation default} 037 * <li>{@link EssentialOperation essential} 038 * </ul> 039 * 040 * <p>Override the {@link #createForName} method to support additional custom 041 * policies. 042 * 043 * <p>Related specifications: 044 * 045 * <ul> 046 * <li>OpenID Connect Federation 1.0, section 4.1. 047 * </ul> 048 */ 049public class DefaultPolicyOperationFactory implements PolicyOperationFactory { 050 051 052 @Override 053 public PolicyOperation createForName(final OperationName name) { 054 055 if (SubsetOfOperation.NAME.equals(name)) { 056 return new SubsetOfOperation(); 057 } else if (OneOfOperation.NAME.equals(name)) { 058 return new OneOfOperation(); 059 } else if (SupersetOfOperation.NAME.equals(name)) { 060 return new SupersetOfOperation(); 061 } else if (AddOperation.NAME.equals(name)) { 062 return new AddOperation(); 063 } else if (ValueOperation.NAME.equals(name)) { 064 return new ValueOperation(); 065 } else if (DefaultOperation.NAME.equals(name)) { 066 return new DefaultOperation(); 067 } else if (EssentialOperation.NAME.equals(name)) { 068 return new EssentialOperation(); 069 } else { 070 return null; 071 } 072 } 073}