summaryrefslogtreecommitdiff
path: root/utils/src/main/java/at/gv/egiz/idlink
diff options
context:
space:
mode:
authorclemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2009-01-20 17:01:09 +0000
committerclemenso <clemenso@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2009-01-20 17:01:09 +0000
commita7d404cd6db2724d36523e59c87c3007fa86a258 (patch)
treee938b10cccf606c062fdb4cf569b8245a83b8a37 /utils/src/main/java/at/gv/egiz/idlink
parentc97c49eb4399829603816e4b3e47c74b67d0f27b (diff)
parentce598ba5142ff7673085dd90865f9323d69574be (diff)
downloadmocca-1.0.2.tar.gz
mocca-1.0.2.tar.bz2
mocca-1.0.2.zip
[maven-release-plugin] copy for tag mocca-1.0.2mocca-1.0.2
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/tags/mocca-1.0.2@276 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'utils/src/main/java/at/gv/egiz/idlink')
-rw-r--r--utils/src/main/java/at/gv/egiz/idlink/IdentityLinkFactory.java213
1 files changed, 110 insertions, 103 deletions
diff --git a/utils/src/main/java/at/gv/egiz/idlink/IdentityLinkFactory.java b/utils/src/main/java/at/gv/egiz/idlink/IdentityLinkFactory.java
index a5ceeafc..fb7943dc 100644
--- a/utils/src/main/java/at/gv/egiz/idlink/IdentityLinkFactory.java
+++ b/utils/src/main/java/at/gv/egiz/idlink/IdentityLinkFactory.java
@@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package at.gv.egiz.idlink;
-
+package at.gv.egiz.idlink;
+
import iaik.xml.crypto.XmldsigMore;
import java.io.InputStreamReader;
@@ -81,6 +81,7 @@ import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
+import at.gv.e_government.reference.namespace.persondata._20020228_.AbstractPersonType;
import at.gv.e_government.reference.namespace.persondata._20020228_.IdentificationType;
import at.gv.e_government.reference.namespace.persondata._20020228_.PersonNameType;
import at.gv.e_government.reference.namespace.persondata._20020228_.PhysicalPersonType;
@@ -88,63 +89,64 @@ import at.gv.e_government.reference.namespace.persondata._20020228_.Identificati
import at.gv.e_government.reference.namespace.persondata._20020228_.PersonNameType.FamilyName;
import at.gv.egiz.xmldsig.KeyTypeNotSupportedException;
import at.gv.egiz.xmldsig.KeyValueFactory;
-
+import oasis.names.tc.saml._1_0.assertion.AnyType;
+
public class IdentityLinkFactory {
- private static Log log = LogFactory.getLog(IdentityLinkFactory.class);
-
- /**
- * The instance returned by {@link #getInstance()}.
- */
- private static IdentityLinkFactory instance;
-
- /**
- * The <code>JAXBContext</code>.
- */
- private static JAXBContext jaxbContext;
-
- /**
- * The <code>KeyValueFactory</code>.
- */
- private static KeyValueFactory keyValueFactory;
-
- /**
- * Get an instance of this <code>CompressedIdentityLinkFactory</code>.
- *
- * @return an instance of this <code>CompressedIdentityLinkFactory</code>
- */
- public synchronized static IdentityLinkFactory getInstance() {
- if (instance == null) {
- instance = new IdentityLinkFactory();
- }
- return instance;
- }
-
- /**
- * Private constructor.
- */
- private IdentityLinkFactory() {
-
- keyValueFactory = new KeyValueFactory();
-
- StringBuffer packageNames = new StringBuffer();
- packageNames.append(at.gv.e_government.reference.namespace.persondata._20020228_.ObjectFactory.class.getPackage().getName());
- packageNames.append(":");
- packageNames.append(org.w3._2000._09.xmldsig_.ObjectFactory.class.getPackage().getName());
- packageNames.append(":");
- packageNames.append(org.w3._2001._04.xmldsig_more_.ObjectFactory.class.getPackage().getName());
- packageNames.append(":");
- packageNames.append(at.buergerkarte.namespaces.personenbindung._20020506_.ObjectFactory.class.getPackage().getName());
+ private static Log log = LogFactory.getLog(IdentityLinkFactory.class);
+
+ /**
+ * The instance returned by {@link #getInstance()}.
+ */
+ private static IdentityLinkFactory instance;
+
+ /**
+ * The <code>JAXBContext</code>.
+ */
+ private static JAXBContext jaxbContext;
+
+ /**
+ * The <code>KeyValueFactory</code>.
+ */
+ private static KeyValueFactory keyValueFactory;
+
+ /**
+ * Get an instance of this <code>CompressedIdentityLinkFactory</code>.
+ *
+ * @return an instance of this <code>CompressedIdentityLinkFactory</code>
+ */
+ public synchronized static IdentityLinkFactory getInstance() {
+ if (instance == null) {
+ instance = new IdentityLinkFactory();
+ }
+ return instance;
+ }
+
+ /**
+ * Private constructor.
+ */
+ private IdentityLinkFactory() {
+
+ keyValueFactory = new KeyValueFactory();
+
+ StringBuffer packageNames = new StringBuffer();
+ packageNames.append(at.gv.e_government.reference.namespace.persondata._20020228_.ObjectFactory.class.getPackage().getName());
+ packageNames.append(":");
+ packageNames.append(org.w3._2000._09.xmldsig_.ObjectFactory.class.getPackage().getName());
+ packageNames.append(":");
+ packageNames.append(org.w3._2001._04.xmldsig_more_.ObjectFactory.class.getPackage().getName());
+ packageNames.append(":");
+ packageNames.append(at.buergerkarte.namespaces.personenbindung._20020506_.ObjectFactory.class.getPackage().getName());
packageNames.append(":");
packageNames.append(oasis.names.tc.saml._1_0.assertion.ObjectFactory.class.getPackage().getName());
-
- try {
- jaxbContext = JAXBContext.newInstance(packageNames.toString());
- } catch (JAXBException e) {
- // we should not get an JAXBException initializing the JAXBContext
- throw new RuntimeException(e);
- }
-
+
+ try {
+ jaxbContext = JAXBContext.newInstance(packageNames.toString());
+ } catch (JAXBException e) {
+ // we should not get an JAXBException initializing the JAXBContext
+ throw new RuntimeException(e);
+ }
+
}
public JAXBElement<AssertionType> createAssertion(String assertionId,
@@ -175,11 +177,11 @@ public class IdentityLinkFactory {
return asFactory.createAssertion(assertionType);
- }
-
+ }
+
public AttributeStatementType createAttributeStatement(String idValue, String idType,
String givenName, String familyName, String dateOfBirth,
- PublicKey[] publicKeys) throws KeyTypeNotSupportedException {
+ PublicKey[] publicKeys) throws KeyTypeNotSupportedException {
oasis.names.tc.saml._1_0.assertion.ObjectFactory asFactory =
new oasis.names.tc.saml._1_0.assertion.ObjectFactory();
@@ -215,8 +217,11 @@ public class IdentityLinkFactory {
physicalPersonType.getIdentification().add(identificationType);
physicalPersonType.setName(personNameType);
physicalPersonType.setDateOfBirth(dateOfBirth);
-
- subjectConfirmationType.setSubjectConfirmationData(physicalPersonType);
+ JAXBElement<AbstractPersonType> physicalPerson = prFactory.createPerson(physicalPersonType);
+
+ AnyType personType = asFactory.createAnyType();
+ personType.getContent().add(physicalPerson);
+ subjectConfirmationType.setSubjectConfirmationData(personType);
JAXBElement<SubjectConfirmationType> subjectConfirmation = asFactory.createSubjectConfirmation(subjectConfirmationType);
@@ -232,52 +237,54 @@ public class IdentityLinkFactory {
AttributeType attributeType = asFactory.createAttributeType();
attributeType.setAttributeName("CitizenPublicKey");
attributeType.setAttributeNamespace("urn:publicid:gv.at:namespaces:identitylink:1.2");
- attributeType.getAttributeValue().add(createKeyValue.getValue());
+ AnyType attributeValueType = asFactory.createAnyType();
+ attributeValueType.getContent().add(createKeyValue);
+ attributeType.getAttributeValue().add(attributeValueType);
attributeStatementType.getAttribute().add(attributeType);
}
return attributeStatementType;
- }
-
- /**
- * Marshall the given <code>compressedIdentityLink</code> into a DOM document
- * with the given Nodes as <code>parent</code> and <code>nextSibling</code>
- * nodes.
- *
- * @param identityLink
- * the <code>CompressedIdentityLink</code> element
- * @param parent
- * the parent node
- * @param nextSibling
- * the next sibling node (may be <code>null</code>)
- * @param applyWorkarounds
- * apply workarounds as spefiyed by
- * {@link #applyWorkarounds(Element, int)}
- *
- * @throws JAXBException
- * if an unexpected error occurs while marshalling
- * @throws NullPointerException
- * if <code>compressdIdentityLink</code> or <code>parent</code> is
- * <code>null</code>
- */
- public void marshallIdentityLink(
- JAXBElement<AssertionType> identityLink,
- Node parent, Node nextSibling) throws JAXBException {
-
- DOMResult result = new DOMResult(parent, nextSibling);
-
- try {
- Marshaller marshaller = jaxbContext.createMarshaller();
-
- marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
-
- marshaller.marshal(identityLink, result);
- } catch (PropertyException e) {
- throw new RuntimeException(e);
- }
-
+ }
+
+ /**
+ * Marshall the given <code>compressedIdentityLink</code> into a DOM document
+ * with the given Nodes as <code>parent</code> and <code>nextSibling</code>
+ * nodes.
+ *
+ * @param identityLink
+ * the <code>CompressedIdentityLink</code> element
+ * @param parent
+ * the parent node
+ * @param nextSibling
+ * the next sibling node (may be <code>null</code>)
+ * @param applyWorkarounds
+ * apply workarounds as spefiyed by
+ * {@link #applyWorkarounds(Element, int)}
+ *
+ * @throws JAXBException
+ * if an unexpected error occurs while marshalling
+ * @throws NullPointerException
+ * if <code>compressdIdentityLink</code> or <code>parent</code> is
+ * <code>null</code>
+ */
+ public void marshallIdentityLink(
+ JAXBElement<AssertionType> identityLink,
+ Node parent, Node nextSibling) throws JAXBException {
+
+ DOMResult result = new DOMResult(parent, nextSibling);
+
+ try {
+ Marshaller marshaller = jaxbContext.createMarshaller();
+
+ marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
+
+ marshaller.marshal(identityLink, result);
+ } catch (PropertyException e) {
+ throw new RuntimeException(e);
+ }
+
}
public void signIdentityLink(Element assertion, X509Certificate certificate,
@@ -416,6 +423,6 @@ public class IdentityLinkFactory {
log.trace(sb.toString());
}
- }
-
-}
+ }
+
+}