private CredentialValue getCredentialValueForAlias(String alias) { GatewayServices services = (GatewayServices)request.getServletContext(). getAttribute(GatewayServices.GATEWAY_SERVICES_ATTRIBUTE); String clusterName = (String) request.getServletContext().getAttribute(GatewayServices.GATEWAY_CLUSTER_ATTRIBUTE); AliasService as = services.getService(GatewayServices.ALIAS_SERVICE); char[] credential = null; try { credential = as.getPasswordFromAliasForCluster(clusterName, alias); } catch (AliasServiceException e) { e.printStackTrace(); } if (credential != null) { return new CredentialValue(alias, new String(credential)); } return null; }
private List<String> getCredentialsList() { GatewayServices services = (GatewayServices)request.getServletContext(). getAttribute(GatewayServices.GATEWAY_SERVICES_ATTRIBUTE); String clusterName = (String) request.getServletContext().getAttribute(GatewayServices.GATEWAY_CLUSTER_ATTRIBUTE); AliasService as = services.getService(GatewayServices.ALIAS_SERVICE); List<String> aliases = null; try { aliases = as.getAliasesForCluster(clusterName); } catch (AliasServiceException e) { e.printStackTrace(); } return aliases; }
private char[] getSigningKeyPassphrase(char[] signingKeyPassphrase) throws AliasServiceException { if(signingKeyPassphrase != null) { return signingKeyPassphrase; } char[] phrase = as.getPasswordFromAliasForGateway(SIGNING_KEY_PASSPHRASE); if (phrase == null) { phrase = as.getGatewayIdentityPassphrase(); } return phrase; }
@Override public void execute() throws Exception { AliasService as = getAliasService(); if (cluster == null) { cluster = "__gateway"; } if (value != null) { as.addAliasForCluster(cluster, name, value); out.println(name + " has been successfully created."); } else { if ("true".equals(generate)) { as.generateAliasForCluster(cluster, name); out.println(name + " has been successfully generated."); } else { value = new String(promptUserForPassword()); as.addAliasForCluster(cluster, name, value); out.println(name + " has been successfully created."); } } }
@Override public void execute() throws Exception { AliasService as = getAliasService(); KeystoreService keystoreService = getKeystoreService(); if (as != null) { if (cluster == null) { cluster = "__gateway"; } boolean credentialStoreForClusterAvailable = keystoreService.isCredentialStoreForClusterAvailable(cluster); if (credentialStoreForClusterAvailable) { List<String> aliasesForCluster = as.getAliasesForCluster(cluster); if (null == aliasesForCluster || !aliasesForCluster.contains(name)) { out.println("Deletion of Alias: " + name + " from cluster: " + cluster + " Failed. " + "\n" + "No such alias exists in the cluster."); } else { as.removeAliasForCluster(cluster, name); out.println(name + " has been successfully deleted."); } } else { out.println("Invalid cluster name provided: " + cluster); } } }
aliases = this.as.getAliasesForCluster(clusterName); } catch (AliasServiceException e) { log.aliasServiceException(e); if(aliases.contains(key)) { try { value = String.valueOf(this.as.getPasswordFromAliasForCluster(clusterName, key)); } catch (AliasServiceException e) { log.unableToGetPassword(key, e);
@Override public byte[] sign(String algorithm, String alias, String payloadToSign) { try { char[] passphrase; passphrase = as.getGatewayIdentityPassphrase(); PrivateKey privateKey = (PrivateKey) ks.getKeyForGateway(alias, passphrase); Signature signature = Signature.getInstance(algorithm); signature.initSign(privateKey); signature.update(payloadToSign.getBytes(StandardCharsets.UTF_8)); return signature.sign(); } catch (NoSuchAlgorithmException | AliasServiceException | KeystoreServiceException | SignatureException | InvalidKeyException e) { LOG.failedToSignData( e ); } return null; }
if (aliasService != null) { try { credential = aliasService.getPasswordFromAliasForGateway(config.getCredentialAlias()); } catch (AliasServiceException e) { log.unresolvedCredentialAlias(config.getCredentialAlias());
/** * Add the alias to the local keystore. * Most likely this will be called by remote registry watch listener. * * @param clusterName Name of the cluster * @param alias Alias name to be added * @param value alias value to be added * @throws AliasServiceException exception on failure adding alias */ public void addAliasForClusterLocally(final String clusterName, final String alias, final String value) throws AliasServiceException { localAliasService.addAliasForCluster(clusterName, alias, value); }
/** * Remove the given alias from local keystore. * Most likely this will be called by remote registry watch listener. * * @param clusterName Name of the cluster * @param alias Alias name to be removed * @throws AliasServiceException exception on failure removing alias */ public void removeAliasForClusterLocally(final String clusterName, final String alias) throws AliasServiceException { LOG.removeAliasLocally(clusterName, alias); localAliasService.removeAliasForCluster(clusterName, alias); }
aliases = this.as.getAliasesForCluster(clusterName); } catch (AliasServiceException e) { log.aliasServiceException(e); if(aliases.contains(key)) { try { value = String.valueOf(this.as.getPasswordFromAliasForCluster(clusterName, key)); } catch (AliasServiceException e) { log.unableToGetPassword(key, e);
private void addDefaultConfig(String clientNameParameter, Map<String, String> properties) { // add default saml params if (clientNameParameter.contains("SAML2Client")) { properties.put(PropertiesConfigFactory.SAML_KEYSTORE_PATH, keystoreService.getKeystorePath()); properties.put(PropertiesConfigFactory.SAML_KEYSTORE_PASSWORD, new String(masterService.getMasterSecret())); // check for provisioned alias for private key char[] gip = null; try { gip = aliasService.getGatewayIdentityPassphrase(); } catch(AliasServiceException ase) { log.noPrivateKeyPasshraseProvisioned(ase); } if (gip != null) { properties.put(PropertiesConfigFactory.SAML_PRIVATE_KEY_PASSWORD, new String(gip)); } else { // no alias provisioned then use the master properties.put(PropertiesConfigFactory.SAML_PRIVATE_KEY_PASSWORD, new String(masterService.getMasterSecret())); } } }
@Override public void execute() throws Exception { AliasService as = getAliasService(); KeystoreService keystoreService = getKeystoreService(); if (as != null) { if (cluster == null) { cluster = "__gateway"; } boolean credentialStoreForClusterAvailable = keystoreService.isCredentialStoreForClusterAvailable(cluster); if (credentialStoreForClusterAvailable) { List<String> aliasesForCluster = as.getAliasesForCluster(cluster); if (null == aliasesForCluster || !aliasesForCluster.contains(name)) { out.println("Deletion of Alias: " + name + " from cluster: " + cluster + " Failed. " + "\n" + "No such alias exists in the cluster."); } else { as.removeAliasForCluster(cluster, name); out.println(name + " has been successfully deleted."); } } else { out.println("Invalid cluster name provided: " + cluster); } } }
if (aliasService != null) { try { char[] defaultUser = aliasService.getPasswordFromAliasForGateway(DEFAULT_USER_ALIAS); if (defaultUser != null) { username = new String(defaultUser); char[] pwd = aliasService.getPasswordFromAliasForGateway(passwordAlias); if (pwd != null) { password = new String(pwd);
/** * Add the alias to the local keystore. * Most likely this will be called by remote registry watch listener. * * @param clusterName Name of the cluster * @param alias Alias name to be added * @param value alias value to be added * @throws AliasServiceException exception on failure adding alias */ public void addAliasForClusterLocally(final String clusterName, final String alias, final String value) throws AliasServiceException { localAliasService.addAliasForCluster(clusterName, alias, value); }
/** * Remove the given alias from local keystore. * Most likely this will be called by remote registry watch listener. * * @param clusterName Name of the cluster * @param alias Alias name to be removed * @throws AliasServiceException exception on failure removing alias */ public void removeAliasForClusterLocally(final String clusterName, final String alias) throws AliasServiceException { LOG.removeAliasLocally(clusterName, alias); localAliasService.removeAliasForCluster(clusterName, alias); }
@Override public void execute() throws Exception { AliasService as = getAliasService(); if (cluster == null) { cluster = "__gateway"; } if (value != null) { as.addAliasForCluster(cluster, name, value); out.println(name + " has been successfully created."); } else { if (Boolean.parseBoolean(generate)) { as.generateAliasForCluster(cluster, name); out.println(name + " has been successfully generated."); } else { value = new String(promptUserForPassword()); as.addAliasForCluster(cluster, name, value); out.println(name + " has been successfully created."); } } }
private CredentialValue getCredentialValueForAlias(String alias) { GatewayServices services = (GatewayServices)request.getServletContext(). getAttribute(GatewayServices.GATEWAY_SERVICES_ATTRIBUTE); String clusterName = (String) request.getServletContext().getAttribute(GatewayServices.GATEWAY_CLUSTER_ATTRIBUTE); AliasService as = services.getService(GatewayServices.ALIAS_SERVICE); char[] credential = null; try { credential = as.getPasswordFromAliasForCluster(clusterName, alias); } catch (AliasServiceException e) { e.printStackTrace(); } if (credential != null) { return new CredentialValue(alias, new String(credential)); } return null; }
private char[] getSigningKeyPassphrase(char[] signingKeyPassphrase) throws AliasServiceException { if(signingKeyPassphrase != null) { return signingKeyPassphrase; } char[] phrase = as.getPasswordFromAliasForGateway(SIGNING_KEY_PASSPHRASE); if (phrase == null) { phrase = as.getGatewayIdentityPassphrase(); } return phrase; }
private List<String> getCredentialsList() { GatewayServices services = (GatewayServices)request.getServletContext(). getAttribute(GatewayServices.GATEWAY_SERVICES_ATTRIBUTE); String clusterName = (String) request.getServletContext().getAttribute(GatewayServices.GATEWAY_CLUSTER_ATTRIBUTE); AliasService as = services.getService(GatewayServices.ALIAS_SERVICE); List<String> aliases = null; try { aliases = as.getAliasesForCluster(clusterName); } catch (AliasServiceException e) { e.printStackTrace(); } return aliases; }