Search in sources :

Example 6 with RealmInfo

use of org.forgerock.openam.core.RealmInfo in project OpenAM by OpenRock.

the class OpenAMOAuth2UrisFactory method get.

/**
     * Gets a OAuth2Uris instance.
     *
     * @param request TODO
     * @return A UmaProviderSettings instance.
     */
@Override
public OAuth2Uris get(final OAuth2Request request) throws NotFoundException, ServerException {
    RealmInfo realmInfo = request.getParameter(RestletRealmRouter.REALM_INFO);
    HttpServletRequest req = ServletUtils.getRequest(request.<Request>getRequest());
    return get(req, realmInfo);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) RealmInfo(org.forgerock.openam.core.RealmInfo)

Example 7 with RealmInfo

use of org.forgerock.openam.core.RealmInfo in project OpenAM by OpenRock.

the class OpenAMResourceSetStoreTest method setup.

@BeforeMethod
@SuppressWarnings("unchecked")
public void setup() throws Exception {
    dataStore = mock(TokenDataStore.class);
    OAuth2ProviderSettingsFactory providerSettingsFactory = mock(OAuth2ProviderSettingsFactory.class);
    OAuth2UrisFactory<RealmInfo> oAuth2UrisFactory = mock(OAuth2UrisFactory.class);
    OAuth2Uris oAuth2Uris = mock(OAuth2Uris.class);
    TokenIdGenerator idGenerator = mock(TokenIdGenerator.class);
    store = new OpenAMResourceSetStore("REALM", providerSettingsFactory, oAuth2UrisFactory, idGenerator, dataStore);
    given(oAuth2UrisFactory.get(Matchers.<OAuth2Request>anyObject())).willReturn(oAuth2Uris);
    given(oAuth2Uris.getResourceSetRegistrationPolicyEndpoint(anyString())).willReturn("POLICY_URI");
}
Also used : TokenDataStore(org.forgerock.openam.sm.datalayer.store.TokenDataStore) RealmInfo(org.forgerock.openam.core.RealmInfo) TokenIdGenerator(org.forgerock.openam.cts.api.tokens.TokenIdGenerator) OAuth2ProviderSettingsFactory(org.forgerock.oauth2.core.OAuth2ProviderSettingsFactory) OAuth2Uris(org.forgerock.oauth2.core.OAuth2Uris) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 8 with RealmInfo

use of org.forgerock.openam.core.RealmInfo in project OpenAM by OpenRock.

the class RestletRealmRouter method getRealmFromURI.

private RealmInfo getRealmFromURI(Request request) {
    RealmInfo realmInfo = (RealmInfo) request.getAttributes().get(REALM_INFO);
    String subrealm = (String) request.getAttributes().get("subrealm");
    if (subrealm != null && !subrealm.isEmpty()) {
        if (realmInfo == null) {
            throw new IllegalStateException("RealmInfo is null! Has not been set from server name");
        } else {
            return realmInfo.appendUriRealm(subrealm);
        }
    }
    return null;
}
Also used : RealmInfo(org.forgerock.openam.core.RealmInfo)

Example 9 with RealmInfo

use of org.forgerock.openam.core.RealmInfo in project OpenAM by OpenRock.

the class RestletRealmRouter method getRealmFromServerName.

private RealmInfo getRealmFromServerName(Request request) {
    String serverName = request.getHostRef().getHostDomain();
    try {
        SSOToken adminToken = coreWrapper.getAdminToken();
        String orgDN = coreWrapper.getOrganization(adminToken, serverName);
        return new RealmInfo(coreWrapper.convertOrgNameToRealmName(orgDN));
    } catch (IdRepoException | SSOException e) {
        throw new ResourceException(Status.SERVER_ERROR_INTERNAL, e);
    }
}
Also used : RealmInfo(org.forgerock.openam.core.RealmInfo) SSOToken(com.iplanet.sso.SSOToken) IdRepoException(com.sun.identity.idm.IdRepoException) SSOException(com.iplanet.sso.SSOException) ResourceException(org.restlet.resource.ResourceException)

Example 10 with RealmInfo

use of org.forgerock.openam.core.RealmInfo in project OpenAM by OpenRock.

the class RestletRealmRouterTest method setUpServerName.

private void setUpServerName(Request request, SSOToken adminToken, String realm) throws IdRepoException, SSOException {
    Reference reference = request.getResourceRef();
    given(request.getHostRef()).willReturn(reference);
    given(reference.getHostDomain()).willReturn("HOST_DOMAIN");
    given(coreWrapper.getOrganization(adminToken, "HOST_DOMAIN")).willReturn("REALM_HOST_DN");
    given(coreWrapper.convertOrgNameToRealmName("REALM_HOST_DN")).willReturn(realm.equals("/") ? realm : "/" + realm);
    request.getAttributes().put(RestletRealmRouter.REALM_INFO, new RealmInfo("/"));
}
Also used : RealmInfo(org.forgerock.openam.core.RealmInfo) Reference(org.restlet.data.Reference)

Aggregations

RealmInfo (org.forgerock.openam.core.RealmInfo)10 OAuth2ProviderSettingsFactory (org.forgerock.oauth2.core.OAuth2ProviderSettingsFactory)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 BeforeMethod (org.testng.annotations.BeforeMethod)3 SSOException (com.iplanet.sso.SSOException)2 SSOToken (com.iplanet.sso.SSOToken)2 IdRepoException (com.sun.identity.idm.IdRepoException)2 ClientRegistrationStore (org.forgerock.oauth2.core.ClientRegistrationStore)2 OAuth2Request (org.forgerock.oauth2.core.OAuth2Request)2 OAuth2Uris (org.forgerock.oauth2.core.OAuth2Uris)2 TokenStore (org.forgerock.oauth2.core.TokenStore)2 TypeLiteral (com.google.inject.TypeLiteral)1 FactoryModuleBuilder (com.google.inject.assistedinject.FactoryModuleBuilder)1 Evaluator (com.sun.identity.entitlement.Evaluator)1 KeyPair (java.security.KeyPair)1 PublicKey (java.security.PublicKey)1 HashMap (java.util.HashMap)1 Subject (javax.security.auth.Subject)1 SignedJwt (org.forgerock.json.jose.jws.SignedJwt)1 AccessToken (org.forgerock.oauth2.core.AccessToken)1