package com.sun.identity.saml2.assertion;

import com.sun.identity.saml2.assertion.impl.AdviceImpl;
import com.sun.identity.saml2.assertion.impl.AssertionIDRefImpl;
import com.sun.identity.saml2.assertion.impl.AssertionImpl;
import com.sun.identity.saml2.assertion.impl.AttributeImpl;
import com.sun.identity.saml2.assertion.impl.AttributeStatementImpl;
import com.sun.identity.saml2.assertion.impl.AudienceRestrictionImpl;
import com.sun.identity.saml2.assertion.impl.AuthnContextImpl;
import com.sun.identity.saml2.assertion.impl.AuthnStatementImpl;
import com.sun.identity.saml2.assertion.impl.BaseIDImpl;
import com.sun.identity.saml2.assertion.impl.ConditionImpl;
import com.sun.identity.saml2.assertion.impl.ConditionsImpl;
import com.sun.identity.saml2.assertion.impl.EncryptedAssertionImpl;
import com.sun.identity.saml2.assertion.impl.EncryptedAttributeImpl;
import com.sun.identity.saml2.assertion.impl.EncryptedIDImpl;
import com.sun.identity.saml2.assertion.impl.IssuerImpl;
import com.sun.identity.saml2.assertion.impl.NameIDImpl;
import com.sun.identity.saml2.assertion.impl.OneTimeUseImpl;
import com.sun.identity.saml2.assertion.impl.ProxyRestrictionImpl;
import com.sun.identity.saml2.assertion.impl.SubjectConfirmationDataImpl;
import com.sun.identity.saml2.assertion.impl.SubjectConfirmationImpl;
import com.sun.identity.saml2.assertion.impl.SubjectImpl;
import com.sun.identity.saml2.assertion.impl.SubjectLocalityImpl;
import com.sun.identity.saml2.common.SAML2Exception;
import com.sun.identity.saml2.common.SAML2SDKUtils;
import org.w3c.dom.Element;

public class AssertionFactory {
   private static final AssertionFactory INSTANCE = new AssertionFactory();

   private AssertionFactory() {
   }

   public static AssertionFactory getInstance() {
      return INSTANCE;
   }

   public Advice createAdvice(Element elem) throws SAML2Exception {
      Object obj = SAML2SDKUtils.getObjectInstance("Advice", elem);
      return obj == null ? new AdviceImpl(elem) : (Advice)obj;
   }

   public Assertion createAssertion() {
      Object obj = SAML2SDKUtils.getObjectInstance("Assertion");
      return obj == null ? new AssertionImpl() : (Assertion)obj;
   }

   public Assertion createAssertion(Element elem) throws SAML2Exception {
      Object obj = SAML2SDKUtils.getObjectInstance("Assertion", elem);
      return obj == null ? new AssertionImpl(elem) : (Assertion)obj;
   }

   public Assertion createAssertion(String xml) throws SAML2Exception {
      Object obj = SAML2SDKUtils.getObjectInstance("Assertion", xml);
      return obj == null ? new AssertionImpl(xml) : (Assertion)obj;
   }

   public AssertionIDRef createAssertionIDRef(Element elem) throws SAML2Exception {
      Object obj = SAML2SDKUtils.getObjectInstance("AssertionIDRef", elem);
      return obj == null ? new AssertionIDRefImpl(elem) : (AssertionIDRef)obj;
   }

   public AudienceRestriction createAudienceRestriction() {
      Object obj = SAML2SDKUtils.getObjectInstance("AudienceRestriction");
      return obj == null ? new AudienceRestrictionImpl() : (AudienceRestriction)obj;
   }

   public AudienceRestriction createAudienceRestriction(Element elem) throws SAML2Exception {
      Object obj = SAML2SDKUtils.getObjectInstance("AudienceRestriction", elem);
      return obj == null ? new AudienceRestrictionImpl(elem) : (AudienceRestriction)obj;
   }

   public BaseID createBaseID(Element elem) throws SAML2Exception {
      Object obj = SAML2SDKUtils.getObjectInstance("BaseID", elem);
      return obj == null ? new BaseIDImpl(elem) : (BaseID)obj;
   }

   public Condition createCondition(Element elem) {
      Object obj = SAML2SDKUtils.getObjectInstance("Condition", elem);
      return obj == null ? new ConditionImpl(elem) : (Condition)obj;
   }

   public Conditions createConditions() {
      Object obj = SAML2SDKUtils.getObjectInstance("Conditions");
      return obj == null ? new ConditionsImpl() : (Conditions)obj;
   }

   public Conditions createConditions(Element elem) throws SAML2Exception {
      Object obj = SAML2SDKUtils.getObjectInstance("Conditions", elem);
      return obj == null ? new ConditionsImpl(elem) : (Conditions)obj;
   }

   public EncryptedAssertion createEncryptedAssertion(Element elem) throws SAML2Exception {
      Object obj = SAML2SDKUtils.getObjectInstance("EncryptedAssertion", elem);
      return obj == null ? new EncryptedAssertionImpl(elem) : (EncryptedAssertion)obj;
   }

   public EncryptedID createEncryptedID(Element elem) throws SAML2Exception {
      Object obj = SAML2SDKUtils.getObjectInstance("EncryptedID", elem);
      return obj == null ? new EncryptedIDImpl(elem) : (EncryptedID)obj;
   }

   public Issuer createIssuer() {
      Object obj = SAML2SDKUtils.getObjectInstance("Issuer");
      return obj == null ? new IssuerImpl() : (Issuer)obj;
   }

   public Issuer createIssuer(Element elem) throws SAML2Exception {
      Object obj = SAML2SDKUtils.getObjectInstance("Issuer", elem);
      return obj == null ? new IssuerImpl(elem) : (Issuer)obj;
   }

   public Issuer createIssuer(String xml) throws SAML2Exception {
      Object obj = SAML2SDKUtils.getObjectInstance("Issuer", xml);
      return obj == null ? new IssuerImpl(xml) : (Issuer)obj;
   }

   public NameID createNameID() {
      Object obj = SAML2SDKUtils.getObjectInstance("NameID");
      return obj == null ? new NameIDImpl() : (NameID)obj;
   }

   public NameID createNameID(Element elem) throws SAML2Exception {
      Object obj = SAML2SDKUtils.getObjectInstance("NameID", elem);
      return obj == null ? new NameIDImpl(elem) : (NameID)obj;
   }

   public NameID createNameID(String xml) throws SAML2Exception {
      Object obj = SAML2SDKUtils.getObjectInstance("NameID", xml);
      return obj == null ? new NameIDImpl(xml) : (NameID)obj;
   }

   public OneTimeUse createOneTimeUse(Element elem) {
      Object obj = SAML2SDKUtils.getObjectInstance("OneTimeUse", elem);
      return obj == null ? new OneTimeUseImpl(elem) : (OneTimeUse)obj;
   }

   public ProxyRestriction createProxyRestriction(Element elem) throws SAML2Exception {
      Object obj = SAML2SDKUtils.getObjectInstance("ProxyRestriction", elem);
      return obj == null ? new ProxyRestrictionImpl(elem) : (ProxyRestriction)obj;
   }

   public Subject createSubject() {
      Object obj = SAML2SDKUtils.getObjectInstance("Subject");
      return obj == null ? new SubjectImpl() : (Subject)obj;
   }

   public Subject createSubject(Element elem) throws SAML2Exception {
      Object obj = SAML2SDKUtils.getObjectInstance("Subject", elem);
      return obj == null ? new SubjectImpl(elem) : (Subject)obj;
   }

   public SubjectConfirmation createSubjectConfirmation() {
      Object obj = SAML2SDKUtils.getObjectInstance("SubjectConfirmation");
      return obj == null ? new SubjectConfirmationImpl() : (SubjectConfirmation)obj;
   }

   public SubjectConfirmation createSubjectConfirmation(Element elem) throws SAML2Exception {
      Object obj = SAML2SDKUtils.getObjectInstance("SubjectConfirmation", elem);
      return obj == null ? new SubjectConfirmationImpl(elem) : (SubjectConfirmation)obj;
   }

   public SubjectConfirmationData createSubjectConfirmationData() {
      Object obj = SAML2SDKUtils.getObjectInstance("SubjectConfirmationData");
      return obj == null ? new SubjectConfirmationDataImpl() : (SubjectConfirmationData)obj;
   }

   public SubjectConfirmationData createSubjectConfirmationData(Element elem) throws SAML2Exception {
      Object obj = SAML2SDKUtils.getObjectInstance("SubjectConfirmationData", elem);
      return obj == null ? new SubjectConfirmationDataImpl(elem) : (SubjectConfirmationData)obj;
   }

   public Attribute createAttribute() {
      Object obj = SAML2SDKUtils.getObjectInstance("Attribute");
      return obj == null ? new AttributeImpl() : (Attribute)obj;
   }

   public Attribute createAttribute(Element elem) throws SAML2Exception {
      Object obj = SAML2SDKUtils.getObjectInstance("Attribute", elem);
      return obj == null ? new AttributeImpl(elem) : (Attribute)obj;
   }

   public Attribute createAttribute(String xml) throws SAML2Exception {
      Object obj = SAML2SDKUtils.getObjectInstance("Attribute", xml);
      return obj == null ? new AttributeImpl(xml) : (Attribute)obj;
   }

   public AttributeStatement createAttributeStatement() {
      Object obj = SAML2SDKUtils.getObjectInstance("AttributeStatement");
      return obj == null ? new AttributeStatementImpl() : (AttributeStatement)obj;
   }

   public AttributeStatement createAttributeStatement(Element elem) throws SAML2Exception {
      Object obj = SAML2SDKUtils.getObjectInstance("AttributeStatement", elem);
      return obj == null ? new AttributeStatementImpl(elem) : (AttributeStatement)obj;
   }

   public AuthnContext createAuthnContext() {
      Object obj = SAML2SDKUtils.getObjectInstance("AuthnContext");
      return obj == null ? new AuthnContextImpl() : (AuthnContext)obj;
   }

   public AuthnContext createAuthnContext(Element elem) throws SAML2Exception {
      Object obj = SAML2SDKUtils.getObjectInstance("AuthnContext", elem);
      return obj == null ? new AuthnContextImpl(elem) : (AuthnContext)obj;
   }

   public AuthnStatement createAuthnStatement() {
      Object obj = SAML2SDKUtils.getObjectInstance("AuthnStatement");
      return obj == null ? new AuthnStatementImpl() : (AuthnStatement)obj;
   }

   public AuthnStatement createAuthnStatement(Element elem) throws SAML2Exception {
      Object obj = SAML2SDKUtils.getObjectInstance("AuthnStatement", elem);
      return obj == null ? new AuthnStatementImpl(elem) : (AuthnStatement)obj;
   }

   public AuthzDecisionStatement createAuthzDecisionStatement(Element elem) {
      Object obj = SAML2SDKUtils.getObjectInstance("AuthzDecisionStatement", elem);
      return obj == null ? null : (AuthzDecisionStatement)obj;
   }

   public EncryptedAttribute createEncryptedAttribute(Element elem) throws SAML2Exception {
      Object obj = SAML2SDKUtils.getObjectInstance("EncryptedAttribute", elem);
      return obj == null ? new EncryptedAttributeImpl(elem) : (EncryptedAttribute)obj;
   }

   public SubjectLocality createSubjectLocality(Element elem) throws SAML2Exception {
      Object obj = SAML2SDKUtils.getObjectInstance("SubjectLocality", elem);
      return obj == null ? new SubjectLocalityImpl(elem) : (SubjectLocality)obj;
   }
}
