use of com.sun.identity.saml2.assertion.AssertionIDRef in project OpenAM by OpenRock.
the class AdviceImpl method toXMLString.
/**
* Returns a String representation
* @param includeNSPrefix Determines whether or not the namespace
* qualifier is prepended to the Element when converted
* @param declareNS Determines whether or not the namespace is
* declared within the Element.
* @return A String representation
* @exception SAML2Exception if something is wrong during conversion
*/
public String toXMLString(boolean includeNSPrefix, boolean declareNS) throws SAML2Exception {
StringBuffer sb = new StringBuffer(2000);
String NS = "";
String appendNS = "";
if (declareNS) {
NS = SAML2Constants.ASSERTION_DECLARE_STR;
}
if (includeNSPrefix) {
appendNS = SAML2Constants.ASSERTION_PREFIX;
}
sb.append("<").append(appendNS).append(ADVICE_ELEMENT).append(NS).append(">\n");
int length = 0;
if (assertionIDRefs != null) {
length = assertionIDRefs.size();
for (int i = 0; i < length; i++) {
AssertionIDRef assertionIDRef = (AssertionIDRef) assertionIDRefs.get(i);
sb.append(assertionIDRef.toXMLString(includeNSPrefix, false));
}
}
if (assertionURIRefs != null) {
length = assertionURIRefs.size();
for (int i = 0; i < length; i++) {
String str = (String) assertionURIRefs.get(i);
sb.append("<").append(appendNS).append(ASSERTION_URI_REF_ELEMENT).append(">").append(str).append("</").append(appendNS).append(ASSERTION_URI_REF_ELEMENT).append(">\n");
}
}
if (assertions != null) {
length = assertions.size();
for (int i = 0; i < length; i++) {
Assertion assertion = (Assertion) assertions.get(i);
sb.append(assertion.toXMLString(includeNSPrefix, false));
}
}
if (encryptedAssertions != null) {
length = encryptedAssertions.size();
for (int i = 0; i < length; i++) {
EncryptedAssertion ea = (EncryptedAssertion) encryptedAssertions.get(i);
sb.append(ea.toXMLString(includeNSPrefix, false));
}
}
if (additionalInfo != null) {
length = additionalInfo.size();
for (int i = 0; i < length; i++) {
String str = (String) additionalInfo.get(i);
sb.append(str).append("\n");
}
}
sb.append("</").append(appendNS).append(ADVICE_ELEMENT).append(">");
return sb.toString();
}
use of com.sun.identity.saml2.assertion.AssertionIDRef in project OpenAM by OpenRock.
the class AssertionIDRequestImpl method parseDOMChileElements.
/**
* Parses child elements of the Docuemnt Element for this object.
*
* @param iter the child elements iterator.
* @throws SAML2Exception if error parsing the Document Element.
*/
protected void parseDOMChileElements(ListIterator iter) throws SAML2Exception {
super.parseDOMChileElements(iter);
AssertionFactory aFactory = AssertionFactory.getInstance();
while (iter.hasNext()) {
Element childElement = (Element) iter.next();
String localName = childElement.getLocalName();
if (SAML2Constants.ASSERTION_ID_REF.equals(localName)) {
AssertionIDRef assertionIDRef = aFactory.createAssertionIDRef(childElement);
if (assertionIDRefs == null) {
assertionIDRefs = new ArrayList();
}
assertionIDRefs.add(assertionIDRef);
} else {
iter.previous();
break;
}
}
if (assertionIDRefs == null) {
throw new SAML2Exception(SAML2Utils.bundle.getString("schemaViolation"));
}
}
use of com.sun.identity.saml2.assertion.AssertionIDRef in project OpenAM by OpenRock.
the class AssertionIDRequestImpl method getXMLString.
protected void getXMLString(Set namespaces, StringBuffer attrs, StringBuffer childElements, boolean includeNSPrefix, boolean declareNS) throws SAML2Exception {
validateData();
if (declareNS) {
namespaces.add(SAML2Constants.PROTOCOL_DECLARE_STR.trim());
namespaces.add(SAML2Constants.ASSERTION_DECLARE_STR.trim());
}
super.getXMLString(namespaces, attrs, childElements, includeNSPrefix, declareNS);
for (Iterator iter = assertionIDRefs.iterator(); iter.hasNext(); ) {
AssertionIDRef assertionIDRef = (AssertionIDRef) iter.next();
childElements.append(assertionIDRef.toXMLString(includeNSPrefix, declareNS)).append(SAML2Constants.NEWLINE);
}
}
use of com.sun.identity.saml2.assertion.AssertionIDRef in project OpenAM by OpenRock.
the class AdviceImpl method makeImmutable.
/**
* Makes the object immutable
*/
public void makeImmutable() {
if (isMutable) {
if (assertions != null) {
int length = assertions.size();
for (int i = 0; i < length; i++) {
Assertion assertion = (Assertion) assertions.get(i);
assertion.makeImmutable();
}
assertions = Collections.unmodifiableList(assertions);
}
if (encryptedAssertions != null) {
encryptedAssertions = Collections.unmodifiableList(encryptedAssertions);
}
if (assertionIDRefs != null) {
int length = assertionIDRefs.size();
for (int i = 0; i < length; i++) {
AssertionIDRef assertionIDRef = (AssertionIDRef) assertionIDRefs.get(i);
assertionIDRef.makeImmutable();
}
assertionIDRefs = Collections.unmodifiableList(assertionIDRefs);
}
if (assertionURIRefs != null) {
assertionURIRefs = Collections.unmodifiableList(assertionURIRefs);
}
if (additionalInfo != null) {
additionalInfo = Collections.unmodifiableList(additionalInfo);
}
isMutable = false;
}
}
use of com.sun.identity.saml2.assertion.AssertionIDRef in project OpenAM by OpenRock.
the class AssertionIDRefImpl method parseElement.
private void parseElement(Element element) throws SAML2Exception {
if (element == null) {
SAML2Utils.debug.message("AssertionIDRefImpl.parseElement:" + " Input is null.");
throw new SAML2Exception(SAML2Utils.bundle.getString("nullInput"));
}
String tag = element.getLocalName();
if (!SAML2Constants.ASSERTION_ID_REF.equals(tag)) {
SAML2Utils.debug.message("AssertionIDRefImpl.parseElement: " + "Element local name is not AssertionIDRef.");
throw new SAML2Exception(SAML2Utils.bundle.getString("wrongInput"));
}
NodeList nodes = element.getChildNodes();
int nodeCount = nodes.getLength();
if (nodeCount > 0) {
for (int i = 0; i < nodeCount; i++) {
Node currentNode = nodes.item(i);
if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
if (SAML2Utils.debug.messageEnabled()) {
SAML2Utils.debug.message("AssertionIDRefImpl.parseElement: " + "AssertionIDRef can't have child element.");
}
throw new SAML2Exception(SAML2Utils.bundle.getString("wrongInput"));
}
}
}
value = XMLUtils.getElementValue(element);
if ((value == null) || (value.trim().length() == 0)) {
if (SAML2Utils.debug.messageEnabled()) {
SAML2Utils.debug.message("AssertionIDRefImpl.parseElement: " + "AssertionIDRef value is null or empty.");
}
throw new SAML2Exception(SAML2Utils.bundle.getString("emptyElementValue"));
}
mutable = false;
}
Aggregations