Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed to Jasig under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. Jasig licenses this file to you 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: 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.jasig.cas3.extensions.clearpass.integration.uportal;
 import  org.springframework.util.Assert;

Scott Battaglia
$Revision$ $Date$
 public final class PasswordCachingCasAssertionSecurityContext extends CasAssertionSecurityContext {
     private final String clearPassUrl;
     private byte[] cachedCredentials;
     protected PasswordCachingCasAssertionSecurityContext(final String clearPassUrl) {
         Assert.notNull(clearPassUrl"clearPassUrl cannot be null.");
         this. = clearPassUrl;
     protected void postAuthenticate(final Assertion assertion) {
         final String proxyTicket = assertion.getPrincipal().getProxyTicketFor(this.);
         if (proxyTicket == null) {
             log.error("Unable to obtain proxy ticket for ClearPass service.");
         final String password = retrievePasswordFromResponse(proxyTicket);
         if (password != null) {
             log.debug("Password retrieved from ClearPass.");
             this. = password.getBytes();
         } else {
             log.debug("Unable to retrieve password from ClearPass.");
     public IOpaqueCredentials getOpaqueCredentials() {
         if (this. == null) {
             return super.getOpaqueCredentials();
         final NotSoOpaqueCredentials credentials = new CacheOpaqueCredentials();
         return credentials;
     protected final String retrievePasswordFromResponse(final String proxyTicket) {
         final String url = this. + (this..contains("?") ? "&" : "?") + "ticket=" + proxyTicket;
         final String response = CommonUtils.getResponseFromServer(url);
         final String password = XmlUtils.getTextForElement(response"credentials");
         if (password != null) {
             return password;
         log.error("Unable to Retrieve Password.  Full Response from ClearPass was [" + response + "]");
         return null;

Copied from
 	private class CacheOpaqueCredentials extends ChainingOpaqueCredentials implements NotSoOpaqueCredentials {
 		private static final long serialVersionUID = 1l;
 		public String getCredentials() {
             return this. != null ? new String(this.) : null;
New to GrepCode? Check out our FAQ X