Search in sources :

Example 11 with Client

use of edu.uiuc.ncsa.security.delegation.storage.Client in project OA4MP by ncsa.

the class ClientStoreTest method testBasic.

@Test
public void testBasic() throws Exception {
    Client client = getClientStore().create();
    System.out.println("New client ID = " + client.getIdentifier());
    client.setHomeUri("urn:test:/home/uri");
    client.setSecret(getRandomString(256));
    client.setName("Test delegation client");
    client.setEmail("test@email.foo.edu");
    client.setErrorUri("uri:test:/uh/oh/uri");
    client.setProxyLimited(true);
    getClientStore().save(client);
    Client client2 = getClientStore().get(client.getIdentifier());
    assert client.equals(client2);
    getClientStore().remove(client.getIdentifier());
}
Also used : Client(edu.uiuc.ncsa.security.delegation.storage.Client) Test(org.junit.Test)

Example 12 with Client

use of edu.uiuc.ncsa.security.delegation.storage.Client in project OA4MP by ncsa.

the class NewCAStoreTest method testApprovalStore.

public void testApprovalStore(ClientStore clientStore, ClientApprovalStore caStore) throws Exception {
    // put one in, get it back, make sure it matches.
    Client client = (Client) clientStore.create();
    client.setHomeUri("urn:test:/home/uri/" + getRandomString(32));
    client.setSecret(getRandomString(256));
    client.setName("Test client" + getRandomString(32));
    client.setEmail(getRandomString(32) + "@email.foo.edu");
    client.setErrorUri("uri:test:/uh/oh/uri/" + getRandomString(32));
    clientStore.save(client);
    ClientApproval ca = (ClientApproval) caStore.create();
    ca.setApprover("test-approver");
    ca.setApproved(true);
    ca.setApprovalTimestamp(new Date());
    ca.setIdentifier(client.getIdentifier());
    caStore.save(ca);
    ClientApproval ca1 = (ClientApproval) caStore.get(ca.getIdentifier());
    assert ca.equals(ca1);
    caStore.remove(ca.getIdentifier());
    clientStore.remove(client);
}
Also used : ClientApproval(edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval) Client(edu.uiuc.ncsa.security.delegation.storage.Client) Date(java.util.Date)

Example 13 with Client

use of edu.uiuc.ncsa.security.delegation.storage.Client in project OA4MP by ncsa.

the class MyProxyDelegationServlet method getClient.

public Client getClient(Identifier identifier) {
    if (identifier == null) {
        throw new UnknownClientException("no client id");
    }
    Client c = getServiceEnvironment().getClientStore().get(identifier);
    if (c == null) {
        DebugUtil.dbg(this, "client name is " + getServiceEnvironment().getClientStore().getClass().getSimpleName());
        DebugUtil.dbg(this, "client store is a " + getServiceEnvironment().getClientStore());
        if (getServiceEnvironment().getClientStore().size() == 0) {
            System.err.println("NO ENTRIES IN CLIENT STORE");
        } else {
            System.err.println("Store contains " + getServiceEnvironment().getClientStore().size() + " entries.");
        }
        System.err.println("printing identifiers...");
        for (Identifier x : getServiceEnvironment().getClientStore().keySet()) {
            System.err.println(x);
        }
        System.err.println("done!");
        String ww = "The client with identifier \"" + identifier.toString() + "\"  cannot be found.";
        warn(ww + " Client store is " + getServiceEnvironment().getClientStore());
        throw new UnknownClientException(ww + "  Is the value in the client config correct?", identifier);
    }
    checkClientApproval(c);
    return c;
}
Also used : BasicIdentifier(edu.uiuc.ncsa.security.core.util.BasicIdentifier) Identifier(edu.uiuc.ncsa.security.core.Identifier) UnknownClientException(edu.uiuc.ncsa.security.core.exceptions.UnknownClientException) Client(edu.uiuc.ncsa.security.delegation.storage.Client)

Example 14 with Client

use of edu.uiuc.ncsa.security.delegation.storage.Client in project OA4MP by ncsa.

the class RegistrationServlet method addNewClient.

@Override
protected Client addNewClient(HttpServletRequest request, HttpServletResponse response) throws Throwable {
    Client client = super.addNewClient(request, response);
    client.setSecret(getRequiredParam(request, CLIENT_PUBLIC_KEY, client));
    String x = getRequiredParam(request, CLIENT_ERROR_URL, client);
    if (!x.toLowerCase().startsWith("https")) {
        throw new RetryException("The error uri \"" + x + "\" is not secure.");
    }
    client.setErrorUri(x);
    try {
        debug("decoding public key from PEM");
        KeyUtil.fromX509PEM(client.getSecret());
    } catch (Throwable t) {
        warn("could not decode public key for client=" + client.getIdentifierString() + ", message:" + t.getMessage());
        request.setAttribute("client", client);
        throw new RetryException("public key could not be parsed. " + t.getMessage());
    }
    fireNewClientEvent(client);
    return client;
}
Also used : Client(edu.uiuc.ncsa.security.delegation.storage.Client) RetryException(edu.uiuc.ncsa.security.core.exceptions.RetryException)

Example 15 with Client

use of edu.uiuc.ncsa.security.delegation.storage.Client in project OA4MP by ncsa.

the class NewClientNotifier method fireNewClientEvent.

@Override
public void fireNewClientEvent(NewClientEvent notificationEvent) {
    if (!mailUtil.isEnabled()) {
        return;
    }
    Client client = notificationEvent.getClient();
    Map<String, String> replacements = getReplacements(client);
    boolean rc = mailUtil.sendMessage(replacements);
    if (rc) {
        loggingFacade.info("sending email notification for client " + client.getIdentifierString());
    } else {
        loggingFacade.info("failure sending email notification for client " + client.getIdentifierString());
    }
}
Also used : Client(edu.uiuc.ncsa.security.delegation.storage.Client)

Aggregations

Client (edu.uiuc.ncsa.security.delegation.storage.Client)26 BasicIdentifier (edu.uiuc.ncsa.security.core.util.BasicIdentifier)8 Test (org.junit.Test)7 ClientApproval (edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval)6 Date (java.util.Date)6 Identifier (edu.uiuc.ncsa.security.core.Identifier)5 OA4MPIdentifierProvider (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.transactions.OA4MPIdentifierProvider)3 OA2ClientMemoryStore (edu.uiuc.ncsa.myproxy.oa4mp.oauth2.storage.OA2ClientMemoryStore)2 OA4MPServiceTransaction (edu.uiuc.ncsa.myproxy.oa4mp.server.OA4MPServiceTransaction)2 UnknownClientException (edu.uiuc.ncsa.security.core.exceptions.UnknownClientException)2 ClientProvider (edu.uiuc.ncsa.security.delegation.storage.ClientProvider)2 ClientConverter (edu.uiuc.ncsa.security.delegation.storage.impl.ClientConverter)2 OA2Client (edu.uiuc.ncsa.security.oauth_2_0.OA2Client)2 OA2ClientConverter (edu.uiuc.ncsa.security.oauth_2_0.OA2ClientConverter)2 OA2ClientProvider (edu.uiuc.ncsa.security.oauth_2_0.OA2ClientProvider)2 JSONObject (net.sf.json.JSONObject)2 OA4MPServiceProvider (edu.uiuc.ncsa.myproxy.oa4mp.client.OA4MPServiceProvider)1 AssetProvider (edu.uiuc.ncsa.myproxy.oa4mp.client.storage.AssetProvider)1 AdminClient (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.adminClient.AdminClient)1 MultiDSClientStoreProvider (edu.uiuc.ncsa.myproxy.oa4mp.server.storage.MultiDSClientStoreProvider)1