Package org.apache.hadoop.gateway.services.security

Examples of org.apache.hadoop.gateway.services.security.AliasService


     
      systemPass= systemPass.substring( "S{ALIAS=".length(), systemPass.length() - 1 );
      String aliasName = systemPass;
     
      GatewayServices services = GatewayServer.getGatewayServices();
      AliasService aliasService = (AliasService)services.getService(GatewayServices.ALIAS_SERVICE);
     
      String clusterName = getClusterName();
      //System.err.println("FACTORY systempass 30: " + systemPass);
      //System.err.println("FACTORY clustername 40: " + clusterName);
      //System.err.println("FACTORY SystemProperty GatewayHome 50: " + System.getProperty(GatewayConfig.GATEWAY_HOME_VAR));
      char[] password = aliasService.getPasswordFromAliasForCluster(clusterName, systemPass);
      //System.err.println("FACTORY password: " + ((password == null) ? "NULL" : new String(password)));
      if ( password != null ) {
        //System.err.println("FACTORY SUCCESS 20 system password :" + new String(password));
        super.setSystemPassword( new String(password) );
      } else {
View Full Code Here


    rc = cli.run(gwCreateArgs);
    assertEquals(0, rc);
    assertTrue(outContent.toString(), outContent.toString().contains("alias1 has been successfully " +
        "created."));

    AliasService as = cli.getGatewayServices().getService(GatewayServices.ALIAS_SERVICE);

    outContent.reset();
    String[] clusterCreateArgs = {"create-alias", "alias2", "--value", "testvalue1", "--cluster", "test",
        "--master", "master"};
    cli = new KnoxCLI();
    cli.setConf( config );
    rc = cli.run(clusterCreateArgs);
    assertEquals(0, rc);
    assertTrue(outContent.toString(), outContent.toString().contains("alias2 has been successfully " +
        "created."));

    outContent.reset();
    String[] args2 = {"list-alias", "--master", "master"};
    cli = new KnoxCLI();
    rc = cli.run(args2);
    assertEquals(0, rc);
    assertFalse(outContent.toString(), outContent.toString().contains("alias2"));
    assertTrue(outContent.toString(), outContent.toString().contains("alias1"));

    char[] passwordChars = as.getPasswordFromAliasForCluster("test", "alias2");
    assertNotNull(passwordChars);
    assertTrue(new String(passwordChars), "testvalue1".equals(new String(passwordChars)));

    outContent.reset();
    String[] args1 = {"list-alias", "--cluster", "test", "--master", "master"};
View Full Code Here

    gatewayUrl = "http://localhost:" + gateway.getAddresses()[0].getPort() + "/" + config.getGatewayPath();
    clusterUrl = gatewayUrl + "/test-cluster";
   
    ///*
    GatewayServices services = GatewayServer.getGatewayServices();
    AliasService aliasService = (AliasService)services.getService(GatewayServices.ALIAS_SERVICE);
    aliasService.addAliasForCluster("test-cluster", "ldcSystemPassword", "guest-password");
 
    char[] password1 = aliasService.getPasswordFromAliasForCluster( "test-cluster", "ldcSystemPassword");
    //System.err.println("SETUP password 10: " + ((password1 == null) ? "NULL" : new String(password1)));
   
    descriptor = new File( topoDir, "test-cluster.xml" );
    stream = new FileOutputStream( descriptor );
    createTopology(ldapPort).toStream( stream );
View Full Code Here

    gatewayUrl = "http://localhost:" + gateway.getAddresses()[0].getPort() + "/" + config.getGatewayPath();
    clusterUrl = gatewayUrl + "/testdg-cluster";
   
    ///*
    GatewayServices services = GatewayServer.getGatewayServices();
    AliasService aliasService = (AliasService)services.getService(GatewayServices.ALIAS_SERVICE);
    aliasService.addAliasForCluster("testdg-cluster", "ldcSystemPassword", "guest-password");
 
    char[] password1 = aliasService.getPasswordFromAliasForCluster( "testdg-cluster", "ldcSystemPassword");
    //System.err.println("SETUP password 10: " + ((password1 == null) ? "NULL" : new String(password1)));
   
    descriptor = new File( topoDir, "testdg-cluster.xml" );
    stream = new FileOutputStream( descriptor );
    createTopology(ldapPort).toStream( stream );
View Full Code Here

    EasyMock.expect( context.getWebArchive() ).andReturn( webArchive ).anyTimes();
    EasyMock.expect( context.getWebAppDescriptor() ).andReturn( Descriptors.create( WebAppDescriptor.class ) ).anyTimes();
    EasyMock.expect( context.getTopology() ).andReturn( topology ).anyTimes();
    EasyMock.replay( context );

    AliasService as = EasyMock.createNiceMock( AliasService.class );
    CryptoService cryptoService = new DefaultCryptoService();
    ((DefaultCryptoService)cryptoService).setAliasService( as );

    GatewayServices gatewayServices = EasyMock.createNiceMock( GatewayServices.class );
    EasyMock.expect( gatewayServices.getService( GatewayServices.CRYPTO_SERVICE ) ).andReturn( cryptoService ).anyTimes();
View Full Code Here

    public abstract void execute() throws Exception;

    public abstract String getUsage();

    protected AliasService getAliasService() {
      AliasService as = services.getService(GatewayServices.ALIAS_SERVICE);
      return as;
    }
View Full Code Here

   /* (non-Javadoc)
    * @see org.apache.hadoop.gateway.util.KnoxCLI.Command#execute()
    */
   @Override
   public void execute() throws Exception {
     AliasService as = getAliasService();

     if (cluster == null) {
       cluster = "__gateway";
     }
     out.println("Listing aliases for: " + cluster);
     List<String> aliases = as.getAliasesForCluster(cluster);
     for (String alias : aliases) {
       out.println(alias);
     }
     out.println("\n" + aliases.size() + " items.");
   }
View Full Code Here

    */
   @Override
   public void execute() throws Exception {
     KeystoreService ks = getKeystoreService();
    
     AliasService as = getAliasService();
    
     if (ks != null) {
       try {
         if (!ks.isCredentialStoreForClusterAvailable(GATEWAY_CREDENTIAL_STORE_NAME)) {
//           log.creatingCredentialStoreForGateway();
           ks.createCredentialStoreForCluster(GATEWAY_CREDENTIAL_STORE_NAME);
         }
         else {
//           log.credentialStoreForGatewayFoundNotCreating();
         }
         as.generateAliasForCluster(GATEWAY_CREDENTIAL_STORE_NAME, GATEWAY_IDENTITY_PASSPHRASE);
       } catch (KeystoreServiceException e) {
         throw new ServiceLifecycleException("Keystore was not loaded properly - the provided (or persisted) master secret may not match the password for the keystore.", e);
       }
 
       try {
         if (!ks.isKeystoreForGatewayAvailable()) {
//           log.creatingKeyStoreForGateway();
           ks.createKeystoreForGateway();
         }
         else {
//           log.keyStoreForGatewayFoundNotCreating();
         }
         char[] passphrase = as.getPasswordFromAliasForCluster(GATEWAY_CREDENTIAL_STORE_NAME, GATEWAY_IDENTITY_PASSPHRASE);
         ks.addSelfSignedCertForGateway("gateway-identity", passphrase, hostname);
//         logAndValidateCertificate();
         out.println("Certificate gateway-identity has been successfully created.");
       } catch (KeystoreServiceException e) {
         throw new ServiceLifecycleException("Keystore was not loaded properly - the provided (or persisted) master secret may not match the password for the keystore.", e);
View Full Code Here

   /* (non-Javadoc)
    * @see org.apache.hadoop.gateway.util.KnoxCLI.Command#execute()
    */
   @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 (generate.equals("true")) {
         as.generateAliasForCluster(cluster, name);
         out.println(name + " has been successfully generated.");
       }
       else {
         throw new IllegalArgumentException("No value has been set. " +
             "Consider setting --generate or --value.");
View Full Code Here

   /* (non-Javadoc)
    * @see org.apache.hadoop.gateway.util.KnoxCLI.Command#execute()
    */
   @Override
   public void execute() throws Exception {
     AliasService as = getAliasService();
     if (as != null) {
       if (cluster == null) {
         cluster = "__gateway";
       }
       as.removeAliasForCluster(cluster, name);
       out.println(name + " has been successfully deleted.");
     }
   }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.gateway.services.security.AliasService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.