use of com.sun.identity.cot.COTException in project OpenAM by OpenRock.
the class ImportMetaData method validateCOT.
private void validateCOT() throws CLIException {
if ((cot != null) && (cot.length() > 0)) {
try {
CircleOfTrustManager cotManager = new CircleOfTrustManager(ssoToken);
if (!cotManager.getAllCirclesOfTrust(realm).contains(cot)) {
String[] args = { realm, metadata, extendedData, cot, spec, getResourceString("import-entity-exception-cot-no-exist") };
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_IMPORT_ENTITY", args);
throw new CLIException(getResourceString("import-entity-exception-cot-no-exist"), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
} catch (COTException e) {
throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
}
use of com.sun.identity.cot.COTException in project OpenAM by OpenRock.
the class ImportMetaData method handleWSFedRequest.
private void handleWSFedRequest(RequestContext rc) throws CLIException {
try {
String federationID = null;
List<String> newMetaAliases = null;
com.sun.identity.wsfederation.jaxb.entityconfig.FederationConfigElement configElt = null;
if (extendedData != null) {
configElt = getWSFedEntityConfigElement();
/*
* see note at the end of this class for how we decide
* the realm value
*/
if (configElt != null && configElt.isHosted()) {
List config = configElt.getIDPSSOConfigOrSPSSOConfig();
if (!config.isEmpty()) {
com.sun.identity.wsfederation.jaxb.entityconfig.BaseConfigType bConfig = (com.sun.identity.wsfederation.jaxb.entityconfig.BaseConfigType) config.iterator().next();
realm = WSFederationMetaUtils.getRealmByMetaAlias(bConfig.getMetaAlias());
newMetaAliases = getMetaAliases(config);
}
}
}
WSFederationMetaManager metaManager = new WSFederationMetaManager(ssoToken);
if (metadata != null) {
federationID = importWSFedMetaData();
}
if (configElt != null) {
if (null != newMetaAliases && !newMetaAliases.isEmpty()) {
metaManager.validateMetaAliasForNewEntity(realm, newMetaAliases);
}
metaManager.createEntityConfig(realm, configElt);
String out = (webAccess) ? "web" : extendedData;
Object[] objs = { out };
getOutputWriter().printlnMessage(MessageFormat.format(getResourceString("import-entity-succeeded"), objs));
}
if ((cot != null) && (cot.length() > 0) && (federationID != null)) {
CircleOfTrustManager cotManager = new CircleOfTrustManager(ssoToken);
if (!cotManager.isInCircleOfTrust(realm, cot, spec, federationID)) {
cotManager.addCircleOfTrustMember(realm, cot, spec, federationID);
}
}
} catch (COTException e) {
throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
} catch (WSFederationMetaException e) {
throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
use of com.sun.identity.cot.COTException in project OpenAM by OpenRock.
the class ListCircleOfTrustMembers method handleRequest.
/**
* List members in a circle of trust.
*
* @param rc Request Context.
* @throws CLIException if unable to process this request.
*/
@Override
public void handleRequest(RequestContext rc) throws CLIException {
super.handleRequest(rc);
ldapLogin();
realm = getStringOptionValue(FedCLIConstants.ARGUMENT_REALM, "/");
cot = getStringOptionValue(FedCLIConstants.ARGUMENT_COT);
IOutput outputWriter = getOutputWriter();
spec = FederationManager.getIDFFSubCommandSpecification(rc);
String[] params = { realm, cot, spec };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_LIST_COT_MEMBERS", params);
try {
CircleOfTrustManager cotManager = new CircleOfTrustManager(ssoToken);
Set circleOfTrusts = cotManager.getAllCirclesOfTrust(realm);
if (!circleOfTrusts.contains(cot)) {
Object[] obj = { cot };
String[] args = { realm, cot, spec, MessageFormat.format(getResourceString("list-circle-of-trust-members-cot-does-not-exists"), obj) };
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_LIST_COT_MEMBERS", args);
throw new CLIException(MessageFormat.format(getResourceString("list-circle-of-trust-members-cot-does-not-exists"), obj), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
Set members = cotManager.listCircleOfTrustMember(realm, cot, spec);
if ((members == null) || members.isEmpty()) {
Object[] obj = { cot };
outputWriter.printlnMessage(MessageFormat.format(getResourceString("list-circle-of-trust-members-no-members"), obj));
} else {
Object[] obj = { cot };
outputWriter.printlnMessage(MessageFormat.format(getResourceString("list-circle-of-trust-members-members"), obj));
for (Iterator i = members.iterator(); i.hasNext(); ) {
String entityId = (String) i.next();
outputWriter.printlnMessage(" " + entityId);
}
}
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEEDED_LIST_COT_MEMBERS", params);
} catch (COTException e) {
debugWarning("ListCircleOfTrustMembers.handleRequest", e);
String[] args = { realm, cot, spec, e.getMessage() };
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_LIST_COT_MEMBERS", args);
throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
use of com.sun.identity.cot.COTException in project OpenAM by OpenRock.
the class ListCircleOfTrusts method handleRequest.
/**
* Lists circle of trusts.
*
* @param rc Request Context.
* @throws CLIException if unable to process this request.
*/
@Override
public void handleRequest(RequestContext rc) throws CLIException {
super.handleRequest(rc);
ldapLogin();
realm = getStringOptionValue(FedCLIConstants.ARGUMENT_REALM, "/");
IOutput outputWriter = getOutputWriter();
String[] params = { realm };
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "ATTEMPT_LIST_COTS", params);
try {
CircleOfTrustManager cotManager = new CircleOfTrustManager(ssoToken);
Set members = cotManager.getAllCirclesOfTrust(realm);
if ((members == null) || members.isEmpty()) {
Object[] obj = { realm };
outputWriter.printlnMessage(MessageFormat.format(getResourceString("list-circles-of-trust-no-members"), obj));
} else {
Object[] obj = { realm };
outputWriter.printlnMessage(MessageFormat.format(getResourceString("list-circles-of-trust-members"), obj));
for (Iterator i = members.iterator(); i.hasNext(); ) {
String cot = (String) i.next();
outputWriter.printlnMessage(" " + cot);
}
}
writeLog(LogWriter.LOG_ACCESS, Level.INFO, "SUCCEEDED_LIST_COTS", params);
} catch (COTException e) {
debugWarning("ListCircleOfTrusts.handleRequest", e);
String[] args = { realm, e.getMessage() };
writeLog(LogWriter.LOG_ERROR, Level.INFO, "FAILED_LIST_COTS", args);
throw new CLIException(e.getMessage(), ExitCodes.REQUEST_CANNOT_BE_PROCESSED);
}
}
use of com.sun.identity.cot.COTException in project OpenAM by OpenRock.
the class TaskModelImpl method getEntities.
/**
* Returns a set of entities in a circle of trust.
*
* @param realm Realm.
* @param cotName Name of circle of trust.
* @return a set of entities in a circle of trust.
* @throws AMConsoleException if unable to retrieve entities.
*/
public Set getEntities(String realm, String cotName) throws AMConsoleException {
try {
CircleOfTrustManager mgr = new CircleOfTrustManager();
Set entities = mgr.listCircleOfTrustMember(realm, cotName, COTConstants.SAML2);
return (entities == null) ? Collections.EMPTY_SET : entities;
} catch (COTException ex) {
throw new AMConsoleException(ex.getMessage());
}
}
Aggregations