use of com.sun.identity.shared.datastruct.OrderedSet in project OpenAM by OpenRock.
the class DefaultClientTypesManager method mergeWithParent.
/**
* Merge the Client with its Parent. The parent could be in either in
* internal or external db. Used to merge uaprofile devices.
*
* @param cMap
* Map of the client data.
*
* @return The Merged map.
*/
private Map mergeWithParent(Map cMap) {
String ct = getClientType(cMap);
String parentId = getParentID(cMap);
Map rMap = cMap;
Map pMap = null;
OrderedSet os = new OrderedSet();
while ((parentId != null) && (!ct.equals(parentId))) {
pMap = (Map) mergedClientData.get(parentId);
if (pMap == null) {
debug.error(CLASS + "clientdata null for: " + parentId);
rMap = null;
break;
}
rMap = mergeMap(pMap, cMap);
os.add(parentId);
cMap = rMap;
ct = getClientType(pMap);
parentId = getParentID(pMap);
}
if (rMap != null) {
rMap.put(PARENT_ID, os);
}
return rMap;
}
use of com.sun.identity.shared.datastruct.OrderedSet in project OpenAM by OpenRock.
the class DefaultClientTypesManager method setParentStyles.
/**
* Sets the styles and parent ids tree set for a client
*
* @param clientData
*/
protected void setParentStyles(Map clientData) {
if (clientData == null) {
return;
}
// childs' parents
Set cParents = (Set) clientData.get(PARENT_ID);
String parentId = getFirstString(cParents);
String clientType = getClientType(clientData);
Map parentMap = (Map) mergedClientData.get(parentId);
if (parentMap == null) {
debug.error("ParentMap for clientType = " + clientType + ", parentId = " + parentId + " was null");
return;
}
//
if (baseProfiles.containsKey(parentId)) {
if (clientData.get(USER_AGENT) == null) {
Map s = (Map) baseProfiles.get(parentId);
if (s.get(clientType) == null) {
// valid style
s.put(clientType, new TreeMap());
if (debug.messageEnabled()) {
debug.message(CLASS + "Creating Style: " + clientType + " : Parent : " + parentId);
}
}
}
} else {
//
// Add the parent first and then add parent's parents'.
// NOTE: this will work only for a max of 2-level parent
//
OrderedSet os = new OrderedSet();
os.add(parentId);
Set pParents = (Set) parentMap.get(PARENT_ID);
os.addAll(pParents);
clientData.put(PARENT_ID, os);
}
}
use of com.sun.identity.shared.datastruct.OrderedSet in project OpenAM by OpenRock.
the class IOUtilsTest method testDeserializeValid.
@Test
public void testDeserializeValid() throws Exception {
// This assumes that the fallback list is in place
final Map validCollection = new HashMap();
validCollection.put("key1", "value1");
OrderedSet value2 = new OrderedSet();
value2.add("A");
value2.add("B");
value2.add("C");
value2.add("D");
validCollection.put("key2", value2);
Set<String> value3 = new HashSet<>();
value3.add("value3.1");
value3.add("value3.2");
value3.add("value3.3");
validCollection.put("key3", value3);
List<String> value4 = new ArrayList<>();
value4.add("value4.1");
value4.add("value4.2");
value4.add("value4.3");
value4.add("value4.4");
validCollection.put("key4", value4);
Map value5 = new HashMap();
value5.put("value2", value2);
value5.put("value3", value3);
value5.put("value4", value4);
validCollection.put("key5", value5);
validCollection.put("key6", Collections.emptyMap());
validCollection.put("key7", new Integer(7));
validCollection.put("key8", new Boolean(true));
validCollection.put("key9", new String[] { "1", "2" });
validCollection.put("key10", new Integer[] { 1, 2 });
validCollection.put("key11", new byte[] { 0, 1 });
validCollection.put("key12", new char[] { 0, 1 });
validCollection.put("key13", new short[] { 0, 1 });
validCollection.put("key14", new int[] { 0, 1 });
validCollection.put("key15", new long[] { 0, 1 });
validCollection.put("key16", new float[] { 0.0f, 1.0f });
validCollection.put("key17", new double[] { 0.0f, 1.0f });
validCollection.put("key18", new boolean[] { true, false });
validCollection.put("key19", new int[][] { { 1, 1 }, { 2, 2 } });
final byte[] bytes = getObjectStreamBytes(validCollection, true);
// can't use assertEquals here due to the way the primitives are checked for being equal
Assert.assertNotNull(IOUtils.deserialise(bytes, true));
}
use of com.sun.identity.shared.datastruct.OrderedSet in project OpenAM by OpenRock.
the class IDPProxyUtil method getNewAuthnRequest.
/**
* Constructs new authentication request by using the original request
* that is sent by the service provider to the proxying IDP.
* @param hostedEntityId hosted provider ID
* @param destination The destination where the new AuthnRequest will be sent to.
* @param realm Realm
* @param origRequest Original Authn Request
* @return AuthnRequest new authn request.
* @exception SAML2Exception for failure in creating new authn request.
* @return AuthnRequest object
*/
private static AuthnRequest getNewAuthnRequest(String hostedEntityId, String destination, String realm, AuthnRequest origRequest) throws SAML2Exception {
String classMethod = "IDPProxyUtil.getNewAuthnRequest: ";
// New Authentication request should only be a single sign-on request.
try {
AuthnRequest newRequest = ProtocolFactory.getInstance().createAuthnRequest();
String requestID = SAML2Utils.generateID();
if (requestID == null || requestID.isEmpty()) {
throw new SAML2Exception(SAML2Utils.bundle.getString("cannotGenerateID"));
}
newRequest.setID(requestID);
SPSSODescriptorElement localDescriptor = IDPSSOUtil.metaManager.getSPSSODescriptor(realm, hostedEntityId);
newRequest.setDestination(XMLUtils.escapeSpecialCharacters(destination));
newRequest.setConsent(origRequest.getConsent());
newRequest.setIsPassive(origRequest.isPassive());
newRequest.setForceAuthn(origRequest.isForceAuthn());
newRequest.setAttributeConsumingServiceIndex(origRequest.getAttributeConsumingServiceIndex());
newRequest.setAssertionConsumerServiceIndex(origRequest.getAssertionConsumerServiceIndex());
String protocolBinding = origRequest.getProtocolBinding();
newRequest.setProtocolBinding(protocolBinding);
OrderedSet acsSet = SPSSOFederate.getACSUrl(localDescriptor, protocolBinding);
String acsURL = (String) acsSet.get(0);
newRequest.setAssertionConsumerServiceURL(acsURL);
Issuer issuer = AssertionFactory.getInstance().createIssuer();
issuer.setValue(hostedEntityId);
newRequest.setIssuer(issuer);
NameIDPolicy origNameIDPolicy = origRequest.getNameIDPolicy();
if (origNameIDPolicy != null) {
NameIDPolicy newNameIDPolicy = ProtocolFactory.getInstance().createNameIDPolicy();
newNameIDPolicy.setFormat(origNameIDPolicy.getFormat());
newNameIDPolicy.setSPNameQualifier(hostedEntityId);
newNameIDPolicy.setAllowCreate(origNameIDPolicy.isAllowCreate());
newRequest.setNameIDPolicy(newNameIDPolicy);
}
newRequest.setRequestedAuthnContext(origRequest.getRequestedAuthnContext());
newRequest.setExtensions(origRequest.getExtensions());
newRequest.setIssueInstant(new Date());
newRequest.setVersion(SAML2Constants.VERSION_2_0);
Scoping scoping = origRequest.getScoping();
if (scoping != null) {
Scoping newScoping = ProtocolFactory.getInstance().createScoping();
Integer proxyCountInt = scoping.getProxyCount();
int proxyCount = 1;
if (proxyCountInt != null) {
proxyCount = scoping.getProxyCount().intValue();
newScoping.setProxyCount(new Integer(proxyCount - 1));
}
newScoping.setIDPList(scoping.getIDPList());
newRequest.setScoping(newScoping);
} else {
//handling the alwaysIdpProxy case -> the incoming request
//did not contained a Scoping field
SPSSOConfigElement spConfig = getSPSSOConfigByAuthnRequest(realm, origRequest);
Map<String, List<String>> spConfigAttrMap = SAML2MetaUtils.getAttributes(spConfig);
scoping = ProtocolFactory.getInstance().createScoping();
String proxyCountParam = SPSSOFederate.getParameter(spConfigAttrMap, SAML2Constants.IDP_PROXY_COUNT);
if (proxyCountParam != null && (!proxyCountParam.equals(""))) {
int proxyCount = Integer.valueOf(proxyCountParam);
if (proxyCount <= 0) {
scoping.setProxyCount(0);
} else {
//since this is a remote SP configuration, we should
//decrement the proxycount by one
scoping.setProxyCount(proxyCount - 1);
}
}
List<String> proxyIdPs = spConfigAttrMap.get(SAML2Constants.IDP_PROXY_LIST);
if (proxyIdPs != null && !proxyIdPs.isEmpty()) {
List<IDPEntry> list = new ArrayList<IDPEntry>();
for (String proxyIdP : proxyIdPs) {
IDPEntry entry = ProtocolFactory.getInstance().createIDPEntry();
entry.setProviderID(proxyIdP);
list.add(entry);
}
IDPList idpList = ProtocolFactory.getInstance().createIDPList();
idpList.setIDPEntries(list);
scoping.setIDPList(idpList);
newRequest.setScoping(scoping);
}
}
return newRequest;
} catch (Exception ex) {
SAML2Utils.debug.error(classMethod + "Error in creating new authn request.", ex);
throw new SAML2Exception(ex);
}
}
use of com.sun.identity.shared.datastruct.OrderedSet in project OpenAM by OpenRock.
the class DirectoryServicesImpl method searchResultsToSet.
/**
* convert search results to a set of DNS
*/
private Set searchResultsToSet(SearchResults results) throws UMSException {
Set set = new OrderedSet();
if (results != null) {
while (results.hasMoreElements()) {
PersistentObject one = results.next();
set.add(one.getGuid().toString());
}
}
return set;
}
Aggregations