Author: anil.saldhana(a)jboss.com
Date: 2011-01-31 18:09:57 -0500 (Mon, 31 Jan 2011)
New Revision: 689
Modified:
picketlink-seam/trunk/picketlink-seam/src/main/java/org/picketlink/identity/seam/federation/configuration/SamlIdentityProvider.java
Log:
use metadata extractor
Modified:
picketlink-seam/trunk/picketlink-seam/src/main/java/org/picketlink/identity/seam/federation/configuration/SamlIdentityProvider.java
===================================================================
---
picketlink-seam/trunk/picketlink-seam/src/main/java/org/picketlink/identity/seam/federation/configuration/SamlIdentityProvider.java 2011-01-31
23:05:50 UTC (rev 688)
+++
picketlink-seam/trunk/picketlink-seam/src/main/java/org/picketlink/identity/seam/federation/configuration/SamlIdentityProvider.java 2011-01-31
23:09:57 UTC (rev 689)
@@ -22,19 +22,15 @@
package org.picketlink.identity.seam.federation.configuration;
import java.security.PublicKey;
+import java.security.cert.X509Certificate;
import java.util.HashMap;
import java.util.Map;
-import javax.security.cert.X509Certificate;
-
-import org.picketlink.identity.federation.core.saml.v2.util.DocumentUtil;
+import org.picketlink.identity.federation.api.saml.v2.metadata.MetaDataExtractor;
import
org.picketlink.identity.federation.newmodel.saml.v2.metadata.IDPSSODescriptorType;
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.KeyDescriptorType;
import org.picketlink.identity.federation.newmodel.saml.v2.metadata.KeyTypes;
import org.picketlink.identity.seam.federation.SamlProfile;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
/**
* @author Marcel Kolsteren
@@ -69,46 +65,11 @@
{
if (keyDescriptor.getUse().equals(KeyTypes.SIGNING))
{
- Element elem = keyDescriptor.getKeyInfo();
- if( elem != null )
+ X509Certificate cert = MetaDataExtractor.getCertificate(keyDescriptor);
+ if( cert != null )
{
- NodeList x509DataNodes = elem.getElementsByTagName( "X509Data"
);
- if( x509DataNodes != null && x509DataNodes.getLength() > 0 )
- {
- //Choose the first one
- Node x509DataNode = x509DataNodes.item(0);
- NodeList children = x509DataNode.getChildNodes();
- int len = children != null ? children.getLength() : 0 ;
- for( int i = 0 ; i < len ; i++ )
- {
- Node nl = children.item(i);
- if( nl.getNodeName().contains( "X509Certificate" ) )
- {
- byte[] certificate = null ;
- try
- {
- certificate = DocumentUtil.getNodeAsString(nl).getBytes();
- }
- catch ( Exception e )
- {
- throw new RuntimeException( e );
- }
- try
- {
- X509Certificate cert =
X509Certificate.getInstance(certificate);
- publicKey = cert.getPublicKey();
- }
- catch (javax.security.cert.CertificateException e)
- {
- throw new RuntimeException(e);
- }
- break;
- }
-
- }
-
- }
- }
+ publicKey = cert.getPublicKey();
+ }
/*for (Object content : keyDescriptor.getKeyInfo() )
{
Show replies by date