Package com.alu.e3.data.model

Examples of com.alu.e3.data.model.Auth


   * @param clientId
   * @param clientSecret
   */
  public void setOAuth(String clientId, String clientSecret) {
   
    Auth auth = new Auth();   
    auth.setAuthDetail(new AuthDetail());
    auth.getAuthDetail().setClientId(clientId);
    auth.getAuthDetail().setClientSecret(clientSecret)
   
    this.authIdentity.setAuth(auth);
  }
View Full Code Here


  @Override
  public AuthReport checkAllowed(Api api, String username, String password) {
    if(logger.isDebugEnabled()) {
      logger.debug("Try authentication for username [" + username + "] and password [" + password + "] for Api [" + api.getId() + "]");
    }
    Auth auth = this.dataManager.getAuthByUserPass(username, password);
   
    return getAuthReport(api, auth);
  }
View Full Code Here

  @Override
  public AuthReport checkAllowed(Api api, String username, String passwordDigest, boolean isPasswordText, String nonce, String created) {
    if(logger.isDebugEnabled()) {
      logger.debug("Try authentication for username [" + username + "] for Api [" + api.getId() + "]");
    }
    Auth auth = this.dataManager.getWsseAuth(username, passwordDigest, isPasswordText, nonce, created);

    return getAuthReport(api, auth);   
  }
View Full Code Here

  @Override
  public AuthReport checkOAuthAllowed(Api api, String clientId, String clientSecret) {
    if(logger.isDebugEnabled()) {
      logger.debug("Try authentication for cliendId [" + clientId + "] for Api [" + api.getId() + "]");
    }
    Auth auth = this.dataManager.getAuthByOAuth(clientId, clientSecret);
   
    return getAuthReport(api, auth);       
  }
View Full Code Here

   * Sets the Auth from a CanonicalizedIpAddress
   * @param ip
   */
  public void setAuth(CanonicalizedIpAddress ip) {
   
    Auth auth = new Auth();   
    auth.setAuthDetail(new AuthDetail());
    auth.getAuthDetail().getWhiteListedIps().add(ip.getIp());
   
    this.authIdentity.setAuth(auth);
  }
View Full Code Here

  @Test
  public void testAddTwiceAuthSameIP() {

    // Add a new Auth
    Auth auth = new Auth();
    auth.setId("id2");
    auth.setAuthDetail(new AuthDetail());
    auth.getAuthDetail().setType(NBAuthType.IP_WHITE_LIST);
    auth.getAuthDetail().getWhiteListedIps().add("12.34.56.78");
    dataManager.addAuth(auth);

    Auth auth2 = new Auth();
    auth2.setId("id3");
    auth2.setAuthDetail(new AuthDetail());
    auth2.getAuthDetail().setType(NBAuthType.IP_WHITE_LIST);
    auth2.getAuthDetail().getWhiteListedIps().add("12.34.56.78");

    boolean wasException = false;
    try
    {
      dataManager.addAuth(auth2);
    }
    catch (Exception e)
    {
      wasException = true;
    }

    assertTrue("Second auth with same API key was refused", wasException);

    // cleanup for next test
    dataManager.removeAuth(auth.getId());



    // Add a new Auth
    auth = new Auth();
    auth.setId("id2");
    auth.setAuthDetail(new AuthDetail());
    auth.getAuthDetail().setType(NBAuthType.IP_WHITE_LIST);
    auth.getAuthDetail().getWhiteListedIps().add("12.34.56.78");
    dataManager.addAuth(auth);

    auth2 = new Auth();
    auth2.setId("id3");
    auth2.setAuthDetail(new AuthDetail());
    auth2.getAuthDetail().setType(NBAuthType.IP_WHITE_LIST);
    auth2.getAuthDetail().getWhiteListedIps().add("112.34.56.78");
    dataManager.addAuth(auth2);

    auth2.getAuthDetail().getWhiteListedIps().clear();
    auth2.getAuthDetail().getWhiteListedIps().add("12.34.56.78");

    wasException = false;
    try
    {
      dataManager.updateAuth(auth2);
    }
    catch (Exception e)
    {
      wasException = true;
    }

    assertTrue("Second auth with same API key was refused", wasException);

    // cleanup for next test
    dataManager.removeAuth(auth.getId());
    dataManager.removeAuth(auth2.getId());

  }
View Full Code Here

  @Test
  public void testGetAllAuth() {

    // Add a new Auth
    Auth auth = new Auth();
    auth.setId("id1");
    auth.setAuthDetail(new AuthDetail());
    auth.getAuthDetail().setUsername("username1");
    auth.getAuthDetail().setType(NBAuthType.AUTHKEY);
    auth.getAuthDetail().setAuthKeyValue("authKey1");
    dataManager.addAuth(auth);

    Auth auth2 = new Auth();
    auth2.setId("id2");
    auth2.setAuthDetail(new AuthDetail());
    auth2.getAuthDetail().setUsername("username");
    auth2.getAuthDetail().setType(NBAuthType.AUTHKEY);
    auth2.getAuthDetail().setAuthKeyValue("authKey2");
    dataManager.addAuth(auth2);

    Set<String> auths = dataManager.getAllAuthIds();
    assertNotNull("No auth found", auths);

    List<String> authList = new ArrayList<String>();

    for (String authStr : auths) {
      authList.add(authStr);
    }

    assertEquals("Auth count is correct", 2, authList.size());
    assertTrue("Both Auths are found", (authList.get(0).equals(auth.getId()) || authList.get(0).equals(auth2.getId())) && (authList.get(1).equals(auth.getId()) || authList.get(1).equals(auth2.getId())));

    // cleanup for next test
    dataManager.removeAuth(auth.getId());
    dataManager.removeAuth(auth2.getId());
  }
View Full Code Here

    api.setId("id1");
    api.setApiDetail(new ApiDetail());
    dataManager.addApi(api);

    // Add a new Auth
    Auth auth = new Auth();
    auth.setId("id2");
    auth.setStatus(StatusType.ACTIVE);
    auth.setAuthDetail(new AuthDetail());
    auth.getAuthDetail().setType(NBAuthType.AUTHKEY);
    auth.getAuthDetail().setAuthKeyValue("authKey10");
    dataManager.addAuth(auth);

    // Add a new Policy
    Policy policy = new Policy();
    policy.setId("id3");
    policy.getApiIds().add(api.getId());
    dataManager.addPolicy(policy);

    // Create bucket
    QuotaRLBucket authIds = new QuotaRLBucket();
    authIds.setId("id3");
    authIds.getAuthIds().add(auth.getId());
    dataManager.createBucket(policy.getId(), authIds);

    // Now, get the API and check that it's OK
    Api api2 = dataManager.getApiById("id1");
    assertEquals("API has new policy", policy.getId(), api2.getPolicyIds().get(0));

    // Now, get the Auth and check that it's OK
    Auth auth2 = dataManager.getAuthById("id2");
    assertEquals("Auth has new policy", policy.getId(), auth2.getPolicyContexts().get(0).getPolicyId());

    // Check that bucket is added correctly to policy
    policy = dataManager.getPolicyById(policy.getId());
    assertEquals("Correct number of buckets for policy", 1, policy.getAuthIds().size());
    assertEquals("Policy has new bucket", authIds.getId(), policy.getAuthIds().get(0).getId());   

    dataManager.removePolicy(policy.getId());

    // Now, get the API and check that it's OK
    Api api3 = dataManager.getApiById("id1");
    assertEquals("API has no policy", 0, api3.getPolicyIds().size());

    // Now, get the API and check that it's OK
    Auth auth3 = dataManager.getAuthById("id2");
    assertEquals("Auth has no policy", 0, auth3.getPolicyContexts().size());

    // cleanup
    dataManager.removeApi(api.getId());
    dataManager.removeAuth(auth.getId());
  }
View Full Code Here

    api.setApiDetail(new ApiDetail());
    api.setId("id51");
    dataManager.addApi(api);

    // Add a new Auth
    Auth auth = new Auth();
    auth.setId("id52");
    auth.setStatus(StatusType.ACTIVE);
    auth.setAuthDetail(new AuthDetail());
    auth.getAuthDetail().setType(NBAuthType.AUTHKEY);
    auth.getAuthDetail().setAuthKeyValue("authKey20");
    dataManager.addAuth(auth);

    // Add a new Policy
    Policy policy = new Policy();
    policy.setId("id53");
    policy.getApiIds().add(api.getId());
    QuotaRLBucket authIds = new QuotaRLBucket();
    authIds.setId("bucketId");
    authIds.getAuthIds().add(auth.getId());
    policy.getAuthIds().add(authIds);
    dataManager.addPolicy(policy);

    dataManager.removeApi(api.getId());

    // Now, get the Policy and check that it's OK
    Policy policy2 = dataManager.getPolicyById(policy.getId());
    assertEquals("Policy has no API id", 0, policy2.getApiIds().size());

    // cleanup
    dataManager.removeAuth(auth.getId());
  }
View Full Code Here

    api.setId("id61");
    api.setApiDetail(new ApiDetail());
    dataManager.addApi(api);

    // Add a new Auth
    Auth auth = new Auth();
    auth.setId("id62");
    auth.setStatus(StatusType.ACTIVE);
    auth.setAuthDetail(new AuthDetail());
    auth.getAuthDetail().setType(NBAuthType.AUTHKEY);
    auth.getAuthDetail().setAuthKeyValue("authKey30");
    dataManager.addAuth(auth);

    // Add a new Policy
    QuotaRLBucket authIds = new QuotaRLBucket();
    authIds.setId("id63");
    authIds.getAuthIds().add(auth.getId());

    Policy policy = new Policy();
    policy.setId("id64");
    policy.getApiIds().add(api.getId());
    policy.getAuthIds().add(authIds);
    dataManager.addPolicy(policy);

    dataManager.removeAuth(auth.getId());

    // Now, get the Policy and check that it's OK
    Policy policy2 = dataManager.getPolicyById(policy.getId());
    assertEquals("Policy has no Auth id", 0, policy2.getAuthIds().get(0).getAuthIds().size());
View Full Code Here

TOP

Related Classes of com.alu.e3.data.model.Auth

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.