Search in sources :

Example 11 with AdminClient

use of edu.uiuc.ncsa.myproxy.oa4mp.server.admin.adminClient.AdminClient in project OA4MP by ncsa.

the class ResponseSerializer method serialize.

protected void serialize(ListAdminsResponse response, HttpServletResponse servletResponse) throws IOException {
    JSONArray adminIDs = new JSONArray();
    if (response.getAdmins() != null) {
        for (AdminClient client : response.getAdmins()) {
            adminIDs.add(client.getIdentifierString());
        }
    }
    PrintWriter pw = servletResponse.getWriter();
    JSONObject json = new JSONObject();
    json.put("status", 0);
    json.put("content", adminIDs);
    pw.println(json);
}
Also used : JSONObject(net.sf.json.JSONObject) JSONArray(net.sf.json.JSONArray) AdminClient(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.adminClient.AdminClient) PrintWriter(java.io.PrintWriter)

Example 12 with AdminClient

use of edu.uiuc.ncsa.myproxy.oa4mp.server.admin.adminClient.AdminClient in project OA4MP by ncsa.

the class AdminClientServer method get.

public AbstractACResponse get(ACGetRequest request) {
    if (request.getAdminClient().getIdentifierString().length() == 0) {
        throw new GeneralException("Error: No supplied admin client identifier.");
    }
    AdminClient adminClient = getAdminClientStore().get(request.getAdminClient().getIdentifier());
    // do not return the secret or its hash
    adminClient.setSecret("");
    return new ACGetResponse(adminClient, cose.getClientApprovalStore().isApproved(adminClient.getIdentifier()));
}
Also used : GeneralException(edu.uiuc.ncsa.security.core.exceptions.GeneralException) AdminClient(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.adminClient.AdminClient)

Example 13 with AdminClient

use of edu.uiuc.ncsa.myproxy.oa4mp.server.admin.adminClient.AdminClient in project OA4MP by ncsa.

the class AttributeServer method getAdminClientAttributes.

protected AttributeGetAdminClientResponse getAdminClientAttributes(AttributeGetRequest request) {
    AdminClient adminClient = getAdminClientStore().get(request.getAdminClient().getIdentifier());
    AttributeGetAdminClientResponse response = new AttributeGetAdminClientResponse(subset(adminClient, request.attributes), request.attributes);
    return response;
}
Also used : AdminClient(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.adminClient.AdminClient)

Example 14 with AdminClient

use of edu.uiuc.ncsa.myproxy.oa4mp.server.admin.adminClient.AdminClient in project OA4MP by ncsa.

the class AttributeServer method setAdminClientAttribute.

protected AttributeAdminClientResponse setAdminClientAttribute(AttributeSetClientRequest request) {
    AdminClient client = getAdminClientStore().get(request.getAdminClient().getIdentifier());
    ColumnMap map = new ColumnMap();
    getACConverter().toMap(client, map);
    for (String key : request.getAttributes().keySet()) {
        // don't let anyone change the identifier.
        if (!key.equals(getACConverter().getKeys().identifier())) {
            map.put(key, request.getAttributes().get(key));
        }
    }
    AdminClient updatedClient = getACConverter().fromMap(map, null);
    getAdminClientStore().save(updatedClient);
    AttributeAdminClientResponse attributeClientResponse = new AttributeAdminClientResponse(updatedClient);
    return attributeClientResponse;
}
Also used : ColumnMap(edu.uiuc.ncsa.security.storage.sql.internals.ColumnMap) AdminClient(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.adminClient.AdminClient)

Example 15 with AdminClient

use of edu.uiuc.ncsa.myproxy.oa4mp.server.admin.adminClient.AdminClient in project OA4MP by ncsa.

the class OA2ATServlet method populateClaims.

protected Map<String, String> populateClaims(HttpServletRequest request, Map<String, String> p, OA2ServiceTransaction st) {
    OA2SE oa2se = (OA2SE) getServiceEnvironment();
    String issuer = null;
    // So in order
    // 1. get the issuer from the admin client
    List<Identifier> admins = oa2se.getPermissionStore().getAdmins(st.getClient().getIdentifier());
    for (Identifier adminID : admins) {
        AdminClient ac = oa2se.getAdminClientStore().get(adminID);
        if (ac != null) {
            if (ac.getIssuer() != null) {
                issuer = ac.getIssuer();
                break;
            }
        }
    }
    // 2. If the admin client does not have an issuer set, see if the client has one
    if (issuer == null) {
        issuer = ((OA2Client) st.getClient()).getIssuer();
    }
    // The discovery servlet will try to use the server default or construct the issuer
    if (issuer == null) {
        issuer = OA2DiscoveryServlet.getIssuer(request);
    }
    p.put(OA2Claims.ISSUER, issuer);
    p.put(OA2Claims.SUBJECT, st.getUsername());
    if (st.hasAuthTime()) {
        // convert the date to a time if needed.
        p.put(OA2Constants.AUTHORIZATION_TIME, Long.toString(st.getAuthTime().getTime() / 1000));
    }
    return p;
}
Also used : BasicIdentifier(edu.uiuc.ncsa.security.core.util.BasicIdentifier) Identifier(edu.uiuc.ncsa.security.core.Identifier) OA2SE(edu.uiuc.ncsa.myproxy.oa4mp.oauth2.OA2SE) AdminClient(edu.uiuc.ncsa.myproxy.oa4mp.server.admin.adminClient.AdminClient)

Aggregations

AdminClient (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.adminClient.AdminClient)20 Permission (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.permissions.Permission)5 Identifier (edu.uiuc.ncsa.security.core.Identifier)4 OA2Client (edu.uiuc.ncsa.security.oauth_2_0.OA2Client)4 TypePermission (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.types.TypePermission)3 ColumnMap (edu.uiuc.ncsa.security.storage.sql.internals.ColumnMap)3 JSONObject (net.sf.json.JSONObject)3 AdminClientKeys (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.adminClient.AdminClientKeys)2 PermissionList (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.permissions.PermissionList)2 PrintWriter (java.io.PrintWriter)2 LinkedList (java.util.LinkedList)2 OA2SE (edu.uiuc.ncsa.myproxy.oa4mp.oauth2.OA2SE)1 AddClientRequest (edu.uiuc.ncsa.myproxy.oa4mp.oauth2.cm.util.permissions.AddClientRequest)1 PermissionServer (edu.uiuc.ncsa.myproxy.oa4mp.oauth2.cm.util.permissions.PermissionServer)1 ActionAdd (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.actions.ActionAdd)1 ActionList (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.actions.ActionList)1 TypeClient (edu.uiuc.ncsa.myproxy.oa4mp.server.admin.things.types.TypeClient)1 GeneralException (edu.uiuc.ncsa.security.core.exceptions.GeneralException)1 BasicIdentifier (edu.uiuc.ncsa.security.core.util.BasicIdentifier)1 ClientApproval (edu.uiuc.ncsa.security.delegation.server.storage.ClientApproval)1