| <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../.resources/report.css" type="text/css"/><link rel="shortcut icon" href="../.resources/report.gif" type="image/gif"/><title>SAML1AssertionHandler.java</title><link rel="stylesheet" href="../.resources/prettify.css" type="text/css"/><script type="text/javascript" src="../.resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="right"><a href="../.sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Coverage Report</a> > <a href="index.html" class="el_package">org.apache.rampart.saml</a> > <span class="el_source">SAML1AssertionHandler.java</span></div><h1>SAML1AssertionHandler.java</h1><pre class="source lang-java linenums">/* |
| * Copyright (c) The Apache Software Foundation. |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| |
| package org.apache.rampart.saml; |
| |
| import org.apache.axiom.om.OMElement; |
| import org.apache.rahas.RahasConstants; |
| import org.apache.rahas.TrustException; |
| import org.apache.rahas.impl.util.SAMLUtils; |
| import org.apache.rampart.TokenCallbackHandler; |
| import org.apache.ws.security.WSDocInfo; |
| import org.apache.ws.security.WSSecurityException; |
| import org.apache.ws.security.components.crypto.Crypto; |
| import org.apache.ws.security.handler.RequestData; |
| import org.apache.ws.security.saml.SAMLKeyInfo; |
| import org.apache.ws.security.saml.SAMLUtil; |
| import org.opensaml.saml1.core.Assertion; |
| import org.opensaml.saml1.core.Conditions; |
| |
| /** |
| * This class handles SAML1 assertions.Processes SAML1 assertion and will extract SAML1 attributes |
| * such as assertion id, start date, end date etc ... |
| */ |
| public class SAML1AssertionHandler extends SAMLAssertionHandler{ |
| |
| private Assertion assertion; |
| |
| <span class="nc" id="L41"> public SAML1AssertionHandler(Assertion saml1Assertion) {</span> |
| <span class="nc" id="L42"> this.assertion = saml1Assertion;</span> |
| <span class="nc" id="L43"> this.processSAMLAssertion();</span> |
| <span class="nc" id="L44"> }</span> |
| |
| @Override |
| public boolean isBearerAssertion() { |
| <span class="nc" id="L48"> return RahasConstants.SAML11_SUBJECT_CONFIRMATION_BEARER.equals(</span> |
| SAMLUtils.getSAML11SubjectConfirmationMethod(assertion)); |
| } |
| |
| @Override |
| protected void processSAMLAssertion() { |
| |
| <span class="nc" id="L55"> this.setAssertionId(assertion.getID());</span> |
| |
| //Read the validity period from the 'Conditions' element, else read it from SC Data |
| <span class="nc bnc" id="L58" title="All 2 branches missed."> if (assertion.getConditions() != null) {</span> |
| <span class="nc" id="L59"> Conditions conditions = assertion.getConditions();</span> |
| <span class="nc bnc" id="L60" title="All 2 branches missed."> if (conditions.getNotBefore() != null) {</span> |
| <span class="nc" id="L61"> this.setDateNotBefore(conditions.getNotBefore().toDate());</span> |
| } |
| <span class="nc bnc" id="L63" title="All 2 branches missed."> if (conditions.getNotOnOrAfter() != null) {</span> |
| <span class="nc" id="L64"> this.setDateNotOnOrAfter(conditions.getNotOnOrAfter().toDate());</span> |
| } |
| } |
| <span class="nc" id="L67"> }</span> |
| |
| @Override |
| public byte[] getAssertionKeyInfoSecret(Crypto signatureCrypto, TokenCallbackHandler tokenCallbackHandler) |
| throws WSSecurityException { |
| |
| <span class="nc" id="L73"> RequestData requestData = new RequestData();</span> |
| <span class="nc" id="L74"> requestData.setCallbackHandler(tokenCallbackHandler);</span> |
| <span class="nc" id="L75"> requestData.setSigCrypto(signatureCrypto);</span> |
| |
| <span class="nc" id="L77"> WSDocInfo docInfo = new WSDocInfo(assertion.getDOM().getOwnerDocument()); // TODO Improve ..</span> |
| |
| // TODO change this to use SAMLAssertion parameter once wss4j conversion is done .... |
| <span class="nc" id="L80"> SAMLKeyInfo samlKi = SAMLUtil.getCredentialFromSubject(assertion,</span> |
| requestData, docInfo, true); |
| <span class="nc" id="L82"> return samlKi.getSecret();</span> |
| } |
| |
| |
| @Override |
| public OMElement getAssertionElement() throws TrustException { |
| <span class="nc" id="L88"> return (OMElement)this.assertion.getDOM();</span> |
| } |
| |
| |
| } |
| </pre><div class="footer"><span class="right">Created with <a href="http://www.eclemma.org/jacoco">JaCoCo</a> 0.6.1.201212231917</span></div></body></html> |