Search in sources :

Example 21 with Client

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

the class NewCAStoreTest method testApprovalCycle.

public void testApprovalCycle(ClientStore clientStore, ClientApprovalStore caStore) throws Exception {
    assert !caStore.isApproved(BasicIdentifier.newID("foo:bar:baz://" + getRandomString(32)));
    Client client = (Client) clientStore.create();
    Identifier identifier = client.getIdentifier();
    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(false);
    ca.setApprovalTimestamp(new Date());
    ca.setIdentifier(identifier);
    caStore.save(ca);
    assert !((ClientApproval) caStore.get(client.getIdentifier())).isApproved();
    assert !caStore.isApproved(identifier);
    ca.setApproved(true);
    caStore.save(ca);
    // Regression test to be sure that identifiers are never changed.
    assert identifier.equals(ca.getIdentifier());
    assert identifier.equals(client.getIdentifier());
    assert ((ClientApproval) caStore.get(client.getIdentifier())).isApproved();
    assert caStore.isApproved(identifier);
    caStore.remove(client.getIdentifier());
    clientStore.remove(client.getIdentifier());
}
Also used : BasicIdentifier(edu.uiuc.ncsa.security.core.util.BasicIdentifier) Identifier(edu.uiuc.ncsa.security.core.Identifier) ClientApproval(edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval) Client(edu.uiuc.ncsa.security.delegation.storage.Client) Date(java.util.Date)

Example 22 with Client

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

the class ClientStoreCommands method longFormat.

@Override
protected void longFormat(Identifiable identifiable) {
    super.longFormat(identifiable);
    Client client = (Client) identifiable;
    sayi("home uri=" + client.getHomeUri());
    sayi("error uri=" + client.getErrorUri());
    sayi("limited proxies? " + client.isProxyLimited());
}
Also used : Client(edu.uiuc.ncsa.security.delegation.storage.Client)

Example 23 with Client

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

the class ClientStoreUtil method create.

@Override
public void create() throws Exception {
    boolean tryAgain = true;
    Identifier id = null;
    Client c = null;
    while (tryAgain) {
        say2("enter the id of the object you want to create or return for a random one");
        String inLine = readline();
        if (!(inLine == null || inLine.length() == 0)) {
            try {
                id = BasicIdentifier.newID(inLine);
            } catch (Throwable t) {
                say2("That is not a valid uri. Try again (y/n)?");
                inLine = readline().trim().toLowerCase();
                tryAgain = inLine.equals("y");
            }
        } else {
            tryAgain = false;
        }
    }
    // end input loop.
    c = (Client) getSE().getClientStore().create();
    if (id == null) {
    // use random one
    } else {
        if (getSE().getClientStore().containsKey(id)) {
        // something should happen since this exists.
        }
        c.setIdentifier(id);
    }
    // now invoke updater on the new item.
    update(c);
    getSE().getClientStore().save(c);
}
Also used : BasicIdentifier(edu.uiuc.ncsa.security.core.util.BasicIdentifier) Identifier(edu.uiuc.ncsa.security.core.Identifier) Client(edu.uiuc.ncsa.security.delegation.storage.Client)

Example 24 with Client

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

the class AbstractRegistrationServlet method addNewClient.

protected Client addNewClient(HttpServletRequest request, HttpServletResponse response) throws Throwable {
    // Assumption is that the request is in good order and we just have to pull stuff off it.
    Client client = getServiceEnvironment().getClientStore().create();
    info("creating entry for client=" + client.getIdentifierString());
    // Fill in as much info as we can before parsing public key.
    // We always store exactly what was given to us, though later we html escape it to
    // prevent against HTML injection attacks (fixes bug OAUTH-87).
    client.setName(getRequiredParam(request, CLIENT_NAME, client));
    client.setHomeUri(getRequiredParam(request, CLIENT_HOME_URL, client));
    String x = getRequiredParam(request, CLIENT_EMAIL, client);
    java.util.regex.Pattern p = java.util.regex.Pattern.compile(emailPattern);
    java.util.regex.Matcher m = p.matcher(x);
    if (!m.matches()) {
        throw new ClientRegistrationRetryException("The email address \"" + x + "\" is not valid.", null, client);
    }
    client.setEmail(x);
    client.setProxyLimited(getBooleanParam(request, CLIENT_PROXY_LIMITED));
    getServiceEnvironment().getClientStore().save(client);
    info("Adding approval record for client=" + client.getIdentifierString());
    ClientApproval clientApproval = new ClientApproval(client.getIdentifier());
    clientApproval.setApproved(false);
    info("done with client registration, client=" + client.getIdentifierString());
    // Failure to do so will turn off the ability to email new client registrations!
    return client;
}
Also used : ClientApproval(edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval) Client(edu.uiuc.ncsa.security.delegation.storage.Client)

Example 25 with Client

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

the class AutoRegistrationServlet method addNewClient.

@Override
protected Client addNewClient(HttpServletRequest request, HttpServletResponse response) throws Throwable {
    Client client = super.addNewClient(request, response);
    if (client != null) {
        approveClient(client.getIdentifier(), "auto-approver");
    }
    fireNewClientEvent(client);
    return client;
}
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