Search in sources :

Example 11 with UserInfo

use of org.neo4j.ogm.domain.gh777.UserInfo in project archiva-redback-core by apache.

the class UserServiceTest method getUsers.

@Test
public void getUsers() throws Exception {
    String adminHeader = getAdminAuthzHeader();
    UserService userService = getUserService(adminHeader);
    PagedResult<UserInfo> users = userService.getUsers("", 0, Integer.MAX_VALUE, Collections.emptyList(), "asc");
    assertNotNull(users);
    assertFalse(users.getData().isEmpty());
}
Also used : UserService(org.apache.archiva.redback.rest.api.services.v2.UserService) UserInfo(org.apache.archiva.redback.rest.api.model.v2.UserInfo) Test(org.junit.jupiter.api.Test)

Example 12 with UserInfo

use of org.neo4j.ogm.domain.gh777.UserInfo in project archiva-redback-core by apache.

the class UserServiceTest method registerNoUrl.

@Test
public void registerNoUrl() throws Exception {
    try {
        ServicesAssert assertService = JAXRSClientFactory.create("http://localhost:" + getServerPort() + "/" + getRestServicesPath() + "/testsService/", ServicesAssert.class, Collections.singletonList(getJsonProvider()));
        assertService.clearEmailMessages();
        UserService service = getUserService(getAdminAuthzHeader());
        User u = new User();
        u.setFullName("the toto");
        u.setUserId("toto");
        u.setEmail("toto@toto.fr");
        u.setPassword("toto123");
        u.setConfirmPassword("toto123");
        String key = service.registerUser(u.getUserId(), new UserRegistrationRequest(u, null)).getKey();
        assertNotEquals("-1", key);
        List<EmailMessage> emailMessages = assertService.getEmailMessageSended();
        assertEquals(1, emailMessages.size());
        assertEquals("toto@toto.fr", emailMessages.get(0).getTos().get(0));
        assertEquals("Welcome", emailMessages.get(0).getSubject());
        String messageContent = emailMessages.get(0).getText();
        log.info("messageContent: {}", messageContent);
        assertNotNull(messageContent);
        assertTrue(messageContent.contains("Use the following URL to validate your account."));
        assertTrue(messageContent.contains("http://localhost:" + getServerPort()));
        assertTrue(messageContent.toLowerCase().contains("toto"));
        // assertTrue( service.validateUserFromKey( key ).isSuccess( ) );
        service = getUserService(getAdminAuthzHeader());
        UserInfo uInfo = service.getUser("toto");
        assertNotNull(uInfo);
        assertFalse(uInfo.isValidated());
        assertTrue(uInfo.isPasswordChangeRequired());
    // assertTrue( service.validateUserFromKey( key ).isSuccess( ) );
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw e;
    } finally {
        deleteUserQuietly("toto");
    }
}
Also used : EmailMessage(org.apache.archiva.redback.rest.services.mock.EmailMessage) User(org.apache.archiva.redback.rest.api.model.v2.User) UserService(org.apache.archiva.redback.rest.api.services.v2.UserService) ServicesAssert(org.apache.archiva.redback.rest.services.mock.ServicesAssert) UserInfo(org.apache.archiva.redback.rest.api.model.v2.UserInfo) UserRegistrationRequest(org.apache.archiva.redback.rest.api.model.v2.UserRegistrationRequest) ForbiddenException(javax.ws.rs.ForbiddenException) NotFoundException(javax.ws.rs.NotFoundException) Test(org.junit.jupiter.api.Test)

Example 13 with UserInfo

use of org.neo4j.ogm.domain.gh777.UserInfo in project OA4MP by ncsa.

the class LDAPClaimsSource method main.

public static void main(String[] args) {
    try {
        String rawLdap = "{\"ldap\":{\"failOnError\":\"false\"," + "\"address\":\"ldap.ncsa.illinois.edu\"," + "\"port\":636," + "\"enabled\":\"true\"," + "\"authorizationType\":\"none\"," + "\"searchName\":\"eppn\"," + "\"searchAttributes\":[{" + "\"name\":\"mail\"," + "\"returnAsList\":false," + "\"returnName\":\"mail\"}," + "{\"name\":\"cn\"," + "\"returnAsList\":false," + "\"returnName\":\"name\"}," + "{\"name\":\"memberOf\"," + "\"returnAsList\":false," + "\"isGroup\":true," + "\"returnName\":\"isMemberOf\"}]," + "\"searchBase\":\"ou=People,dc=ncsa,dc=illinois,dc=edu\"," + "\"contextName\":\"\"," + "\"ssl\":{\"tlsVersion\":\"TLS\",\"useJavaTrustStore\":true}}}";
        String rawLdap2 = "{\"ldap\": {\n" + "  \"address\": \"registry-test.cilogon.org\",\n" + "  \"port\": 636,\n" + "  \"enabled\": true,\n" + "  \"authorizationType\": \"simple\",\n" + "  \"failOnError\": false,\n" + "  \"notifyOnFail\": false,\n" + "  \"password\": \"Eavjofoop4gikpecUzbooljorUryikwu\",\n" + "  \"principal\": \"uid=oa4mp_user,ou=system,o=ImPACT,dc=cilogon,dc=org\",\n" + "  \"searchAttributes\":   [\n" + "        {\n" + "      \"name\": \"isMemberOf\",\n" + "      \"returnAsList\": true,\n" + "      \"returnName\": \"isMemberOf\"\n" + "    },\n" + "        {\n" + "      \"name\": \"employeeNumber\",\n" + "      \"returnAsList\": false,\n" + "      \"returnName\": \"employeeNumber\"\n" + "    }\n" + "  ],\n" + "  \"searchBase\": \"ou=people,o=ImPACT,dc=cilogon,dc=org\",\n" + "  \"searchName\": \"username\",\n" + "  \"contextName\": \"\",\n" + "  \"ssl\":   {\n" + "    \"keystore\": {},\n" + "    \"useJavaTrustStore\": true,\n" + "    \"password\": \"changeit\",\n" + "    \"type\": \"jks\"\n" + "  }\n" + "}}";
        DebugUtil.setIsEnabled(true);
        ServiceTransaction st = new ServiceTransaction(BasicIdentifier.newID("foo"));
        st.setUsername("jbasney@ncsa.illinois.edu");
        JSONObject json = JSONObject.fromObject(rawLdap);
        LDAPConfiguration cfg = LDAPConfigurationUtil.fromJSON(json);
        LDAPClaimsSource claimsSource = new LDAPClaimsSource(cfg, null);
        UserInfo ui = new UserInfo();
        ui.getMap().put("username", "jbasney@ncsa.illinois.edu");
        ui.getMap().put("eppn", "jbasney@ncsa.illinois.edu");
        UserInfo ui2 = claimsSource.process(ui, st);
        System.out.println("Result of LDAP query:");
        System.out.println(ui2.getMap());
    // getGid(cfg, "lsst_users");
    } catch (Throwable t) {
        t.printStackTrace();
    }
}
Also used : JSONObject(net.sf.json.JSONObject) ServiceTransaction(edu.uiuc.ncsa.security.delegation.server.ServiceTransaction) UserInfo(edu.uiuc.ncsa.security.oauth_2_0.UserInfo) LDAPConfiguration(edu.uiuc.ncsa.security.oauth_2_0.server.config.LDAPConfiguration)

Example 14 with UserInfo

use of org.neo4j.ogm.domain.gh777.UserInfo in project OA4MP by ncsa.

the class OA2TestCommands method getuserinfo.

public void getuserinfo(InputLine inputLine) throws Exception {
    if (showHelp(inputLine)) {
        getUIHelp();
        return;
    }
    UserInfo userInfo = getOA2S().getUserInfo(dummyAsset.getIdentifier().toString());
    say("user info:");
    for (String key : userInfo.getMap().keySet()) {
        say("          " + key + " = " + userInfo.getMap().get(key));
    }
}
Also used : UserInfo(edu.uiuc.ncsa.security.oauth_2_0.UserInfo)

Example 15 with UserInfo

use of org.neo4j.ogm.domain.gh777.UserInfo in project OA4MP by ncsa.

the class OA2MPService method getUserInfo.

public UserInfo getUserInfo(String identifier) {
    OA2Asset asset = getAsset2(identifier);
    if (asset == null || asset.getAccessToken() == null)
        return null;
    UIRequest uiRequest = new UIRequest(asset.getAccessToken());
    uiRequest.setClient(getEnvironment().getClient());
    DS2 ds2 = (DS2) getEnvironment().getDelegationService();
    UIResponse resp = ds2.getUserInfo(uiRequest);
    JSONObject json = JSONObject.fromObject(resp.getRawJSON());
    UserInfo ui = new UserInfo();
    // return everything, even specialized fields.
    ui.setMap(json);
    // UserInfo ui = (UserInfo) JSONObject.toBean(json, UserInfo.class);
    return ui;
}
Also used : DS2(edu.uiuc.ncsa.security.oauth_2_0.client.DS2) JSONObject(net.sf.json.JSONObject) UserInfo(edu.uiuc.ncsa.security.oauth_2_0.UserInfo)

Aggregations

UserInfo (org.apache.archiva.redback.rest.api.model.v2.UserInfo)19 Test (org.junit.jupiter.api.Test)15 Response (io.restassured.response.Response)8 HashMap (java.util.HashMap)8 UserInfo (edu.uiuc.ncsa.security.oauth_2_0.UserInfo)7 BaseUserInfo (org.apache.archiva.redback.rest.api.model.v2.BaseUserInfo)7 UserService (org.apache.archiva.redback.rest.api.services.v2.UserService)6 NotFoundException (javax.ws.rs.NotFoundException)5 User (org.apache.archiva.redback.rest.api.model.v2.User)5 ForbiddenException (javax.ws.rs.ForbiddenException)4 JSONObject (net.sf.json.JSONObject)4 RoleInfo (org.apache.archiva.redback.rest.api.model.v2.RoleInfo)4 List (java.util.List)3 Map (java.util.Map)3 PagedResult (org.apache.archiva.components.rest.model.PagedResult)3 RoleTemplate (org.apache.archiva.redback.rest.api.model.v2.RoleTemplate)3 UserRegistrationRequest (org.apache.archiva.redback.rest.api.model.v2.UserRegistrationRequest)3 RedbackServiceException (org.apache.archiva.redback.rest.api.services.RedbackServiceException)3 EmailMessage (org.apache.archiva.redback.rest.services.mock.EmailMessage)3 ServicesAssert (org.apache.archiva.redback.rest.services.mock.ServicesAssert)3