Coverage report

  %line %branch
org.apache.jetspeed.sso.impl.SSOSiteImpl
0% 
0% 

 1  
 /*
 2  
 * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
 * contributor license agreements.  See the NOTICE file distributed with
 4  
 * this work for additional information regarding copyright ownership.
 5  
 * The ASF licenses this file to You under the Apache License, Version 2.0
 6  
 * (the "License"); you may not use this file except in compliance with
 7  
 * the License.  You may obtain a copy of the License at
 8  
 * 
 9  
 *      http://www.apache.org/licenses/LICENSE-2.0
 10  
 * 
 11  
 * Unless required by applicable law or agreed to in writing, software
 12  
 * distributed under the License is distributed on an "AS IS" BASIS,
 13  
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
 * See the License for the specific language governing permissions and
 15  
 * limitations under the License.
 16  
 */
 17  
 
 18  
 package org.apache.jetspeed.sso.impl;
 19  
 
 20  
 import java.util.Collection;
 21  
 import java.util.Iterator;
 22  
 import java.util.Vector;
 23  
 
 24  
 import org.apache.jetspeed.sso.SSOException;
 25  
 import org.apache.jetspeed.sso.SSOSite;
 26  
 import org.apache.jetspeed.sso.SSOPrincipal;
 27  
 
 28  
 /**
 29  
 * SSOSiteImpl
 30  
 * 	Class holding information about the Site and credentials for Single Sign on SSO.
 31  
 *	OJB will map the database entries into this class
 32  
 *
 33  
 * @author <a href="mailto:rogerrut@apache.org">Roger Ruttimann</a>
 34  
 * @version $Id: SSOSiteImpl.java 516448 2007-03-09 16:25:47Z ate $
 35  
 */
 36  
 
 37  
 public class SSOSiteImpl implements SSOSite {
 38  
 	
 39  
 	// Private member for OJB mapping
 40  
 	private int		siteId;
 41  
 	private String	name;
 42  
 	private String	siteURL;
 43  
 	private boolean	isAllowUserSet;
 44  
 	private boolean isCertificateRequired;
 45  
 	
 46  
 	private boolean	isChallangeResponseAuthentication;
 47  
 	
 48  
 	/* Realm used to do ChallengeResponse Authentication */
 49  
 	private String	realm;
 50  
 	
 51  
 	private boolean	isFormAuthentication;
 52  
 	
 53  
 	/* Names of fields for User and Password values. The names are up to the
 54  
 	 * application developer and therefore it must be configurable for SSO*/
 55  
 	private String	formUserField;
 56  
 	private String	formPwdField;
 57  
 	
 58  0
 	private Collection	principals = new Vector();
 59  0
 	private Collection	remotePrincipals = new Vector();
 60  
 	
 61  
 	/**
 62  
 	 * 
 63  
 	 */
 64  
 	public SSOSiteImpl() {
 65  0
 		super();
 66  
 		
 67  0
 	}
 68  
 
 69  
 	/*
 70  
 	 * Setters and getters for member variables
 71  
 	 */
 72  
 	
 73  
 	/**
 74  
 	 * @return Returns the isAllowUserSet.
 75  
 	 */
 76  
 	public boolean isAllowUserSet() {
 77  0
 		return isAllowUserSet;
 78  
 	}
 79  
 	/**
 80  
 	 * @param isAllowUserSet The isAllowUserSet to set.
 81  
 	 */
 82  
 	public void setAllowUserSet(boolean isAllowUserSet) {
 83  0
 		this.isAllowUserSet = isAllowUserSet;
 84  0
 	}
 85  
 	/**
 86  
 	 * @return Returns the isCertificateRequired.
 87  
 	 */
 88  
 	public boolean isCertificateRequired() {
 89  0
 		return isCertificateRequired;
 90  
 	}
 91  
 	/**
 92  
 	 * @param isCertificateRequired The isCertificateRequired to set.
 93  
 	 */
 94  
 	public void setCertificateRequired(boolean isCertificateRequired) {
 95  0
 		this.isCertificateRequired = isCertificateRequired;
 96  0
 	}
 97  
 	/**
 98  
 	 * @return Returns the name.
 99  
 	 */
 100  
 	public String getName() {
 101  0
 		return name;
 102  
 	}
 103  
 	/**
 104  
 	 * @param name The name to set.
 105  
 	 */
 106  
 	public void setName(String name) {
 107  0
 		this.name = name;
 108  0
 	}
 109  
 	/**
 110  
 	 * @return Returns the principals.
 111  
 	 */
 112  
 	public Collection getPrincipals() {
 113  0
 		return this.principals;
 114  
 	}
 115  
 	/**
 116  
 	 * @param principals The principals to set.
 117  
 	 */
 118  
 	public void setPrincipals(Collection principals) {
 119  0
 		this.principals.addAll(principals);
 120  0
 	}
 121  
 	/**
 122  
 	 * @return Returns the siteId.
 123  
 	 */
 124  
 	public int getSiteId() {
 125  0
 		return siteId;
 126  
 	}
 127  
 	/**
 128  
 	 * @param siteId The siteId to set.
 129  
 	 */
 130  
 	public void setSiteId(int siteId) {
 131  0
 		this.siteId = siteId;
 132  0
 	}
 133  
 	/**
 134  
 	 * @return Returns the siteURL.
 135  
 	 */
 136  
 	public String getSiteURL() {
 137  0
 		return siteURL;
 138  
 	}
 139  
 	/**
 140  
 	 * @param siteURL The siteURL to set.
 141  
 	 */
 142  
 	public void setSiteURL(String siteURL) {
 143  0
 		this.siteURL = siteURL;
 144  0
 	}
 145  
 	
 146  
 	/**
 147  
 	 * Utility functions
 148  
 	 * addCredential()
 149  
 	 * Adds the credentail to the credentials collection
 150  
 	 *
 151  
 	 */
 152  
 	
 153  
 	
 154  
 	
 155  
 		/**
 156  
 		 * addPrincipal
 157  
 		 * Adds the SSOPrincipal to the principals collection
 158  
 		 *
 159  
 		 */
 160  
 		public void addPrincipal(SSOPrincipal principal) throws SSOException {
 161  0
 			boolean bStatus = false;
 162  
 			
 163  
 			try
 164  
 			{
 165  0
 				bStatus = principals.add(principal);
 166  
 			}
 167  0
 			catch(Exception e)
 168  
 			{
 169  
 				// Adding credentail to coollection failed -- notify caller with SSOException
 170  0
 				throw new SSOException(SSOException.FAILED_ADDING_PRINCIPAL_TO_MAPPING_TABLE_FOR_SITE + e.getMessage()); 
 171  0
 			}
 172  
 			
 173  0
 			if ( bStatus == false)
 174  0
 				throw new SSOException(SSOException.FAILED_ADDING_PRINCIPAL_TO_MAPPING_TABLE_FOR_SITE ); 	
 175  0
 		}
 176  
 		
 177  
 		/**
 178  
 		* removePrincipal()
 179  
 		 * removes a principal from the principals collection
 180  
 		 *
 181  
 		 */
 182  
 		public void removePrincipal(long principalId) throws SSOException
 183  
 		{
 184  0
 			boolean bStatus = false;
 185  0
 			SSOPrincipal principalObj = null;
 186  0
 			Iterator itSitePrincipals = principals.iterator();
 187  
 			
 188  0
 			while (itSitePrincipals.hasNext() )
 189  
 			{
 190  0
 				principalObj = (SSOPrincipal)itSitePrincipals.next();
 191  0
 				if ( principalObj.getPrincipalId() == principalId)
 192  
 				{
 193  
 				
 194  
 					try
 195  
 					{
 196  0
 						bStatus = principals.remove(principalObj);
 197  
 					}
 198  0
 					catch(Exception e)
 199  
 					{
 200  
 						// Adding credentail to coollection failed -- notify caller with SSOException
 201  0
 						throw new SSOException(SSOException.FAILED_REMOVING_PRINCIPAL_FROM_MAPPING_TABLE_FOR_SITE + e.getMessage()); 
 202  0
 					}
 203  
 					
 204  0
 					if ( bStatus == false)
 205  0
 						throw new SSOException(SSOException.FAILED_REMOVING_PRINCIPAL_FROM_MAPPING_TABLE_FOR_SITE ); 
 206  
 				}
 207  
 					
 208  
 			}
 209  0
 		}
 210  
     /**
 211  
      * @return Returns the remotePrincipals.
 212  
      */
 213  
     public Collection getRemotePrincipals() {
 214  0
         return remotePrincipals;
 215  
     }
 216  
     /**
 217  
      * @param remotePrincipals The remotePrincipals to set.
 218  
      */
 219  
     public void setRemotePrincipals(Collection remotePrincipals) {
 220  0
         this.remotePrincipals = remotePrincipals;
 221  0
     }
 222  
     
 223  
     /**
 224  
      * Define the Authentication methods. 
 225  
      * Supported are: Challenge Response and From based
 226  
      */
 227  
     /**
 228  
      * Form authentication requires two fields that hold the credential 
 229  
      * information for the request.
 230  
      */
 231  
     public void setFormAuthentication(String formUserField, String formPwdField)
 232  
     {
 233  
     	// Set the fields for Form Authentication and clear other authentication methods
 234  
     	
 235  0
     }
 236  
     
 237  
     /*
 238  
      * Uses Challenge Response mechanism for authentication
 239  
      */
 240  
     public void setChallengeResponseAuthentication()
 241  
     {
 242  
     	// Set the fields for ChallengeResponse and clear other authentication methods
 243  
     	
 244  0
     }
 245  
 
 246  
     /* Setters/Getters for Authentication settings */
 247  
 	public String getFormPwdField() {
 248  0
 		return formPwdField;
 249  
 	}
 250  
 
 251  
 	public void setFormPwdField(String formPwdField) {
 252  0
 		this.formPwdField = formPwdField;
 253  0
 	}
 254  
 
 255  
 	public String getFormUserField() {
 256  0
 		return formUserField;
 257  
 	}
 258  
 
 259  
 	public void setFormUserField(String formUserField) {
 260  0
 		this.formUserField = formUserField;
 261  0
 	}
 262  
 
 263  
 	public boolean isChallangeResponseAuthentication() {
 264  0
 		return isChallangeResponseAuthentication;
 265  
 	}
 266  
 
 267  
 	public void setChallengeResponseAuthentication(
 268  
 			boolean isChallangeResponseAuthentication) {
 269  0
 		this.isChallangeResponseAuthentication = isChallangeResponseAuthentication;
 270  0
 	}
 271  
 
 272  
 	public boolean isFormAuthentication() {
 273  0
 		return isFormAuthentication;
 274  
 	}
 275  
 
 276  
 	public void setFormAuthentication(boolean isFormAuthentication) {
 277  0
 		this.isFormAuthentication = isFormAuthentication;
 278  0
 	}
 279  
 	
 280  
 	public void configFormAuthentication(String formUserField, String formPwdField)
 281  
 	{
 282  0
 		this.isFormAuthentication = true;
 283  0
 		this.setChallengeResponseAuthentication(false);
 284  
 		
 285  0
 		this.formPwdField	=	formPwdField;
 286  0
 		this.formUserField	=	formUserField;
 287  0
 	}
 288  
 	
 289  
 	/*
 290  
 	 *  (non-Javadoc)
 291  
 	 * @see org.apache.jetspeed.sso.SSOSite#setRealm(java.lang.String)
 292  
 	 */
 293  
 	public void setRealm(String realm)
 294  
 	{
 295  0
 		this.realm = realm;
 296  0
 	}
 297  
 	
 298  
 	/*
 299  
 	 *  (non-Javadoc)
 300  
 	 * @see org.apache.jetspeed.sso.SSOSite#getRealm()
 301  
 	 */
 302  
 	public String getRealm()
 303  
 	{
 304  0
 		return this.realm;
 305  
 	}    
 306  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.