/** * @param name * @param value */ public void setAttribute(String name, Object value) { simpleCredentials.setAttribute(name, value); }
public void setAttribute(String name, Object value) { registrySimpleCredentials.setAttribute(name, value); }
/** * Constructor as required by the JCR TCK. * * @param settings repository settings */ public JackrabbitRepositoryStub(Properties settings) { super(getStaticProperties()); // set some attributes on the sessions superuser.setAttribute("jackrabbit", "jackrabbit"); readwrite.setAttribute("jackrabbit", "jackrabbit"); readonly.setAttribute("jackrabbit", "jackrabbit"); // Repository settings this.settings = settings; }
@Override public boolean setAttributes(@NotNull Credentials credentials, @NotNull Map<String, ?> attributes) { if (credentials instanceof SimpleCredentials) { SimpleCredentials sc = (SimpleCredentials) credentials; for (Map.Entry<String, ?> entry : attributes.entrySet()) { sc.setAttribute(entry.getKey(), entry.getValue()); } return true; } else { return false; } } }
@Override public boolean setAttributes(@Nonnull Credentials credentials, @Nonnull Map<String, ?> attributes) { if (credentials instanceof SimpleCredentials) { SimpleCredentials sc = (SimpleCredentials) credentials; for (Map.Entry<String, ?> entry : attributes.entrySet()) { sc.setAttribute(entry.getKey(), entry.getValue()); } return true; } else { return false; } } }
public ConstantCredentialsStrategy( final String userID, final String preAuthenticationToken ) { Assert.hasText( userID ); Assert.hasText( preAuthenticationToken ); SimpleCredentials creds = new SimpleCredentials( userID, PASSWORD ); creds.setAttribute( ATTR_PRE_AUTHENTICATION_TOKEN, preAuthenticationToken ); this.credentials = creds; }
@Override public void runTest() throws RepositoryException { Repository repository = getRepository(); String t = USER + r.nextInt(numberOfUsers); SimpleCredentials creds = new SimpleCredentials(t, t.toCharArray()); creds.setAttribute(".token", ""); repository.login(creds).logout(); }
public Credentials getCredentials() { String userId = getUserId(); SimpleCredentials creds = new SimpleCredentials( userId, PASSWORD ); creds.setAttribute( ATTR_PRE_AUTHENTICATION_TOKEN, preAuthenticationToken ); return creds; }
private AuthenticationInfo getAuthInfoFromUser(OpenIdUser user) { String jcrId = OpenIDUserUtil.getPrincipalName(user.getIdentity()); SimpleCredentials creds = new SimpleCredentials(jcrId,new char[0]); creds.setAttribute(getClass().getName(), user); return new AuthenticationInfo(OpenIDConstants.OPEN_ID_AUTH_TYPE, creds); }
public WorkflowManagerImpl(Session session) throws RepositoryException { this.userSession = session; SimpleCredentials workflowuser = new SimpleCredentials("workflowuser", new char[]{}); workflowuser.setAttribute(NO_SYSTEM_IMPERSONATION, Boolean.TRUE); this.workflowSession = session.impersonate(workflowuser); ((HippoSession)workflowSession).disableVirtualLayers(); configurationId = session.getRootNode().getNode(CONFIGURATION_PATH + "/" + WORKFLOWS_PATH).getIdentifier(); workflowLogger = new WorkflowLogger(workflowSession); }
private Session openSession(Repository rep, boolean autoFix) throws RepositoryException { SimpleCredentials cred = new SimpleCredentials("admin", "admin".toCharArray()); if (autoFix) { cred.setAttribute("org.apache.jackrabbit.autoFixCorruptions", "true"); } return rep.login(cred); }
private void authenticate(String expiredPw, Object newPw) throws LoginException { SimpleCredentials creds = new SimpleCredentials(userId, expiredPw.toCharArray()); creds.setAttribute(UserConstants.CREDENTIALS_ATTRIBUTE_NEWPASSWORD, newPw); Authentication a = new UserAuthentication(getUserConfiguration(), root, userId); a.authenticate(creds); }
public void testDoCreateToken() { assertFalse(TokenBasedAuthentication.doCreateToken(creds)); assertFalse(TokenBasedAuthentication.doCreateToken(simpleCreds)); assertFalse(TokenBasedAuthentication.doCreateToken(tokenCreds)); SimpleCredentials sc = new SimpleCredentials("uid", "pw".toCharArray()); sc.setAttribute(TokenBasedAuthentication.TOKEN_ATTRIBUTE, null); assertFalse(TokenBasedAuthentication.doCreateToken(sc)); sc.setAttribute(TokenBasedAuthentication.TOKEN_ATTRIBUTE, "somevalue"); assertFalse(TokenBasedAuthentication.doCreateToken(sc)); sc.setAttribute(TokenBasedAuthentication.TOKEN_ATTRIBUTE, ""); assertTrue(TokenBasedAuthentication.doCreateToken(sc)); } }
@Test public void testSimpleCredentialsWithAttribute() throws Exception { ContentSession cs = null; try { SimpleCredentials sc = (SimpleCredentials) getAdminCredentials(); sc.setAttribute(".token", ""); cs = login(sc); } finally { if (cs != null) { cs.close(); } } }
@Test public void testCreateTokenWithInvalidExpirationParam() throws Exception { SimpleCredentials sc = new SimpleCredentials(userId, new char[0]); sc.setAttribute(TokenProvider.PARAM_TOKEN_EXPIRATION, "invalid"); try { tokenProvider.createToken(sc); fail(); } catch (NumberFormatException e) { // success } }
public void testDoCreateToken() { assertFalse(TokenBasedAuthentication.doCreateToken(creds)); assertFalse(TokenBasedAuthentication.doCreateToken(simpleCreds)); assertFalse(TokenBasedAuthentication.doCreateToken(tokenCreds)); SimpleCredentials sc = new SimpleCredentials("uid", "pw".toCharArray()); sc.setAttribute(TokenBasedAuthentication.TOKEN_ATTRIBUTE, null); assertFalse(TokenBasedAuthentication.doCreateToken(sc)); sc.setAttribute(TokenBasedAuthentication.TOKEN_ATTRIBUTE, "somevalue"); assertFalse(TokenBasedAuthentication.doCreateToken(sc)); sc.setAttribute(TokenBasedAuthentication.TOKEN_ATTRIBUTE, ""); assertTrue(TokenBasedAuthentication.doCreateToken(sc)); } }
@Override public void before() throws Exception { super.before(); tokenConfiguration.setSecurityProvider(getSecurityProvider()); context.registerInjectActivateService(tokenConfiguration, ImmutableMap.<String, Object>of( TokenProvider.PARAM_TOKEN_EXPIRATION, 25, TokenProvider.PARAM_TOKEN_LENGTH, 4)); sc = new SimpleCredentials(getTestUser().getID(), new char[0]); sc.setAttribute(TokenConstants.TOKEN_ATTRIBUTE, ""); }
@Override protected void setUp() throws Exception { super.setUp(); String adminId = getHelper().getProperty(RepositoryStub.PROP_PREFIX + '.' + RepositoryStub.PROP_SUPERUSER_NAME); String adminPw = getHelper().getProperty(RepositoryStub.PROP_PREFIX + '.' + RepositoryStub.PROP_SUPERUSER_PWD); SimpleCredentials credentials = new SimpleCredentials(adminId, adminPw.toCharArray()); credentials.setAttribute(RepositoryImpl.REFRESH_INTERVAL, 0); adminSession = getHelper().getRepository().login(credentials); adminUserManager = ((JackrabbitSession) adminSession).getUserManager(); }
@Test public void testSingleValued() { CredentialsSupport cs = CompositeCredentialsSupport.newInstance(() -> newHashSet(SimpleCredentialsSupport.getInstance())); assertEquals(SimpleCredentialsSupport.getInstance().getCredentialClasses(), cs.getCredentialClasses()); assertTrue(cs.getAttributes(new TestCredentials()).isEmpty()); SimpleCredentials creds = new SimpleCredentials("userid", new char[0]); creds.setAttribute("attr", "value"); assertEquals(SimpleCredentialsSupport.getInstance().getAttributes(creds), cs.getAttributes(creds)); }
@Test public void testCreateTokenWithExpirationParam() throws Exception { SimpleCredentials sc = new SimpleCredentials(userId, new char[0]); sc.setAttribute(TokenProvider.PARAM_TOKEN_EXPIRATION, 100000); TokenInfo info = tokenProvider.createToken(sc); assertTokenInfo(info, userId); Tree tokenTree = getTokenTree(info); assertNotNull(tokenTree); assertTrue(tokenTree.exists()); assertTrue(tokenTree.hasProperty(TokenProvider.PARAM_TOKEN_EXPIRATION)); assertEquals(100000, tokenTree.getProperty(TokenProvider.PARAM_TOKEN_EXPIRATION).getValue(Type.LONG).longValue()); }