use of com.sun.identity.wsfederation.jaxb.wsfederation.TokenIssuerNameElement in project OpenAM by OpenRock.
the class CreateWSFedMetaDataTemplate method addWSFedIdentityProviderTemplate.
private static void addWSFedIdentityProviderTemplate(String entityId, com.sun.identity.wsfederation.jaxb.wsfederation.ObjectFactory objFactory, FederationElement fed, Map mapParams, String url) throws JAXBException, CertificateEncodingException {
if (url == null) {
url = getHostURL();
}
String idpAlias = (String) mapParams.get(MetaTemplateParameters.P_IDP);
String idpSCertAlias = (String) mapParams.get(MetaTemplateParameters.P_IDP_S_CERT);
String maStr = buildMetaAliasInURI(idpAlias);
if ((idpSCertAlias != null) && idpSCertAlias.length() > 0) {
com.sun.identity.wsfederation.jaxb.wsse.ObjectFactory secextObjFactory = new com.sun.identity.wsfederation.jaxb.wsse.ObjectFactory();
com.sun.identity.wsfederation.jaxb.xmlsig.ObjectFactory dsObjectFactory = new com.sun.identity.wsfederation.jaxb.xmlsig.ObjectFactory();
TokenSigningKeyInfoElement tski = objFactory.createTokenSigningKeyInfoElement();
SecurityTokenReferenceElement str = secextObjFactory.createSecurityTokenReferenceElement();
X509DataElement x509Data = dsObjectFactory.createX509DataElement();
X509Certificate x509Cert = dsObjectFactory.createX509DataTypeX509Certificate();
x509Cert.setValue(KeyUtil.getKeyProviderInstance().getX509Certificate(idpSCertAlias).getEncoded());
x509Data.getX509IssuerSerialOrX509SKIOrX509SubjectName().add(x509Cert);
str.getAny().add(x509Data);
tski.setSecurityTokenReference(str);
fed.getAny().add(tski);
}
TokenIssuerNameElement tin = objFactory.createTokenIssuerNameElement();
tin.setValue(entityId);
fed.getAny().add(tin);
TokenIssuerEndpointElement tie = objFactory.createTokenIssuerEndpointElement();
com.sun.identity.wsfederation.jaxb.wsaddr.ObjectFactory addrObjFactory = new com.sun.identity.wsfederation.jaxb.wsaddr.ObjectFactory();
AttributedURIType auri = addrObjFactory.createAttributedURIType();
auri.setValue(url + "/WSFederationServlet" + maStr);
tie.setAddress(auri);
fed.getAny().add(tie);
TokenTypesOfferedElement tto = objFactory.createTokenTypesOfferedElement();
TokenType tt = objFactory.createTokenType();
tt.setUri(WSFederationConstants.URN_OASIS_NAMES_TC_SAML_11);
tto.getTokenType().add(tt);
fed.getAny().add(tto);
UriNamedClaimTypesOfferedElement uncto = objFactory.createUriNamedClaimTypesOfferedElement();
ClaimType ct = objFactory.createClaimType();
ct.setUri(WSFederationConstants.NAMED_CLAIM_TYPES[WSFederationConstants.NAMED_CLAIM_UPN]);
DisplayNameType dnt = objFactory.createDisplayNameType();
dnt.setValue(WSFederationConstants.NAMED_CLAIM_DISPLAY_NAMES[WSFederationConstants.NAMED_CLAIM_UPN]);
ct.setDisplayName(dnt);
uncto.getClaimType().add(ct);
fed.getAny().add(uncto);
}
use of com.sun.identity.wsfederation.jaxb.wsfederation.TokenIssuerNameElement in project OpenAM by OpenRock.
the class CreateWSFedMetaDataTemplate method addWSFedServiceProviderTemplate.
private static void addWSFedServiceProviderTemplate(String entityId, com.sun.identity.wsfederation.jaxb.wsfederation.ObjectFactory objFactory, FederationElement fed, Map mapParams, String url) throws JAXBException {
if (url == null) {
url = getHostURL();
}
String spAlias = (String) mapParams.get(MetaTemplateParameters.P_SP);
String maStr = buildMetaAliasInURI(spAlias);
TokenIssuerNameElement tin = objFactory.createTokenIssuerNameElement();
tin.setValue(entityId);
fed.getAny().add(tin);
TokenIssuerEndpointElement tie = objFactory.createTokenIssuerEndpointElement();
com.sun.identity.wsfederation.jaxb.wsaddr.ObjectFactory addrObjFactory = new com.sun.identity.wsfederation.jaxb.wsaddr.ObjectFactory();
AttributedURIType auri = addrObjFactory.createAttributedURIType();
auri.setValue(url + "/WSFederationServlet" + maStr);
tie.setAddress(auri);
fed.getAny().add(tie);
SingleSignOutNotificationEndpointElement ssne = objFactory.createSingleSignOutNotificationEndpointElement();
AttributedURIType ssneUri = addrObjFactory.createAttributedURIType();
ssneUri.setValue(url + "/WSFederationServlet" + maStr);
ssne.setAddress(auri);
fed.getAny().add(ssne);
}
use of com.sun.identity.wsfederation.jaxb.wsfederation.TokenIssuerNameElement in project OpenAM by OpenRock.
the class WSFedPropertiesModelImpl method setGenAttributeValues.
/**
* Saves the attribute values from the General page.
*
* @param realm to which the entity belongs.
* @param fedId is the entity id.
* @param idpStdValues has the General standard attribute value pairs.
* @param role of the entity ID.
* @param location specifies if the entity is remote or local.
* @throws AMConsoleException if saving of attribute value fails.
*/
public void setGenAttributeValues(String realm, String fedId, Map idpStdValues, String role, String location) throws AMConsoleException {
String tknissEndPt = null;
String tknissName = null;
Iterator it = idpStdValues.entrySet().iterator();
while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next();
Object key = entry.getKey();
Object value = entry.getValue();
if (key.equals(TFTOKENISSUER_ENDPT)) {
HashSet set = (HashSet) idpStdValues.get(key);
Iterator i = set.iterator();
while ((i != null) && (i.hasNext())) {
tknissEndPt = (String) i.next();
}
} else if (key.equals(TFTOKENISSUER_NAME)) {
HashSet set = (HashSet) idpStdValues.get(key);
Iterator i = set.iterator();
while ((i != null) && (i.hasNext())) {
tknissName = (String) i.next();
}
} else if (key.equals(TF_DISPNAME)) {
if (role.equals(EntityModel.SERVICE_PROVIDER)) {
HashSet set = (HashSet) idpStdValues.get(key);
// Get the current map of extended SP values
Map tmpMap = getExtendedValues(role, realm, fedId);
// Replace existing value
tmpMap.put(TF_DISPNAME, set);
setSPExtAttributeValues(realm, fedId, tmpMap, location);
} else if (role.equals(EntityModel.IDENTITY_PROVIDER)) {
HashSet set = (HashSet) idpStdValues.get(key);
// Get the current map of extended IDP values
Map tmpMap = getExtendedValues(role, realm, fedId);
// Replace existing value
tmpMap.put(TF_DISPNAME, set);
setIDPExtAttributeValues(realm, fedId, tmpMap, location);
} else if (role.equals(DUAL)) {
HashSet set = (HashSet) idpStdValues.get(key);
// Get the current map of extended SP values
Map tmpMap = getExtendedValues(EntityModel.SERVICE_PROVIDER, realm, fedId);
// Replace existing value
tmpMap.put(TF_DISPNAME, set);
setSPExtAttributeValues(realm, fedId, tmpMap, location);
// Get the current map of extended IDP values
tmpMap = getExtendedValues(EntityModel.IDENTITY_PROVIDER, realm, fedId);
set = (HashSet) idpStdValues.get(TFIDPDISP_NAME);
// Replace existing value
tmpMap.put(TF_DISPNAME, set);
setIDPExtAttributeValues(realm, fedId, tmpMap, location);
}
}
}
try {
//fedElem is standard metadata federation element under the realm.
WSFederationMetaManager metaManager = getWSFederationMetaManager();
FederationElement fedElem = metaManager.getEntityDescriptor(realm, fedId);
if (fedElem == null) {
if (debug.warningEnabled()) {
debug.warning("WSFedPropertiesModelImpl.setGenAttributeValues:" + " found invalid federation element " + fedId);
}
throw new AMConsoleException("invalid.federation.element");
} else {
for (Iterator iter = fedElem.getAny().iterator(); iter.hasNext(); ) {
Object o = iter.next();
if (o instanceof TokenIssuerEndpointElement) {
((TokenIssuerEndpointElement) o).getAddress().setValue(tknissEndPt);
} else if (o instanceof TokenIssuerNameElement) {
((TokenIssuerNameElement) o).setValue(tknissName);
}
}
metaManager.setFederation(realm, fedElem);
}
} catch (WSFederationMetaException e) {
debug.warning("WSFedPropertiesModelImpl.setGenAttributeValues", e);
throw new AMConsoleException(e.getMessage());
}
}
Aggregations