예제 #1
0
 protected AbstractMetadataProvider idpMetadataProvider(ParserPool parserPool) {
   AbstractMetadataProvider idpMetadataProvider;
   try {
     if (idpMetadataPath != null) {
       Resource resource = null;
       if (this.idpMetadataPath.startsWith(CommonHelper.RESOURCE_PREFIX)) {
         String path = this.idpMetadataPath.substring(CommonHelper.RESOURCE_PREFIX.length());
         if (!path.startsWith("/")) {
           path = "/" + path;
         }
         resource = new ClasspathResource(path);
       } else {
         resource = new FilesystemResource(this.idpMetadataPath);
       }
       idpMetadataProvider = new ResourceBackedMetadataProvider(new Timer(true), resource);
     } else {
       InputStream in = new ByteArrayInputStream(idpMetadata.getBytes());
       Document inCommonMDDoc = parserPool.parse(in);
       Element metadataRoot = inCommonMDDoc.getDocumentElement();
       idpMetadataProvider = new DOMMetadataProvider(metadataRoot);
     }
     idpMetadataProvider.setParserPool(parserPool);
     idpMetadataProvider.initialize();
   } catch (MetadataProviderException e) {
     throw new SamlException("Error initializing idpMetadataProvider", e);
   } catch (XMLParserException e) {
     throw new TechnicalException("Error parsing idp Metadata", e);
   } catch (ResourceException e) {
     throw new TechnicalException("Error getting idp Metadata resource", e);
   }
   return idpMetadataProvider;
 }
  /**
   * Gets the authentication request object.
   *
   * @return the authentication request object
   * @throws UnmarshallingException thrown if there is a problem unmarshalling the serialized form
   *     of the request
   */
  public synchronized AuthnRequest getAuthenticiationRequestXmlObject()
      throws UnmarshallingException {
    if (authnRequest == null) {
      try {
        ParserPool parser = Configuration.getParserPool();
        Document requestDoc = parser.parse(new StringReader(serialAuthnRequest));
        Unmarshaller requestUnmarshaller =
            Configuration.getUnmarshallerFactory().getUnmarshaller(AuthnRequest.TYPE_NAME);
        authnRequest =
            (AuthnRequest) requestUnmarshaller.unmarshall(requestDoc.getDocumentElement());
      } catch (XMLParserException e) {
        throw new UnmarshallingException(
            "Unable to unmarshall serialized authentication request", e);
      }
    }

    return authnRequest;
  }