Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.paypal.base;
  
  import java.util.HashMap;
  import java.util.HashSet;
  import java.util.Map;
  import java.util.Set;
  
CredentialManager acts as a factory for loading com.paypal.base.credential.ICredential credential configured in application properties
 
 public final class CredentialManager {
 
 	/*
 	 * Map used for to override ConfigManager configurations
 	 */
 	private Map<StringStringconfigurationMap = null;

Credential Manager

Parameters:
configurationMap java.util.Map
 
 	public CredentialManager(Map<StringStringconfigurationMap) {
 		if (configurationMap == null) {
 					"ConfigurationMap cannot be null");
 		}
 		this. = configurationMap;
 	}
 
 		ICredential credential = null;
 		if (getAccounts().size() == 0) {
 					"No API accounts have been configured in application properties");
 		}
 				prefix);
 		if (userId != null && userId.trim().length() != 0) {
 			for (Entry<StringStringentry : credMap.entrySet()) {
 				if (entry.getKey().endsWith(
 						&& entry.getValue().equalsIgnoreCase(userId)) {
 					String acctKey = entry.getKey().substring(0,
 							entry.getKey().indexOf('.'));
 					credential = returnCredential(credMapacctKey);
 				}
 			}
 			if (credential == null) {
 						"Account for the username does not exists in the properties file");
 			}
 		} else {
 			int index = 1;
 			String userName = (StringcredMap.get(prefix + index
 			if (userName != null && userName.trim().length() != 0) {
 				credential = returnCredential(credMapprefix + index);
 			} else {
 						"Associate valid account for index 1");
 			}
 		}
 		return credential;
 	}
 
 	private Set<StringgetAccounts(Map<StringStringconfigurationMap) {
 		Set<Stringset = new HashSet<String>();
 		for (Object obj : configurationMap.keySet()) {
 			key = (Stringobj;
 			if (key.contains("acct")) {
 				int pos = key.indexOf('.');
 				String acct = key.substring(0, pos);
 				set.add(acct);
 			}
 		}
 		return set;
 	}
 
 			Map<StringStringconfigurationMapString category) {
 		HashMap<StringStringmap = new HashMap<StringString>();
 		for (Object obj : configurationMap.keySet()) {
			key = (Stringobj;
			if (key.contains(category)) {
				map.put(keyconfigurationMap.get(key));
			}
		}
		return map;
	}
			String acctKeythrows InvalidCredentialException {
		ICredential credential = null;
		String userName = (StringcredMap.get(acctKey
		String password = (StringcredMap.get(acctKey
		String appId = (StringcredMap.get(acctKey
		String subject = (StringcredMap.get(acctKey
		if (credMap.get(acctKey + .) != null) {
			String signature = (StringcredMap.get(acctKey
			credential = new SignatureCredential(userNamepasswordsignature);
			((SignatureCredentialcredential).setApplicationId(appId);
			if (subject != null && subject.trim().length() > 0) {
				ThirdPartyAuthorization thirdPartyAuthorization = new SubjectAuthorization(
						subject);
				((SignatureCredentialcredential)
						.setThirdPartyAuthorization(thirdPartyAuthorization);
			}
else if (credMap.get(acctKey + .) != null) {
			String certPath = (StringcredMap.get(acctKey
			String certKey = (StringcredMap.get(acctKey
			credential = new CertificateCredential(userNamepassword,
					certPathcertKey);
			if (subject != null && subject.trim().length() > 0) {
				ThirdPartyAuthorization thirdPartyAuthorization = new SubjectAuthorization(
						subject);
				((CertificateCredentialcredential)
						.setThirdPartyAuthorization(thirdPartyAuthorization);
			}
else {
					"The account does not have a valid credential type(signature/certificate)");
		}
		return credential;
	}
New to GrepCode? Check out our FAQ X