ImportMetaData.java revision e99c5132fdbbe07880893fa1f7d7afb2767261be
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: ImportMetaData.java,v 1.15 2009/10/29 00:03:50 exu Exp $
*
* Portions Copyrighted 2012-2015 ForgeRock As.
*/
/**
* Import Meta Data.
*/
public class ImportMetaData extends AuthenticatedCommand {
private String extendedData;
private boolean webAccess;
/**
* Imports Meta Data.
*
* @param rc Request Context.
* @throws CLIException if unable to process this request.
*/
throws CLIException {
super.handleRequest(rc);
ldapLogin();
"ATTEMPT_IMPORT_ENTITY", params);
"FAILED_IMPORT_ENTITY", args);
throw new CLIException(
getResourceString("import-entity-exception-no-datafile"),
}
validateCOT();
try {
"SUCCEEDED_IMPORT_ENTITY", params);
"SUCCEEDED_IMPORT_ENTITY", params);
"SUCCEEDED_IMPORT_ENTITY", params);
} else {
throw new CLIException(
getResourceString("unsupported-specification"),
}
} catch (CLIException e) {
spec, e.getMessage()};
"FAILED_IMPORT_ENTITY", args);
throw e;
}
}
private void validateCOT()
throws CLIException {
try {
ssoToken);
spec,
"import-entity-exception-cot-no-exist")
};
"FAILED_IMPORT_ENTITY", args);
throw new CLIException(
"import-entity-exception-cot-no-exist"),
}
} catch (COTException e) {
throw new CLIException(e.getMessage(),
}
}
}
throws CLIException {
try {
if (extendedData != null) {
/*
* see note at the end of this class for how we decide
* the realm value
*/
bConfig.getMetaAlias());
}
}
}
// Load the metadata if it has been provided
}
// Load the extended metadata if it has been provided
}
}
}
}
ssoToken);
}
}
}
} catch (COTException e) {
throw new CLIException(e.getMessage(),
} catch (SAML2MetaException e) {
throw new CLIException(e.getMessage(),
}
}
throws CLIException {
try {
if (extendedData != null) {
/*
* see note at the end of this class for how we decide
* the realm value
*/
} else {
spConfig.getMetaAlias());
}
}
}
}
}
}
ssoToken);
entityID);
}
}
} catch (IDFFMetaException e) {
throw new CLIException(e.getMessage(),
} catch (COTException e) {
throw new CLIException(e.getMessage(),
}
}
throws CLIException {
try {
if (extendedData != null) {
/*
* see note at the end of this class for how we decide
* the realm value
*/
bConfig =
bConfig.getMetaAlias());
}
}
}
ssoToken);
}
}
}
(federationID != null)) {
ssoToken);
) {
}
}
} catch (COTException e) {
throw new CLIException(e.getMessage(),
} catch (WSFederationMetaException e) {
throw new CLIException(e.getMessage(),
}
}
throws SAML2MetaException, CLIException {
try {
if (webAccess) {
} else {
}
"import-entity-exception-invalid-descriptor-file"),
}
"import-entity-exception-invalid-descriptor-file"),
}
return result;
} catch (FileNotFoundException e) {
} catch (JAXBException e) {
debugWarning("ImportMetaData.importMetaData", e);
"import-entity-exception-invalid-descriptor-file"),
} catch (IllegalArgumentException e) {
debugWarning("ImportMetaData.importMetaData", e);
"import-entity-exception-invalid-descriptor-file"),
} finally {
try {
} catch (IOException e) {
//do not if the file cannot be closed.
}
}
}
}
throws IDFFMetaException, CLIException
{
try {
if (webAccess) {
} else {
}
if (obj instanceof
obj;
//TODO: signature
//SAML2MetaSecurityUtils.verifySignature(doc);
//
}
return entityID;
} catch (FileNotFoundException e) {
} catch (JAXBException e) {
debugWarning("ImportMetaData.importMetaData", e);
"import-entity-exception-invalid-descriptor-file"),
} catch (IllegalArgumentException e) {
debugWarning("ImportMetaData.importMetaData", e);
"import-entity-exception-invalid-descriptor-file"),
} finally {
try {
} catch (IOException e) {
//do not if the file cannot be closed.
}
}
}
}
private String importWSFedMetaData()
{
try {
if (webAccess) {
} else {
}
// Just get the first element for now...
// TODO - loop through Federation elements?
obj = ((com.sun.identity.wsfederation.jaxb.wsfederation.FederationMetadataElement)obj).getAny().get(0);
}
if ( federationID == null )
{
}
// WSFederationMetaSecurityUtils.verifySignature(doc);
}
return federationID;
} catch (FileNotFoundException e) {
} catch (JAXBException e) {
debugWarning("ImportMetaData.importMetaData", e);
"import-entity-exception-invalid-descriptor-file"),
} catch (IllegalArgumentException e) {
debugWarning("ImportMetaData.importMetaData", e);
"import-entity-exception-invalid-descriptor-file"),
} finally {
try {
} catch (IOException e) {
//do not if the file cannot be closed.
}
}
}
}
private EntityConfigElement geEntityConfigElement()
throws SAML2MetaException, CLIException {
try {
if (webAccess) {
} else {
}
return (obj instanceof EntityConfigElement) ?
} catch (FileNotFoundException e) {
} catch (JAXBException e) {
debugWarning("ImportMetaData.importExtendedData", e);
"import-entity-exception-invalid-config-file"), objs),
} catch (IllegalArgumentException e) {
debugWarning("ImportMetaData.importExtendedData", e);
"import-entity-exception-invalid-config-file"), objs),
} finally {
try {
} catch (IOException e) {
//do not if the file cannot be closed.
}
}
}
}
try {
if (webAccess) {
} else {
}
return (obj instanceof
} catch (IOException e) {
} catch (JAXBException e) {
debugWarning("ImportMetaData.importExtendedData", e);
"import-entity-exception-invalid-config-file"), objs),
} catch (IllegalArgumentException e) {
debugWarning("ImportMetaData.importExtendedData", e);
"import-entity-exception-invalid-config-file"), objs),
}
}
throws WSFederationMetaException, CLIException {
try {
if (webAccess) {
} else {
}
return (obj instanceof
null;
} catch (FileNotFoundException e) {
} catch (JAXBException e) {
debugWarning("ImportMetaData.importExtendedData", e);
"import-entity-exception-invalid-config-file"), objs),
} catch (IllegalArgumentException e) {
debugWarning("ImportMetaData.importExtendedData", e);
"import-entity-exception-invalid-config-file"), objs),
} finally {
try {
} catch (IOException e) {
//do not if the file cannot be closed.
}
}
}
}
/**
* Gets the metaaliases for this configuration
* @param config the{@link BaseConfigType}.
* @return the metaAliases or an empty list if none found.
*/
}
}
return metaAliases;
}
throws IOException {
try {
}
} finally {
}
}
}
}
/* Deciding realm value
if (extended metadata xml exists) {
if (hosted) {
get the realm value from meta alias either from IDP or SP
config element.
} else {
use the value provide by --realm/-e option
}
} else {
use the value provide by --realm/-e option
}
*/