1/*
2 * reserved comment block
3 * DO NOT REMOVE OR ALTER!
4 */
5/**
6 * Licensed to the Apache Software Foundation (ASF) under one
7 * or more contributor license agreements. See the NOTICE file
8 * distributed with this work for additional information
9 * regarding copyright ownership. The ASF licenses this file
10 * to you under the Apache License, Version 2.0 (the
11 * "License"); you may not use this file except in compliance
12 * with the License. You may obtain a copy of the License at
13 *
14 * http://www.apache.org/licenses/LICENSE-2.0
15 *
16 * Unless required by applicable law or agreed to in writing,
17 * software distributed under the License is distributed on an
18 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19 * KIND, either express or implied. See the License for the
20 * specific language governing permissions and limitations
21 * under the License.
22 */
23
24package com.sun.org.apache.xml.internal.security.utils.resolver.implementations;
25
26import java.io.FileInputStream;
27import java.io.FileNotFoundException;
28import java.io.IOException;
29import java.io.InputStream;
30
31import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
32import com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolverContext;
33import com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolverSpi;
34
35/**
36 * @author $Author: coheigea $
37 */
38public class ResolverAnonymous extends ResourceResolverSpi {
39
40    private InputStream inStream = null;
41
42    @Override
43    public boolean engineIsThreadSafe() {
44        return true;
45    }
46
47    /**
48     * @param filename
49     * @throws FileNotFoundException
50     * @throws IOException
51     */
52    public ResolverAnonymous(String filename) throws FileNotFoundException, IOException {
53        inStream = new FileInputStream(filename);
54    }
55
56    /**
57     * @param is
58     */
59    public ResolverAnonymous(InputStream is) {
60        inStream = is;
61    }
62
63    /** @inheritDoc */
64    @Override
65    public XMLSignatureInput engineResolveURI(ResourceResolverContext context) {
66        return new XMLSignatureInput(inStream);
67    }
68
69    /**
70     * @inheritDoc
71     */
72    @Override
73    public boolean engineCanResolveURI(ResourceResolverContext context) {
74        if (context.uriToResolve == null) {
75            return true;
76        }
77        return false;
78    }
79
80    /** @inheritDoc */
81    public String[] engineGetPropertyKeys() {
82        return new String[0];
83    }
84}
85