use of com.sun.identity.saml.common.SAMLException in project OpenAM by OpenRock.
the class QueryResponse method parseCreds.
private void parseCreds(Element elem) throws DiscoveryException {
NodeList contentnl = elem.getChildNodes();
Node child;
String nodeName;
SecurityAssertion assertion;
for (int i = 0, length = contentnl.getLength(); i < length; i++) {
child = contentnl.item(i);
if ((nodeName = child.getLocalName()) != null) {
try {
assertion = new SecurityAssertion((Element) child);
} catch (SAMLException se) {
if (DiscoUtils.debug.messageEnabled()) {
DiscoUtils.debug.message("QueryResponse(Element): " + "Exception thrown when parsing Credentials:", se);
}
throw new DiscoveryException(DiscoUtils.bundle.getString("wrongCredential"));
}
if (creds == null) {
creds = new ArrayList();
}
creds.add(assertion);
}
}
}
use of com.sun.identity.saml.common.SAMLException in project OpenAM by OpenRock.
the class Attribute method addAttributeValue.
/**
* Adds <code>AttributeValue</code> to the Attribute.
*
* @param value A String representing <code>AttributeValue</code>.
* @exception SAMLException
*/
public void addAttributeValue(String value) throws SAMLException {
if (value == null || value.length() == 0) {
if (SAMLUtilsCommon.debug.messageEnabled()) {
SAMLUtilsCommon.debug.message("addAttributeValue: Input is null");
}
throw new SAMLRequesterException(SAMLUtilsCommon.bundle.getString("nullInput"));
}
StringBuffer sb = new StringBuffer(300);
sb.append("<").append(SAMLConstants.ASSERTION_PREFIX).append("AttributeValue").append(SAMLConstants.assertionDeclareStr).append(">").append(value).append("</").append(SAMLConstants.ASSERTION_PREFIX).append("AttributeValue>");
try {
Element ele = XMLUtils.toDOMDocument(sb.toString().trim(), SAMLUtilsCommon.debug).getDocumentElement();
if (_attributeValue == null) {
_attributeValue = new ArrayList();
}
if (!(_attributeValue.add(ele))) {
if (SAMLUtilsCommon.debug.messageEnabled()) {
SAMLUtilsCommon.debug.message("Attribute: failed to " + "add to the attribute value list.");
}
throw new SAMLRequesterException(SAMLUtilsCommon.bundle.getString("addListError"));
}
} catch (Exception e) {
SAMLUtilsCommon.debug.error("addAttributeValue error", e);
throw new SAMLRequesterException("Exception in addAttributeValue" + e.getMessage());
}
}
use of com.sun.identity.saml.common.SAMLException in project OpenAM by OpenRock.
the class AssertionManagerClient method getAssertion.
/**
* Returns assertion associated with the <code>AssertionArtifact</code>.
* @param artifact An <code>AssertionArtifact</code>.
* @param destID The destination site requesting the assertion using
* the artifact. This String is compared with the
* <code>destID</code> that the artifact is created for originally.
* @return The Assertion referenced to by artifact.
* @throws SAMLException If an error occurred during the process, or no
* assertion maps to the input artifact.
*/
protected Assertion getAssertion(AssertionArtifact artifact, String destID) throws SAMLException {
if (useLocal) {
return (assertionManager.getAssertion(artifact, destID));
}
String assertion = null;
try {
Object[] args = { artifact.getAssertionArtifact(), Base64.encode(SAMLUtils.stringToByteArray(destID)) };
assertion = (String) stub.send("getAssertion2", args, null, null);
return (new Assertion(XMLUtils.toDOMDocument(assertion, SAMLUtils.debug).getDocumentElement()));
} catch (Exception re) {
if (SAMLUtils.debug.warningEnabled()) {
SAMLUtils.debug.warning("AMC:getAssertion: " + artifact, re);
}
throw (new SAMLException(re.getMessage()));
}
}
use of com.sun.identity.saml.common.SAMLException in project OpenAM by OpenRock.
the class AssertionManagerClient method createAssertionArtifact.
/**
* Returns an <code>AssertionArtifact</code> for the given <code>
* Assertion</code>.
* @param assertion The Assertion for which an Artifact needs to be
* created.
* @param target The <code>sourceID</code> of the site for which the
* <code>AssertionArtifact</code> is created. It is in raw String
* format (not Base64 encoded, for example.) This String can be
* obtained from converting the 20 bytes sequence to char Array,
* then from the char Array to String.
* @return <code>AssertionArtifact</code>
* @throws SAMLException if the <code>AssertionArtifact</code> cannot be
* created.
*/
public AssertionArtifact createAssertionArtifact(Assertion assertion, String target) throws SAMLException {
if (useLocal) {
return (assertionManager.createAssertionArtifact(assertion, target));
}
String aa = null;
try {
Object[] args = { assertion.toString(true, true), Base64.encode(SAMLUtils.stringToByteArray(target)) };
aa = (String) stub.send("createAssertionArtifact", args, null, null);
return (new AssertionArtifact(aa));
} catch (Exception re) {
if (SAMLUtils.debug.warningEnabled()) {
SAMLUtils.debug.warning("AMC:createAssertionArtifact:", re);
}
throw (new SAMLException(re.getMessage()));
}
}
use of com.sun.identity.saml.common.SAMLException in project OpenAM by OpenRock.
the class AssertionManagerClient method getAssertion.
/**
* Returns assertion associated with the <code>AssertionArtifact</code>.
* @param artifact An <code>AssertionArtifact</code>.
* @param destID A Set of String that represents the destination id.
* The destination site requesting the assertion using the
* artifact. This String is compared with the <code>destID</code>
* that the artifact is created for originally. This field must not
* be null or empty set.
* @return The Assertion referenced to by artifact.
* @throws SAMLException If an error occurred during the process, or no
* assertion maps to the input artifact.
*/
public Assertion getAssertion(AssertionArtifact artifact, Set destID) throws SAMLException {
if (useLocal) {
return (assertionManager.getAssertion(artifact, destID));
}
String assertion = null;
try {
if (destID == null || destID.isEmpty()) {
SAMLUtils.debug.error("AssertionManagerClient:getAssertion(" + "AssertionArtifact, Set): destID set is null");
throw new SAMLException("nullInput");
}
Set destSet = new HashSet();
Iterator it = destID.iterator();
while (it.hasNext()) {
destSet.add(Base64.encode(SAMLUtils.stringToByteArray((String) it.next())));
}
Object[] args = { artifact.getAssertionArtifact(), destSet };
assertion = (String) stub.send("getAssertion", args, null, null);
return (new Assertion(XMLUtils.toDOMDocument(assertion, SAMLUtils.debug).getDocumentElement()));
} catch (Exception re) {
if (SAMLUtils.debug.warningEnabled()) {
SAMLUtils.debug.warning("AMC:getAssertion: " + artifact, re);
}
throw (new SAMLException(re.getMessage()));
}
}
Aggregations