use of com.sun.identity.liberty.ws.disco.jaxb.InsertEntryType in project OpenAM by OpenRock.
the class DiscoEntryHandlerImplUtils method handleInserts.
/*
* Adds discovery entries.
* Used by implementations of SPI <code>DiscoEntryHandler</code>:
* <code>UserDiscoEntryHandler</code> and
* <code>UserDynamicEntryHandler</code>.
*
* @param discoEntriesMap Discovery Entries Map.
* @param removes List of entries to be added.
* @return true if the operation is successful; false otherwise.
*/
public static Map handleInserts(Set discoEntries, List inserts) {
/*
* if support proxy:
* look through discoEntries and find all the serviceTypes that have
* proxy proxyServiceTypes
*/
Map insertResults = new HashMap();
insertResults.put(DiscoEntryHandler.STATUS_CODE, DiscoConstants.STATUS_FAILED);
Set supportedDirectives = DiscoServiceManager.getSupportedDirectives();
if (debug.messageEnabled()) {
debug.message("DiscoEntryHandlerImplUtils.handleInserts: " + "size of supportedDirective is " + supportedDirectives.size());
}
Iterator i = inserts.iterator();
InsertEntryType insertEntry = null;
DiscoEntryElement de = null;
ResourceOfferingType resOff = null;
List newEntryIDs = new LinkedList();
while (i.hasNext()) {
insertEntry = (InsertEntryType) i.next();
try {
de = DiscoUtils.getDiscoEntryFactory().createDiscoEntryElement();
} catch (JAXBException je) {
debug.error("DiscoEntryHandlerImplUtils.handleInserts: couldn't " + "create DiscoEntry: ", je);
return insertResults;
}
resOff = insertEntry.getResourceOffering();
String newEntryID = SAMLUtils.generateID();
if (debug.messageEnabled()) {
debug.message("DiscoEntryHandlerImplUtils: newEntryID=" + newEntryID);
}
resOff.setEntryID(newEntryID);
newEntryIDs.add(newEntryID);
de.setResourceOffering(resOff);
List dirs = insertEntry.getAny();
if ((dirs != null) && !dirs.isEmpty()) {
Iterator j = dirs.iterator();
while (j.hasNext()) {
Object dir = j.next();
if (dir instanceof AuthenticateRequesterElement) {
if (!supportedDirectives.contains(DiscoConstants.AUTHN_DIRECTIVE)) {
debug.error("Directive AuthenticateRequester is " + "not supported.");
return insertResults;
}
} else if (dir instanceof AuthorizeRequesterElement) {
if (!supportedDirectives.contains(DiscoConstants.AUTHZ_DIRECTIVE)) {
debug.error("Directive AuthorizeRequester is " + "not supported.");
return insertResults;
}
} else if (dir instanceof AuthenticateSessionContextElement) {
if (!supportedDirectives.contains(DiscoConstants.SESSION_DIRECTIVE)) {
debug.error("Directive AuthenticateSessionContext " + "is not supported.");
return insertResults;
}
} else if (dir instanceof EncryptResourceIDElement) {
if (!supportedDirectives.contains(DiscoConstants.ENCRYPT_DIRECTIVE)) {
debug.error("Directive EncryptResourceID " + "is not supported.");
return insertResults;
}
} else if (dir instanceof GenerateBearerTokenElement) {
if (!supportedDirectives.contains(DiscoConstants.BEARER_DIRECTIVE)) {
debug.error("Directive GenerateBearerToken " + "is not supported.");
return insertResults;
}
} else {
debug.error("Directive " + dir + " is not supported.");
return insertResults;
}
}
de.getAny().addAll(dirs);
}
if (!discoEntries.add(de)) {
debug.error("DiscoEntryHandlerImplUtils.handleInserts: couldn't " + "add DiscoEntry to Set.");
return insertResults;
}
}
insertResults.put(DiscoEntryHandler.STATUS_CODE, DiscoConstants.STATUS_OK);
insertResults.put(DiscoEntryHandler.NEW_ENTRY_IDS, newEntryIDs);
return insertResults;
}
Aggregations