use of com.sun.identity.liberty.ws.disco.jaxb.AuthorizeRequesterElement 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;
}
use of com.sun.identity.liberty.ws.disco.jaxb.AuthorizeRequesterElement in project OpenAM by OpenRock.
the class SMDiscoveryServiceData method getDirectiveEntry.
/**
* Returns map of directive entries.
*
* @return map of directive entries.
*/
public static Map getDirectiveEntry(DiscoEntryElement entry) {
Map map = Collections.EMPTY_MAP;
List directiveList = entry.getAny();
if ((directiveList != null) && !directiveList.isEmpty()) {
map = new HashMap(directiveList.size() * 2);
for (Iterator iter = directiveList.iterator(); iter.hasNext(); ) {
Object obj = iter.next();
;
if (obj instanceof AuthenticateRequesterElement) {
AuthenticateRequesterElement dType = (AuthenticateRequesterElement) obj;
setDirectiveData(dType, map, DiscoConstants.AUTHN_DIRECTIVE);
} else if (obj instanceof EncryptResourceIDElement) {
EncryptResourceIDElement dType = (EncryptResourceIDElement) obj;
setDirectiveData(dType, map, DiscoConstants.ENCRYPT_DIRECTIVE);
} else if (obj instanceof AuthenticateSessionContextElement) {
AuthenticateSessionContextElement dType = (AuthenticateSessionContextElement) obj;
setDirectiveData(dType, map, DiscoConstants.SESSION_DIRECTIVE);
} else if (obj instanceof AuthorizeRequesterElement) {
AuthorizeRequesterElement dType = (AuthorizeRequesterElement) obj;
setDirectiveData(dType, map, DiscoConstants.AUTHZ_DIRECTIVE);
} else if (obj instanceof GenerateBearerTokenElement) {
GenerateBearerTokenElement dType = (GenerateBearerTokenElement) obj;
setDirectiveData(dType, map, DiscoConstants.BEARER_DIRECTIVE);
} else if (obj instanceof SendSingleLogOutElement) {
SendSingleLogOutElement dType = (SendSingleLogOutElement) obj;
setDirectiveData(dType, map, DiscoConstants.LOGOUT_DIRECTIVE);
} else {
debug.error("unsupported directive type");
}
}
}
return map;
}
use of com.sun.identity.liberty.ws.disco.jaxb.AuthorizeRequesterElement in project OpenAM by OpenRock.
the class SMDiscoEntryData method createDirectivesEntry.
private void createDirectivesEntry(DiscoEntryElement de, List descriptionTypeList) throws JAXBException, AMConsoleException {
if ((directives != null) && !directives.isEmpty()) {
Set set = directives.keySet();
for (Iterator iter = set.iterator(); iter.hasNext(); ) {
String dName = (String) iter.next();
List idRefs = (List) directives.get(dName);
if (dName.equals(DiscoConstants.AUTHN_DIRECTIVE)) {
AuthenticateRequesterElement authenticateRequester = discoFac.createAuthenticateRequesterElement();
createDirectiveEntry(de, authenticateRequester, idRefs, descriptionTypeList);
} else if (dName.equals(DiscoConstants.ENCRYPT_DIRECTIVE)) {
EncryptResourceIDElement encryptResourceId = discoFac.createEncryptResourceIDElement();
createDirectiveEntry(de, encryptResourceId, idRefs, descriptionTypeList);
} else if (dName.equals(DiscoConstants.SESSION_DIRECTIVE)) {
AuthenticateSessionContextElement authSessionCntx = discoFac.createAuthenticateSessionContextElement();
createDirectiveEntry(de, authSessionCntx, idRefs, descriptionTypeList);
} else if (dName.equals(DiscoConstants.AUTHZ_DIRECTIVE)) {
AuthorizeRequesterElement authorizeRequester = discoFac.createAuthorizeRequesterElement();
createDirectiveEntry(de, authorizeRequester, idRefs, descriptionTypeList);
} else if (dName.equals(DiscoConstants.BEARER_DIRECTIVE)) {
GenerateBearerTokenElement bearer = disco11Fac.createGenerateBearerTokenElement();
createDirectiveEntry(de, bearer, idRefs, descriptionTypeList);
} else if (dName.equals(DiscoConstants.LOGOUT_DIRECTIVE)) {
SendSingleLogOutElement logout = disco11Fac.createSendSingleLogOutElement();
createDirectiveEntry(de, logout, idRefs, descriptionTypeList);
}
}
}
}
Aggregations