mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-09-17 14:21:29 +00:00
OIDC first try
This commit is contained in:
@@ -19,10 +19,12 @@
|
||||
|
||||
import { HttpClientModule, HttpClientXsrfModule, HTTP_INTERCEPTORS } from '@angular/common/http';
|
||||
import { APP_INITIALIZER, NgModule } from '@angular/core';
|
||||
import { AlfrescoApiV2Service } from './services/alfresco-api-v2.service';
|
||||
import { AlfrescoApiV2 } from './services/alfresco-api-v2';
|
||||
import { AlfrescoApiClientFactory } from './services/alfresco-api-client.factory';
|
||||
import { AlfrescoApiV2LoaderService, createAlfrescoApiV2Service } from './services/alfresco-api-v2-loader.service';
|
||||
import { AuthBearerInterceptor } from './services/auth-bearer.interceptor';
|
||||
import { LegacyAlfrescoApiServiceFacade } from './services/legacy-alfresco-api-service.facade';
|
||||
import { AlfrescoApiService } from '../services/alfresco-api.service';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
@@ -33,8 +35,9 @@ import { AuthBearerInterceptor } from './services/auth-bearer.interceptor';
|
||||
})
|
||||
],
|
||||
providers: [
|
||||
AlfrescoApiV2Service,
|
||||
AlfrescoApiV2,
|
||||
AlfrescoApiV2LoaderService,
|
||||
LegacyAlfrescoApiServiceFacade,
|
||||
AlfrescoApiClientFactory,
|
||||
{
|
||||
provide: APP_INITIALIZER,
|
||||
@@ -47,6 +50,11 @@ import { AuthBearerInterceptor } from './services/auth-bearer.interceptor';
|
||||
{
|
||||
provide: HTTP_INTERCEPTORS, useClass:
|
||||
AuthBearerInterceptor, multi: true
|
||||
},
|
||||
// Reproviding legacy like service for older code
|
||||
{
|
||||
provide: AlfrescoApiService,
|
||||
useExisting: LegacyAlfrescoApiServiceFacade
|
||||
}
|
||||
]
|
||||
})
|
||||
|
@@ -16,5 +16,5 @@
|
||||
*/
|
||||
|
||||
export * from './alfresco-api.module';
|
||||
export * from './services/alfresco-api-v2.service';
|
||||
export * from './services/alfresco-api-v2';
|
||||
export * from './services/alfresco-api-client.factory';
|
||||
|
67
lib/core/alfresco-api/js-api/alfresco-api-type.ts
Normal file
67
lib/core/alfresco-api/js-api/alfresco-api-type.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2018 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*tslint:disable*/ // => because of ADF file naming problems... Try to remove it, if you don't believe me :P
|
||||
|
||||
import { AlfrescoApiConfig } from '@alfresco/js-api';
|
||||
import { JsApiHttpClient } from './js-api-http-client';
|
||||
|
||||
export interface LegacyTicketApi {
|
||||
getAlfTicket(ticket: string): string;
|
||||
}
|
||||
|
||||
// Extracted from existing AlfrescoApi:
|
||||
export interface AlfrescoApiType {
|
||||
config: AlfrescoApiConfig;
|
||||
contentClient: JsApiHttpClient & LegacyTicketApi;
|
||||
contentPrivateClient: JsApiHttpClient & LegacyTicketApi;
|
||||
processClient: JsApiHttpClient;
|
||||
searchClient: JsApiHttpClient;
|
||||
discoveryClient: JsApiHttpClient;
|
||||
gsClient: JsApiHttpClient;
|
||||
authClient: JsApiHttpClient;
|
||||
processAuth?: JsApiHttpClient;
|
||||
|
||||
setConfig(config: AlfrescoApiConfig): void;
|
||||
changeWithCredentialsConfig(withCredentials: boolean) : void;
|
||||
changeCsrfConfig(disableCsrf: boolean): void;
|
||||
changeEcmHost(hostEcm: string): void;
|
||||
changeBpmHost(hostBpm: string): void;
|
||||
login(username: string, password: string): Promise<any>;
|
||||
isCredentialValid(credential: string): boolean;
|
||||
implicitLogin(): Promise<any>;
|
||||
loginTicket(ticketEcm: string, ticketBpm: string): Promise<any>;
|
||||
logout(): Promise<any>;
|
||||
isLoggedIn(): boolean;
|
||||
isBpmLoggedIn(): boolean;
|
||||
isEcmLoggedIn(): boolean;
|
||||
getBpmUsername(): string;
|
||||
getEcmUsername(): string;
|
||||
refreshToken(): Promise<string>;
|
||||
getTicketAuth(): string;
|
||||
setTicket(ticketEcm: string, TicketBpm: string): void;
|
||||
invalidateSession(): void;
|
||||
getTicketBpm(): string;
|
||||
getTicketEcm(): string;
|
||||
getTicket(): string[];
|
||||
isBpmConfiguration(): boolean;
|
||||
isEcmConfiguration(): boolean;
|
||||
isOauthConfiguration(): boolean;
|
||||
isPublicUrl(): boolean;
|
||||
isEcmBpmConfiguration(): boolean;
|
||||
reply(event: string, callback?: any): void;
|
||||
}
|
@@ -18,31 +18,45 @@
|
||||
/*tslint:disable*/ // => because of ADF file naming problems... Try to remove it, if you don't believe me :P
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { DiscoveryApi, NodesApi } from '@alfresco/js-api';
|
||||
import { AlfrescoApiV2Service } from './alfresco-api-v2.service';
|
||||
import { DiscoveryApi, NodesApi, PeopleApi, UserProfileApi } from '@alfresco/js-api';
|
||||
import { AlfrescoApiV2 } from './alfresco-api-v2';
|
||||
|
||||
@Injectable()
|
||||
export class AlfrescoApiClientFactory {
|
||||
// Here we should all the APIs from js-api
|
||||
// Here we should have all the APIs from js-api
|
||||
private discoveryApi: DiscoveryApi = null;
|
||||
private nodesApi: NodesApi = null;
|
||||
private peopleApi: PeopleApi = null;
|
||||
private profileApi: UserProfileApi = null;
|
||||
|
||||
constructor(
|
||||
private angularAlfrescoApi?: AlfrescoApiV2Service) {
|
||||
private angularAlfrescoApi?: AlfrescoApiV2) {
|
||||
}
|
||||
|
||||
getDiscoveryApi() {
|
||||
getDiscoveryApi(): DiscoveryApi {
|
||||
// DiscoveryApi needs to rely on a lot thinner interface: JsApiHttpClient; For now: "as any"
|
||||
this.discoveryApi = this.discoveryApi ?? new DiscoveryApi(this.angularAlfrescoApi as any);
|
||||
return this.discoveryApi;
|
||||
}
|
||||
|
||||
getNodesApi () {
|
||||
getNodesApi(): NodesApi {
|
||||
// NodesApi needs to rely on a lot thinner interface: JsApiHttpClient; For now: "as any"
|
||||
this.nodesApi = this.nodesApi ?? new NodesApi(this.angularAlfrescoApi as any);
|
||||
return this.nodesApi;
|
||||
}
|
||||
|
||||
getPeopleApi(): PeopleApi {
|
||||
// PeopleApi needs to rely on a lot thinner interface: JsApiHttpClient; For now: "as any"
|
||||
this.peopleApi = this.peopleApi ?? new PeopleApi(this.angularAlfrescoApi as any);
|
||||
return this.peopleApi;
|
||||
}
|
||||
|
||||
getProfileApi(): UserProfileApi {
|
||||
// PeopleApi needs to rely on a lot thinner interface: JsApiHttpClient; For now: "as any"
|
||||
this.profileApi = this.profileApi ?? new UserProfileApi(this.angularAlfrescoApi as any);
|
||||
return this.profileApi;
|
||||
}
|
||||
|
||||
getSearchApi() {
|
||||
// TODO
|
||||
}
|
||||
|
@@ -21,8 +21,9 @@ import { Injectable } from '@angular/core';
|
||||
import { AlfrescoApi, AlfrescoApiConfig } from '@alfresco/js-api';
|
||||
import { AppConfigService, AppConfigValues } from '../../app-config/app-config.service';
|
||||
import { OauthConfigModel } from '../../models/oauth-config.model';
|
||||
import { StorageService } from '../../services/storage.service';
|
||||
import { AlfrescoApiV2Service } from './alfresco-api-v2.service';
|
||||
import { AlfrescoApiV2 } from './alfresco-api-v2';
|
||||
import { LegacyAlfrescoApiServiceFacade } from './legacy-alfresco-api-service.facade';
|
||||
import { take } from 'rxjs/operators';
|
||||
|
||||
export function createAlfrescoApiV2Service(angularAlfrescoApiService: AlfrescoApiV2LoaderService) {
|
||||
return () => angularAlfrescoApiService.load();
|
||||
@@ -35,13 +36,12 @@ export class AlfrescoApiV2LoaderService {
|
||||
|
||||
constructor(
|
||||
protected appConfig: AppConfigService,
|
||||
protected storageService: StorageService,
|
||||
private alfrescoApiV2Service?: AlfrescoApiV2Service) {
|
||||
private legacyAlfrescoApiServiceFacade: LegacyAlfrescoApiServiceFacade,
|
||||
private alfrescoApiV2Service?: AlfrescoApiV2) {
|
||||
}
|
||||
|
||||
load(): Promise<any> {
|
||||
return this.appConfig.load().then(() => {
|
||||
this.storageService.prefix = this.appConfig.get<string>(AppConfigValues.STORAGE_PREFIX, '');
|
||||
return this.appConfig.onLoad.pipe(take(1)).toPromise().then(() => {
|
||||
this.initAngularAlfrescoApi();
|
||||
});
|
||||
}
|
||||
@@ -67,5 +67,6 @@ export class AlfrescoApiV2LoaderService {
|
||||
});
|
||||
|
||||
this.alfrescoApiV2Service.init(config);
|
||||
this.legacyAlfrescoApiServiceFacade.init();
|
||||
}
|
||||
}
|
||||
|
@@ -1,87 +0,0 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2019 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*tslint:disable*/ // => because of ADF file naming problems... Try to remove it, if you don't believe me :P
|
||||
|
||||
import { AlfrescoApiConfig } from '@alfresco/js-api';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { JsApiHttpClient } from '../js-api/js-api-http-client';
|
||||
import { JsApiAngularHttpClient } from './js-api-angular-http-client';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
|
||||
@Injectable()
|
||||
export class AlfrescoApiV2Service {
|
||||
public contentPrivateClient: JsApiHttpClient;
|
||||
public contentClient: JsApiHttpClient;
|
||||
public authClient: JsApiHttpClient;
|
||||
public searchClient: JsApiHttpClient;
|
||||
public discoveryClient: JsApiHttpClient;
|
||||
public gsClient: JsApiHttpClient;
|
||||
public processClient: JsApiHttpClient;
|
||||
|
||||
constructor(private httpClient: HttpClient) {}
|
||||
|
||||
init(config: AlfrescoApiConfig) {
|
||||
this.contentPrivateClient = new JsApiAngularHttpClient(
|
||||
config.hostEcm,
|
||||
config.contextRoot,
|
||||
`/api/${config.tenant}/private/alfresco/versions/1`,
|
||||
this.httpClient
|
||||
);
|
||||
|
||||
this.contentClient = new JsApiAngularHttpClient(
|
||||
config.hostEcm,
|
||||
config.contextRoot,
|
||||
`/api/${config.tenant}/public/alfresco/versions/1`,
|
||||
this.httpClient
|
||||
);
|
||||
|
||||
this.authClient = new JsApiAngularHttpClient(
|
||||
config.hostEcm,
|
||||
config.contextRoot,
|
||||
`/api/${config.tenant}/public/authentication/versions/1`,
|
||||
this.httpClient
|
||||
);
|
||||
|
||||
this.searchClient = new JsApiAngularHttpClient(
|
||||
config.hostEcm,
|
||||
config.contextRoot,
|
||||
`/api/${config.tenant}/public/search/versions/1`,
|
||||
this.httpClient
|
||||
);
|
||||
this.discoveryClient = new JsApiAngularHttpClient(
|
||||
config.hostEcm,
|
||||
config.contextRoot,
|
||||
`/api`,
|
||||
this.httpClient
|
||||
);
|
||||
|
||||
this.gsClient = new JsApiAngularHttpClient(
|
||||
config.hostEcm,
|
||||
config.contextRoot,
|
||||
`/api/${config.tenant}/public/gs/versions/1`,
|
||||
this.httpClient
|
||||
);
|
||||
|
||||
this.processClient = new JsApiAngularHttpClient(
|
||||
config.hostBpm,
|
||||
config.contextRootBpm,
|
||||
'',
|
||||
this.httpClient
|
||||
);
|
||||
}
|
||||
}
|
236
lib/core/alfresco-api/services/alfresco-api-v2.ts
Normal file
236
lib/core/alfresco-api/services/alfresco-api-v2.ts
Normal file
@@ -0,0 +1,236 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2019 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*tslint:disable*/ // => because of ADF file naming problems... Try to remove it, if you don't believe me :P
|
||||
/* eslint-disable */
|
||||
|
||||
import { AlfrescoApiConfig } from '@alfresco/js-api';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { JsApiHttpClient } from '../js-api/js-api-http-client';
|
||||
import { JsApiAngularHttpClient } from './js-api-angular-http-client';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { AlfrescoApiType, LegacyTicketApi } from '../js-api/alfresco-api-type';
|
||||
|
||||
@Injectable()
|
||||
export class AlfrescoApiV2 implements AlfrescoApiType {
|
||||
public config: AlfrescoApiConfig;
|
||||
public contentPrivateClient: JsApiHttpClient & LegacyTicketApi;
|
||||
public contentClient: JsApiHttpClient & LegacyTicketApi;
|
||||
public authClient: JsApiHttpClient;
|
||||
public searchClient: JsApiHttpClient;
|
||||
public discoveryClient: JsApiHttpClient;
|
||||
public gsClient: JsApiHttpClient;
|
||||
public processClient: JsApiHttpClient;
|
||||
|
||||
constructor(
|
||||
private httpClient: HttpClient
|
||||
) {}
|
||||
|
||||
init(config: AlfrescoApiConfig) {
|
||||
this.config = config;
|
||||
|
||||
this.contentPrivateClient = new JsApiAngularHttpClient(
|
||||
config.hostEcm,
|
||||
config.contextRoot,
|
||||
`/api/${config.tenant}/private/alfresco/versions/1`,
|
||||
this.httpClient
|
||||
) as unknown as JsApiHttpClient & LegacyTicketApi;
|
||||
|
||||
this.contentClient = new JsApiAngularHttpClient(
|
||||
config.hostEcm,
|
||||
config.contextRoot,
|
||||
`/api/${config.tenant}/public/alfresco/versions/1`,
|
||||
this.httpClient
|
||||
) as unknown as JsApiHttpClient & LegacyTicketApi;
|
||||
|
||||
this.authClient = new JsApiAngularHttpClient(
|
||||
config.hostEcm,
|
||||
config.contextRoot,
|
||||
`/api/${config.tenant}/public/authentication/versions/1`,
|
||||
this.httpClient
|
||||
);
|
||||
|
||||
this.searchClient = new JsApiAngularHttpClient(
|
||||
config.hostEcm,
|
||||
config.contextRoot,
|
||||
`/api/${config.tenant}/public/search/versions/1`,
|
||||
this.httpClient
|
||||
);
|
||||
this.discoveryClient = new JsApiAngularHttpClient(
|
||||
config.hostEcm,
|
||||
config.contextRoot,
|
||||
`/api`,
|
||||
this.httpClient
|
||||
);
|
||||
|
||||
this.gsClient = new JsApiAngularHttpClient(
|
||||
config.hostEcm,
|
||||
config.contextRoot,
|
||||
`/api/${config.tenant}/public/gs/versions/1`,
|
||||
this.httpClient
|
||||
);
|
||||
|
||||
this.processClient = new JsApiAngularHttpClient(
|
||||
config.hostBpm,
|
||||
config.contextRootBpm,
|
||||
'',
|
||||
this.httpClient
|
||||
);
|
||||
}
|
||||
|
||||
setConfig(config: AlfrescoApiConfig) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
changeWithCredentialsConfig(withCredentials: boolean) {
|
||||
console.log(withCredentials);
|
||||
debugger;
|
||||
return false;
|
||||
}
|
||||
|
||||
changeCsrfConfig(disableCsrf: boolean) {
|
||||
console.log(disableCsrf);
|
||||
debugger;
|
||||
}
|
||||
|
||||
changeEcmHost(hostEcm: string) {
|
||||
console.log(hostEcm);
|
||||
debugger;
|
||||
}
|
||||
|
||||
changeBpmHost(hostBpm: string) {
|
||||
console.log(hostBpm);
|
||||
debugger;
|
||||
}
|
||||
|
||||
login(username: string, password: string) {
|
||||
console.log(username, password);
|
||||
debugger;
|
||||
return Promise.reject();
|
||||
}
|
||||
|
||||
isCredentialValid(credential: string) {
|
||||
console.log(credential);
|
||||
debugger;
|
||||
return false;
|
||||
}
|
||||
|
||||
implicitLogin() {
|
||||
debugger;
|
||||
return Promise.reject();
|
||||
}
|
||||
|
||||
loginTicket(ticketEcm: string, ticketBpm: string) {
|
||||
console.log(ticketEcm, ticketBpm);
|
||||
debugger;
|
||||
return Promise.reject();
|
||||
}
|
||||
|
||||
logout() {
|
||||
debugger;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
isLoggedIn() {
|
||||
debugger;
|
||||
return false;
|
||||
}
|
||||
|
||||
isBpmLoggedIn() {
|
||||
debugger;
|
||||
return false;
|
||||
}
|
||||
|
||||
isEcmLoggedIn() {
|
||||
debugger;
|
||||
return false;
|
||||
}
|
||||
|
||||
getBpmUsername() {
|
||||
debugger;
|
||||
return 'Kakarot';
|
||||
}
|
||||
|
||||
getEcmUsername() {
|
||||
debugger;
|
||||
return 'Vegeta';
|
||||
}
|
||||
|
||||
refreshToken() {
|
||||
debugger;
|
||||
return Promise.reject();
|
||||
}
|
||||
|
||||
getTicketAuth() {
|
||||
debugger;
|
||||
return 'xyz-123';
|
||||
}
|
||||
|
||||
setTicket(ticketEcm: string, TicketBpm: string) {
|
||||
console.log(ticketEcm, TicketBpm);
|
||||
debugger;
|
||||
}
|
||||
|
||||
invalidateSession() {
|
||||
debugger;
|
||||
}
|
||||
|
||||
getTicketBpm() {
|
||||
debugger;
|
||||
return 'xyz-456';
|
||||
}
|
||||
|
||||
getTicketEcm() {
|
||||
debugger;
|
||||
return 'xyz-789';
|
||||
}
|
||||
|
||||
getTicket() {
|
||||
debugger;
|
||||
return ['xyz-000'];
|
||||
}
|
||||
|
||||
isBpmConfiguration() {
|
||||
debugger;
|
||||
return false;
|
||||
}
|
||||
|
||||
isEcmConfiguration() {
|
||||
debugger;
|
||||
return false;
|
||||
}
|
||||
|
||||
isOauthConfiguration() {
|
||||
debugger;
|
||||
return false;
|
||||
}
|
||||
|
||||
isPublicUrl() {
|
||||
debugger;
|
||||
return false;
|
||||
}
|
||||
|
||||
isEcmBpmConfiguration() {
|
||||
debugger;
|
||||
return false;
|
||||
}
|
||||
|
||||
reply(event: string, callback?: any) {
|
||||
console.log(event, callback);
|
||||
debugger;
|
||||
}
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2019 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*tslint:disable*/ // => because of ADF file naming problems... Try to remove it, if you don't believe me :P
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ReplaySubject } from 'rxjs/internal/ReplaySubject';
|
||||
import { AlfrescoApiType } from '../js-api/alfresco-api-type';
|
||||
import { AlfrescoApiV2 } from './alfresco-api-v2';
|
||||
|
||||
@Injectable()
|
||||
export class LegacyAlfrescoApiServiceFacade {
|
||||
constructor(private alfrescoApiV2: AlfrescoApiV2) {}
|
||||
|
||||
alfrescoApiInitialized: ReplaySubject<boolean> = new ReplaySubject(1);
|
||||
|
||||
getInstance(): AlfrescoApiType {
|
||||
return this.alfrescoApiV2;
|
||||
}
|
||||
|
||||
init() {
|
||||
this.alfrescoApiInitialized.next(true);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user