1
+ /*
2
+ * JBoss, Home of Professional Open Source
3
+ *
4
+ * Copyright 2013 Red Hat, Inc. and/or its affiliates.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+ package org .picketlink .identity .federation .api .saml .api ;
19
+
20
+ import org .picketlink .common .exceptions .ConfigurationException ;
21
+ import org .picketlink .common .exceptions .ParsingException ;
22
+ import org .picketlink .identity .federation .core .parsers .saml .SAMLParser ;
23
+ import org .picketlink .identity .federation .core .saml .v2 .util .AssertionUtil ;
24
+ import org .picketlink .identity .federation .saml .v2 .assertion .AssertionType ;
25
+
26
+ import java .io .ByteArrayInputStream ;
27
+ import java .io .IOException ;
28
+
29
+ /**
30
+ * Client API for SAML
31
+ * @author Anil Saldhana
32
+ * @since June 12, 2014
33
+ */
34
+ public class SAMLClient {
35
+ /**
36
+ * Given an assertion as a string, parse into {@link org.picketlink.identity.federation.saml.v2.assertion.AssertionType}
37
+ * @param assertionAsString
38
+ * @return
39
+ * @throws IOException
40
+ * @throws ParsingException
41
+ */
42
+ public AssertionType parseAssertion (String assertionAsString ) throws IOException , ParsingException {
43
+ SAMLParser samlParser = new SAMLParser ();
44
+ return (AssertionType ) samlParser .parse (new ByteArrayInputStream (assertionAsString .getBytes ("UTF-8" )));
45
+ }
46
+
47
+ /**
48
+ * Verify whether an {@link org.picketlink.identity.federation.saml.v2.assertion.AssertionType} has expired
49
+ * @param assertionType
50
+ * @return
51
+ * @throws ConfigurationException
52
+ */
53
+ public boolean hasExpired (AssertionType assertionType ) throws ConfigurationException {
54
+ return AssertionUtil .hasExpired (assertionType );
55
+ }
56
+ }
0 commit comments