FederationManager.java revision 4a2f0f0be43dfd4c1b490cbf3cc48b6ba6084b1c
a4544a5a0e622ef69e38641f87ab1b5685e05911Phill Cunnington/**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The contents of this file are subject to the terms
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * of the Common Development and Distribution License
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * (the License). You may not use this file except in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * compliance with the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * You can obtain a copy of the License at
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * opensso/legal/CDDLv1.0.txt
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * See the License for the specific language governing
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * permission and limitations under the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * When distributing Covered Code, include this CDDL
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Header Notice in each file and include the License file
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * at opensso/legal/CDDLv1.0.txt.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * If applicable, add the following below the CDDL Header,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * with the fields enclosed by brackets [] replaced by
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * your own identifying information:
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * "Portions Copyrighted [year] [name of copyright owner]"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * $Id: FederationManager.java,v 1.9 2009/06/05 19:33:43 veiming Exp $
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
a4544a5a0e622ef69e38641f87ab1b5685e05911Phill Cunnington */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpackage com.sun.identity.federation.cli;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.cli.CLIDefinitionBase;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.cli.CLIException;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.cli.RequestContext;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport java.util.List;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster/**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * OpenSSO CLI definition class.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpublic class FederationManager extends CLIDefinitionBase {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private static final String DEFINITION_CLASS =
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster "com.sun.identity.federation.cli.definition.FederationManager";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster static final String DEFAULT_SPECIFICATION =
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster FedCLIConstants.SAML2_SPECIFICATION;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Constructs an instance of this class.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public FederationManager()
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster throws CLIException {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster super(DEFINITION_CLASS);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns product name.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return product name.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public String getProductName() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return rb.getString(FederationManagerConstants.I18N_PRODUCT_NAME);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns <code>true</code> if the option is an authentication related
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * option such as user ID and password.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param opt Name of option.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return <code>true</code> if the option is an authentication related
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * option such as user ID and password.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public boolean isAuthOption(String opt) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return opt.equals(FederationManagerConstants.ARGUMENT_ADMIN_ID) ||
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster opt.equals(FederationManagerConstants.ARGUMENT_PASSWORD_FILE);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns specification version for ID-FF/SAML sub commands.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return specification version for ID-FF/SAML sub commands.
8d3140b524c0e28c0a49dc7c7d481123ef3cfe11Chris Lee */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public static String getIDFFSubCommandSpecification(RequestContext rc) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster String spec = DEFAULT_SPECIFICATION;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster List specs = rc.getOption(FedCLIConstants.SPECIFICATION_VERSION);
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if ((specs != null) && !specs.isEmpty()) {
8d3140b524c0e28c0a49dc7c7d481123ef3cfe11Chris Lee spec = ((String)specs.get(0)).trim();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return spec;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster}
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster