Search in sources :

Example 1 with Authority

use of com.yahoo.athenz.auth.Authority in project athenz by yahoo.

the class ZMSClientTest method createPrincipal.

private Principal createPrincipal(String userName) {
    Authority authority = new com.yahoo.athenz.auth.impl.PrincipalAuthority();
    Principal p = SimplePrincipal.create("user", userName, "v=U1;d=user;n=" + userName + ";s=signature", 0, authority);
    return p;
}
Also used : Authority(com.yahoo.athenz.auth.Authority) SimplePrincipal(com.yahoo.athenz.auth.impl.SimplePrincipal) Principal(com.yahoo.athenz.auth.Principal)

Example 2 with Authority

use of com.yahoo.athenz.auth.Authority in project athenz by yahoo.

the class ZMSImpl method getAuthority.

Authority getAuthority(String className) {
    LOG.debug("Loading authority {}...", className);
    Authority authority = null;
    try {
        authority = (Authority) Class.forName(className).newInstance();
    } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
        LOG.error("Invalid Authority class: " + className + " error: " + e.getMessage());
        return null;
    }
    return authority;
}
Also used : Authority(com.yahoo.athenz.auth.Authority)

Example 3 with Authority

use of com.yahoo.athenz.auth.Authority in project athenz by yahoo.

the class ZMSImpl method isValidUserTokenRequest.

boolean isValidUserTokenRequest(Principal principal, String userName) {
    if (principal == null) {
        return false;
    }
    Authority authority = principal.getAuthority();
    if (authority == null) {
        return false;
    }
    if (authority.allowAuthorization()) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("User Token request - Authority cannot request user tokens");
        }
        return false;
    }
    String authDomain = authority.getDomain();
    if (authDomain == null || !authDomain.equalsIgnoreCase(userDomain)) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("User Token request - not authenticated by User Authority");
        }
        return false;
    }
    if (userName.equalsIgnoreCase(USER_TOKEN_DEFAULT_NAME)) {
        return true;
    }
    if (!userName.equalsIgnoreCase(principal.getName())) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("User Token request - mismatch between request user name and userid");
        }
        return false;
    }
    return true;
}
Also used : Authority(com.yahoo.athenz.auth.Authority)

Example 4 with Authority

use of com.yahoo.athenz.auth.Authority in project athenz by yahoo.

the class ProviderMockClientTest method testPutTenantResourceGroup.

@Test
public void testPutTenantResourceGroup() {
    String systemAdminUser = "user.user_admin";
    Authority authority = new com.yahoo.athenz.auth.impl.PrincipalAuthority();
    Principal p = SimplePrincipal.create("user", systemAdminUser, "v=U1;d=user;n=" + systemAdminUser + ";s=signature", 0, authority);
    ProviderMockClient provider = new ProviderMockClient("localhost:3306/athenz", p);
    TenantResourceGroup tenant = new TenantResourceGroup();
    tenant.setName("name");
    assertNull(provider.putTenantResourceGroup("providerService1", "tenantDom1", "zms", "zms", tenant));
}
Also used : Authority(com.yahoo.athenz.auth.Authority) Principal(com.yahoo.athenz.auth.Principal) SimplePrincipal(com.yahoo.athenz.auth.impl.SimplePrincipal) Test(org.testng.annotations.Test)

Example 5 with Authority

use of com.yahoo.athenz.auth.Authority in project athenz by yahoo.

the class ZTSImplTest method testCheckKerberosAuthorityAuthorization.

@Test
public void testCheckKerberosAuthorityAuthorization() {
    Authority authority = new com.yahoo.athenz.auth.impl.KerberosAuthority();
    Principal principal = SimplePrincipal.create("krb", "user1", "v=U1;d=krb;n=user1;s=signature", 0, authority);
    assertTrue(authorizer.authorityAuthorizationAllowed(principal));
}
Also used : UserAuthority(com.yahoo.athenz.auth.impl.UserAuthority) Authority(com.yahoo.athenz.auth.Authority) CertificateAuthority(com.yahoo.athenz.auth.impl.CertificateAuthority) PrincipalAuthority(com.yahoo.athenz.auth.impl.PrincipalAuthority) SimplePrincipal(com.yahoo.athenz.auth.impl.SimplePrincipal) Principal(com.yahoo.athenz.auth.Principal) Test(org.testng.annotations.Test)

Aggregations

Authority (com.yahoo.athenz.auth.Authority)193 Principal (com.yahoo.athenz.auth.Principal)124 Test (org.testng.annotations.Test)72 PrincipalAuthority (com.yahoo.athenz.auth.impl.PrincipalAuthority)32 SimplePrincipal (com.yahoo.athenz.auth.impl.SimplePrincipal)30 HttpServletRequest (javax.servlet.http.HttpServletRequest)24 AthenzDomain (com.yahoo.athenz.zms.store.AthenzDomain)21 HttpServletResponse (javax.servlet.http.HttpServletResponse)20 ObjectStoreConnection (com.yahoo.athenz.zms.store.ObjectStoreConnection)19 Authorizer (com.yahoo.athenz.auth.Authorizer)15 AuthorityList (com.yahoo.athenz.common.server.rest.Http.AuthorityList)13 ObjectStore (com.yahoo.athenz.zms.store.ObjectStore)11 ServerPrivateKey (com.yahoo.athenz.auth.ServerPrivateKey)9 Timestamp (com.yahoo.rdl.Timestamp)9 Metric (com.yahoo.athenz.common.metrics.Metric)8 IOException (java.io.IOException)8 Response (javax.ws.rs.core.Response)6 Struct (com.yahoo.rdl.Struct)5 UnsupportedEncodingException (java.io.UnsupportedEncodingException)5 WebApplicationException (javax.ws.rs.WebApplicationException)5